All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Johannes Altmanninger <aclopte@gmail.com>
Cc: git@vger.kernel.org
Subject: Re* [PATCH] rerere-train: modernise a bit
Date: Sun, 27 Feb 2022 11:07:55 -0800	[thread overview]
Message-ID: <xmqqy21w3z78.fsf_-_@gitster.g> (raw)
In-Reply-To: <20220227180203.pakrqimsxbjx47tu@gmail.com> (Johannes Altmanninger's message of "Sun, 27 Feb 2022 19:02:03 +0100")

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.

    $ 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

  reply	other threads:[~2022-02-27 19:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-16  7:05 [PATCH] rerere-train: modernise a bit Junio C Hamano
2022-02-20 19:52 ` Derrick Stolee
2022-02-27 18:02 ` Johannes Altmanninger
2022-02-27 19:07   ` Junio C Hamano [this message]
2022-02-27 20:23     ` Re* " Johannes Altmanninger
2022-02-27 22:13       ` Junio C Hamano
2022-02-27 22:09 ` [PATCH v2] rerere-train: two fixes to the use of "git show -s" Junio C Hamano
2022-02-28  5:33   ` Johannes Altmanninger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqy21w3z78.fsf_-_@gitster.g \
    --to=gitster@pobox.com \
    --cc=aclopte@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.