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

Re: [PATCH v2 6/7] rebase: write better reflog messages

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 19, 2013, 18:29 UTC
Message-ID
<7v4ncu0xa4.fsf@alter.siamese.dyndns.org>
In-Reply-To
<7v8v260yy5.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 10 quoted lines
> Junio C Hamano <gitster@pobox.com> writes:
>
>> Excellent question, and I think this illustrates why the recent
>> reroll that uses an approach to use base_reflog_action is not
>> complete and needs further work (to put it mildly).
>> ...
>> That essentially boils down to the very original suggestion I made
>> before Ram introduced the base_reflog_action.
>
> So how about doing something like this?

Having said all that, although I think the "something like this" patch is an improvement in that it spells out the rules regarding the use of GIT_REFLOG_ACTION environment variable, which was not documented so far, I think the environment variable is showing its flaws.

It was a good mechanism in simpler times, back when "git commit", "git fetch" and "git merge" were its primary users. They didn't do many ref updates, and having a way to record that "this update was done by a 'merge' command initiated by the end user" was perfectly adequate.

For a command like "rebase" that can do many ref updates, having to set a custom message and export the variable in each and every step is cumbersome, and keeping the same prefix across becomes even more so.

The $orig_reflog_action used inside git-rebase--interactive is a reasonable local solution for the "keeping the same prefix" problem, but it is a _local_ solution that does not scale. In the end, it updates the GIT_REFLOG_ACTION variable, so the script has to be very careful to make sure the variable has a sensible value before calling any ref-updating "git" command. It will have to set it back to $orig_reflog_action if it ever wants to call another scripted Porcelain.

Among the C infrastructure, commit, fetch, merge and reset are the only ones that pay attention to GIT_REFLOG_ACTION, and we will be adding checkout to the mix. If we originally did not make the mistake of using GIT_REFLOG_ACTION as a whole message, and instead used it to convey _only_ the prefix (i.e. "rebase", "am", etc.) to subprocesses in order to remember what the end-user initiated command was, and used a command line argument to give the actual messages, we would have been in much better shape. E.g. a "checkout" call inside "git rebase" may become

	git checkout \
            --reflog-message="$GIT_REFLOG_ACTION: detaching" \
	    $onto^0

and nobody other than set_reflog_action shell function would be setting GIT_REFLOG_ACTION variable.

Oh well.
Previous: Junio C HamanoNext: Ramkumar Ramachandra
Message 14 of 19 in “Re-roll rr/rebase-checkout-reflog”
  1. 0/7 Re-roll rr/rebase-checkout-reflogRamkumar Ramachandra, Jun 18, 2013
  2. 1/7 t/t7512-status-help: test "HEAD detached from"Ramkumar Ramachandra, Jun 18, 2013
  3. 2/7 wt-status: remove unused field in grab_1st_switch_cbdataRamkumar Ramachandra, Jun 18, 2013
  4. 3/7 t/t2012-checkout-last: test "checkout -" after a rebaseRamkumar Ramachandra, Jun 18, 2013
  5. 4/7 status: do not depend on rebase reflog messagesRamkumar Ramachandra, Jun 18, 2013
  6. 5/7 checkout: respect GIT_REFLOG_ACTIONRamkumar Ramachandra, Jun 18, 2013
  7. 6/7 rebase: write better reflog messagesRamkumar Ramachandra, Jun 18, 2013
  8. Junio C HamanoJun 18, 2013
  9. Johannes SixtJun 19, 2013
  10. Ramkumar RamachandraJun 19, 2013
  11. Johannes SixtJun 19, 2013
  12. Junio C HamanoJun 19, 2013
  13. Junio C HamanoJun 19, 2013
  14. Junio C HamanoJun 19, 2013
  15. 7/7 rebase -i: write better reflog messagesRamkumar Ramachandra, Jun 18, 2013
  16. Junio C HamanoJun 18, 2013
  17. Ramkumar RamachandraJun 18, 2013
  18. Junio C HamanoJun 18, 2013
  19. Ramkumar RamachandraJun 19, 2013

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.