git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: RFC - "git editlog" feature for fixing up local commit messages

From
Avery Pennarun <apenwarr@gmail.com>
Date
Mar 29, 2010, 20:14 UTC
Message-ID
<32541b131003291314r2f5a77e8g28e79b5983821e41@mail.gmail.com>
In-Reply-To
<20100329133132.GA12201@thyrsus.com>
On Mon, Mar 29, 2010 at 9:31 AM, Eric Raymond <esr@thyrsus.com> wrote:
Show 8 quoted lines
> My editcomment script, as it exists, has a technical problem...the
> editor needs to be something like emacsclient that actually invokes in
> a different X window, otherwise whatever it writes to stdout will end
> up stuffed in the comment along with the text I actually wanted to put
> there.  The underlying problem is that git-filter-branch is sort of a
> nuclear-powered chainsaw - gets the job done, but in a way that is
> prone to messy side effects.  A more elegant implementation would
> probably need to tie deeper into the plumbing.

It ought to be easy to work around this; simply extract the log message *before* filter-branch using something like

       git cat-file commit HEAD | tail -n +6 >msg.tmp

(I'm sure someone will correct me by providing a less revolting way to extract the commit message, but it's somehow not coming to me right now.)

Then launch $EDITOR to edit the message, then inside the filter-branch, just use that file instead of launching the editor.

Alternatively, in case you want the option of editing *multiple* commit messages at once, you could just redirect stdin/stdout to /dev/tty.

A further option would be to extend git-rebase--interactive.sh (yes, it's just a shell script) to take an option that makes a given commit (or commits) 'reword' by default instead of 'pick'. And maybe another option to make git-rebase--interactive.sh not actually pop up an editor before it starts running. Then your editcommit script could just be a thin wrapper around rebase with those options.

<insert obligatory wistful reference to git-sequencer> (I don't actually know anything about git-sequencer.)

Have fun,
Avery
Previous: Nicolas PitreNext: Michael J Gruber
Message 4 of 8 in “RFC - "git editlog" feature for fixing up local commit messages”
  1. Eric RaymondMar 29, 2010
  2. Sverre RabbelierMar 29, 2010
  3. Nicolas PitreMar 29, 2010
  4. Avery PennarunMar 29, 2010
  5. Michael J GruberMar 30, 2010
  6. Avery PennarunMar 30, 2010
  7. Jonathan NiederMar 30, 2010
  8. Miles BaderMar 30, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.