felixSchl/git-fiddle

Add a command line argument to only edit commit messages

Closed this issue · 5 comments

In general the one thing I need to edit when rebasing is commit messages. It'd be nice to have a command line argument for git-fiddle that only allows editing commit messages. Even better if the first line of the commit message was on the same line as the 'pick' command, since for the common case of single-line commit messages this would both maximize use of vertical space and would allow more convenient use of editor features like vim's vertical block editing mode and sublime text's multiple cursors.

Been thinking about this, too. I see the vertical block mode appeal. I wonder if we just add some more toggles to disable author and date and always put the subject line on the same line as the rest, with the description below?

So we could have:

<action> <sha> [<timestamp>] [by: <author>] [> <msg>]
[<extended-msg>]

It's a bit tricky to parse this. <action> <sha> is easy. I want to be able to use approxidate timestamps, so I cannot use a fixed amount of columns for the <timestamp>. That's why I have to use 4 characters for "by: ". If we where to add the message, I would propose to add the following character sequence "> ". That should be fairly unambiguous, even if the user name has an e-mail (<name> <<email>>).

Alternatively, we could do this:

<action> <sha> [<author>] [@ <timestamp>] [> <msg>]
[<extended-msg>]

which would shave off the for characters "by: " (now "@").

I am keen to action this, would be super helpful to have.

Yet another option would be to do this:

<action> <sha> [an: <author name>] [ad: <timestamp>] [s: <subject>]
[<body>]

where, an, ad and s are for git pretty-formats and must be considered keywords. Once s: has been matched, the rest of the line must be considered to be part of <subject>.

Alright, this is implemented on a branch: https://github.com/felixSchl/git-fiddle/tree/feature/inline-subjects.

Let me know if anything is unclear.

To only edit commit messages, just do git fiddle --no-fiddle --fiddle-subject. If you have ideas to make the CLI experience better, please do let me know. You can configure the behavior also using git config (see README).

EDIT:

To clarify, I went with this:

<action> <sha> [<author>] [@ <timestamp>] [> <subject>]
[<body>]

I just committed this to master. I've added tests for most things, so should be good to go... could do with more tests, though. I will leave this open for a bit to get your feedback. I am also interested in making the CLI smoother, but have no good ideas so far.

Considering this done. The functionality is there and the CLI can be reviewed anytime.