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

Re: [PATCH] git-rebase: fix probable reflog typo

From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Date
Apr 23, 2014, 11:36 UTC
Message-ID
<vpqy4ywxoos.fsf@anie.imag.fr>
In-Reply-To
<1398212084-16304-1-git-send-email-felipe.contreras@gmail.com>
Felipe Contreras <felipe.contreras@gmail.com> writes:
Show 6 quoted lines
> Commit 26cd160 (rebase -i: use a better reflog message) tried to produce
> a better reflog message, however, it seems a statement was introduced by
> mistake.
>
> 'comment_for_reflog start' basically overides the GIT_REFLOG_ACTION we
> just set.

I think this is more complex than this. To give a bit more context, the code you're changing is:

comment_for_reflog start
if test ! -z "$switch_to"
then
	GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION: checkout $switch_to"
	output git checkout "$switch_to" -- ||
	die "Could not checkout $switch_to"
	comment_for_reflog start
fi

The GIT_REFLOG_ACTION= changes the reflog message for the git checkout command.

Since we use the construct
GIT_REFLOG_ACTION="..." shell_function

the shell may keep $GIT_REFLOG_ACTION set after calling the function (I don't remember what POSIX says, but dash does it: $ f () { echo $X; } $ X=42 f 42 $ echo $X 42 $ X=y f y $ echo $X y ).

So, one needs to reset $GIT_REFLOG_ACTION to what it used to be if is it to be used later. However, it seems to me that the "comment_for_reflog start" is used only for this checkout command. If so, there's no need for the "comment_for_reflog start" before the if statement either.

In any case, this should be clarified with at least a comment in the code.

Show 13 quoted lines
> diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
> index 43631b4..5f1d8c9 100644
> --- a/git-rebase--interactive.sh
> +++ b/git-rebase--interactive.sh
> @@ -893,8 +893,6 @@ then
>  	GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION: checkout $switch_to"
>  	output git checkout "$switch_to" -- ||
>  	die "Could not checkout $switch_to"
> -
> -	comment_for_reflog start
>  fi
>  
>  orig_head=$(git rev-parse --verify HEAD) || die "No HEAD?"
-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Previous: Felipe ContrerasNext: Felipe Contreras
Message 2 of 6 in “git-rebase: fix probable reflog typo”
  1. git-rebase: fix probable reflog typoFelipe Contreras, Apr 23, 2014
  2. Matthieu MoyApr 23, 2014
  3. Felipe ContrerasApr 23, 2014
  4. Matthieu MoyApr 24, 2014
  5. Felipe ContrerasApr 24, 2014
  6. Matthieu MoyApr 24, 2014

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.