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

Re: want <reason> option to git-rebase

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Jun 20, 2018, 01:49 UTC
Message-ID
<20180620014940.GD122284@aiede.svl.corp.google.com>
In-Reply-To
<c5fc1505-9847-25d8-02f3-c0e666afdd1d@kdbg.org>
Johannes Sixt wrote:
> Am 19.06.2018 um 03:06 schrieb Jonathan Nieder:
>> Ian Jackson wrote[1]:
Show 6 quoted lines
>>> git-rebase leaves entries like this in the reflog:
>>>
>>>    c15f4d5391 HEAD@{33}: rebase: checkout c15f4d5391ff07a718431aca68a73e672fe8870e
>>>
>>> It would be nice if there were an option to control this message.
>>> Particularly, when another tool invokes git-rebase,
[...]
Show 21 quoted lines
>>  From git(1):
>>
>>   GIT_REFLOG_ACTION
>> 	When a ref is updated, reflog entries are created to keep
>> 	track of the reason why the ref was updated (which is
>> 	typically the name of the high-level command that updated the
>> 	ref), in addition to the old and new values of the ref. A
>> 	scripted Porcelain command can use set_reflog_action helper
>> 	function in git-sh-setup to set its name to this variable when
>> 	it is invoked as the top level command by the end user, to be
>> 	recorded in the body of the reflog.
>>
>> "git rebase" sets this itself, so it doesn't solve your problem.
>
> If it does so unconditionally, then that is a bug. If a script wants to set
> GIT_REFLOG_ACTION, but finds that it is already set, then it must not change
> the value. set_reflog_action in git-sh-setup does the right thing.
>
> So, if there is another script or application around git-rebase, then it
> should just set GIT_REFLOG_ACTION (if it is not already set) and export the
> environment variable to git-rebase.

Oh, good catch. "git rebase" already generally does the right thing when GIT_REFLOG_ACTION is set (by only appending to it and never replacing it).

Ian, does that work well for you? If so, any ideas where it should go in the documentation to be more discoverable for next time?

Footnotes:
- git-rebase--interactive.sh has the following snippet:
	case "$orig_reflog_action" in
	''|rebase*)
		GIT_REFLOG_ACTION="rebase -i ($1)"
  This is a little too aggressive, since it's possible for a
  user-specified reflog action to start with "rebase" and
  contain additional information that shouldn't be removed.
- likewise in git-rebase--preserve-merges.sh.

Thanks, Jonathan

Previous: Johannes SixtNext: Ian Jackson
Message 4 of 5 in “Re: want <reason> option to git-rebase”
  1. Jonathan NiederJun 19, 2018
  2. Ian JacksonJun 19, 2018
  3. Johannes SixtJun 19, 2018
  4. Jonathan NiederJun 20, 2018
  5. Ian JacksonJun 20, 2018

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.