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

Re: [PATCH] rerere-train: modernise a bit

From
Johannes Altmanninger <aclopte@gmail.com>
Date
Feb 27, 2022, 18:02 UTC
Message-ID
<20220227180203.pakrqimsxbjx47tu@gmail.com>
In-Reply-To
<xmqqsfsjuw8m.fsf@gitster.g>
On Tue, Feb 15, 2022 at 11:05:45PM -0800, Junio C Hamano wrote:
Show 7 quoted lines
> The script wants to create a list of merges using "rev-list" and
> filters commits that do not have more than one parent, but if we
> always pass "--merges" to "rev-list", there is no need to filter.
> 
> The command uses "git show --pretty=format:..." on a single commit
> while generating progress reports, which means this title line is
> left unterminated.  It should have used --pretty=tformat:...

Yep, tformat is more correct semantically, but it's worth noting that there is no behavior change here. These commands behave the same

	git show -s --pretty=tformat:"Learning" HEAD
	git show -s --pretty=format:"Learning" HEAD
I guess we automagically add a final newline somewhere, if it's missing.

If there is a final newline ("Learning%n"), then the commands show different behavior. The subject (%s) can never have a newline, so that's not the case here.

I'd add something like this (for the lack of knowing where exactly the implicit newline comes from):

	No harm was done because we implicitly add the trailing newline,
	but it should have used --pretty=tformat:...
> instead, or better yet, use the more modern --format=... to ensure
> that the title line is properly terminated.
Show 35 quoted lines
> 
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
>  contrib/rerere-train.sh | 9 ++-------
>  1 file changed, 2 insertions(+), 7 deletions(-)
> 
> diff --git c/contrib/rerere-train.sh w/contrib/rerere-train.sh
> index 75125d6ae0..499b07e4a6 100755
> --- c/contrib/rerere-train.sh
> +++ w/contrib/rerere-train.sh
> @@ -66,14 +66,9 @@ original_HEAD=$(git rev-parse --verify HEAD) || {
>  
>  mkdir -p "$GIT_DIR/rr-cache" || exit
>  
> -git rev-list --parents "$@" |
> +git rev-list --parents --merges "$@" |
>  while read commit parent1 other_parents
>  do
> -	if test -z "$other_parents"
> -	then
> -		# Skip non-merges
> -		continue
> -	fi
>  	git checkout -q "$parent1^0"
>  	if git merge $other_parents >/dev/null 2>&1
>  	then
> @@ -86,7 +81,7 @@ do
>  	fi
>  	if test -s "$GIT_DIR/MERGE_RR"
>  	then
> -		git show -s --pretty=format:"Learning from %h %s" "$commit"
> +		git show -s --format="Learning from %h %s" "$commit"
>  		git rerere
>  		git checkout -q $commit -- .
>  		git rerere
Previous: Derrick StoleeNext: Junio C Hamano
Message 3 of 8 in “rerere-train: modernise a bit”
  1. rerere-train: modernise a bitJunio C Hamano, Feb 16, 2022
  2. Derrick StoleeFeb 20, 2022
  3. Johannes AltmanningerFeb 27, 2022
  4. Re* [PATCH] rerere-train: modernise a bitJunio C Hamano, Feb 27, 2022
  5. Johannes AltmanningerFeb 27, 2022
  6. Junio C HamanoFeb 27, 2022
  7. rerere-train: two fixes to the use of "git show -s"Junio C Hamano, Feb 27, 2022
  8. Johannes AltmanningerFeb 28, 2022

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.