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

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

From
Johannes Altmanninger <aclopte@gmail.com>
Date
Feb 27, 2022, 20:23 UTC
Message-ID
<20220227202328.7afrpuaujgwsnmcy@gmail.com>
In-Reply-To
<xmqqy21w3z78.fsf_-_@gitster.g>
On Sun, Feb 27, 2022 at 11:07:55AM -0800, Junio C Hamano wrote:
Show 12 quoted lines
> Johannes Altmanninger <aclopte@gmail.com> writes:
> 
> > 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
> 
> Your observation is not quite right.
> 
> The difference between tformat and format does matter in practice,
> unless your pager is hiding the difference.

Right, I forgot about the pager. Both patches LGTM then. The --no-pager fix would have prevented my confusion, which is an argument for placing it first.

Show 45 quoted lines
> 
>     $ export GIT_PAGER=cat; # disable the pager
>     $ git show -s --pretty=format:"%s" HEAD; echo Q
>     The eighth batchQ
>     $ exit
> 
> This episode also exposes another bug in the rerere-train script,
> caused by the fact that it lets GIT_PAGER to interfere.
> 
> --- >8 ---
> Subject: rerere-train: prevent GIT_PAGER from pausing 'git show -s'
> 
> The script uses "git show -s --format" to display the title of the
> merge commit being studied, without explicitly disabling the pager,
> which is not a safe thing to do in a script.
> 
> For example, when the pager is set to "less" with "-SF" options (-S
> tells the pager not to fold lines but allow horizontal scrolling to
> show the overly long lines, -F tells the pager not to wait if the
> output in its entirety is shown on a single page), and the title of
> the merge commit is longer than the width of the terminal, the pager
> will wait until the end-user tells it to quit after showing the
> single line.
> 
> Explicitly disable the pager for this "git show" invocation to avoid
> this.
> 
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
>  contrib/rerere-train.sh | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git c/contrib/rerere-train.sh w/contrib/rerere-train.sh
> index 499b07e4a6..2b9df7b6f2 100755
> --- c/contrib/rerere-train.sh
> +++ w/contrib/rerere-train.sh
> @@ -81,7 +81,7 @@ do
>  	fi
>  	if test -s "$GIT_DIR/MERGE_RR"
>  	then
> -		git show -s --format="Learning from %h %s" "$commit"
> +		git --no-pager show -s --format="Learning from %h %s" "$commit"
>  		git rerere
>  		git checkout -q $commit -- .
>  		git rerere
Previous: Junio C HamanoNext: Junio C Hamano
Message 5 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.