From: Junio C Hamano <gitster@pobox.com>
To: "Rubén Justo" <rjusto@gmail.com>
Cc: phillip.wood@dunelm.org.uk, Git List <git@vger.kernel.org>
Subject: Re: [PATCH 2/2] add-patch: render hunks through the pager
Date: Fri, 26 Jul 2024 11:36:20 -0700 [thread overview]
Message-ID: <xmqq8qxouhjv.fsf@gitster.g> (raw)
In-Reply-To: <38e190de-cbe4-4f75-acdb-fe566e541179@gmail.com> ("Rubén Justo"'s message of "Thu, 25 Jul 2024 18:43:45 +0200")
Rubén Justo <rjusto@gmail.com> writes:
> Make the print command trigger the pager when invoked using a capital
> 'P', to make it easier for the user to review long hunks.
>
> Note that if the PAGER ends unexpectedly before we've been able to send
> the payload, perhaps because the user is not interested in the whole
> thing, we might receive a SIGPIPE, which would abruptly and unexpectedly
> terminate the interactive session for the user.
>
> Therefore, we need to ignore a possible SIGPIPE signal. Add a test for
> this, in addition to the test for normal operation.
>
> For the SIGPIPE test, we need to make sure that we completely fill the
> operating system's buffer, otherwise we might not trigger the SIGPIPE
> signal. The normal size of this buffer in different OSs varies from a
> few KBs to 1MB. Use a payload large enough to guarantee that we exceed
> this limit.
Up to this point, it is fine.
But ...
> For the tests, avoid the common construct to set and export one-shot
> variables within the scope of a command:
>
> VAR=VAL command args
>
> It happens that when "command" is a shell function that in turn executes
> a "command", the behavior with "VAR" varies depending on the shell:
>
> ** Bash 5.2.21 **
>
> $ f () { bash -c 'echo A=$A'; }
> $ A=1 f
> A=1
>
> ** dash 0.5.12-9 **
>
> $ f () { bash -c 'echo A=$A'; }
> $ A=1 f
> A=1
>
> ** dash 0.5.10.2-6 **
>
> $ f () { bash -c 'echo A=$A'; }
> $ A=1 f
> A=
>
> POSIX explicitly says the effect of this construct is unspecified.
... unless the patch is about changing an existing
GIT_PAGER=... test_terminal git add -p
into
(
GIT_PAGER=...; export GIT_PAGER
test_terminal git add -p
)
then all of the above is irrelevant noise that says "as the coding
guidelines tell us not to use the non-portable 'VAR=VAL shell_func'
construct, we don't."
Always write your proposed log message to those who will read "git
log -p" 6 months down the road. To them, the trouble we had while
diagnosing the true cause of the breakage in the previous iteration
do not exist. It is not part of the "log -p" output they see.
> One of our CI jobs on GitHub Actions uses Ubuntu 20.04 running dash
> 0.5.10.2-6, so avoid using the construct and use a subshell instead.
And it does not matter if all CI platforms are updated. As long as
our coding guidelines say not to use this construct, we don't.
In any case, that is an appropriate thing to say in a commit that
fixes use of such a construct, but not a commit that uses the right
constuct from the get-go.
I have to say that the [4/4] in the previous round, i.e., fc87b2f7
(add-patch: render hunks through the pager, 2024-07-25) in my tree,
is better than this version.
Thanks.
next prev parent reply other threads:[~2024-07-26 18:36 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-23 0:39 [PATCH v2 0/2] add-p P fixups Rubén Justo
2024-07-23 0:42 ` [PATCH v2 1/2] t3701: avoid one-shot export for shell functions Rubén Justo
2024-07-23 0:42 ` [PATCH v2 2/2] pager: make wait_for_pager a no-op for "cat" Rubén Justo
2024-07-23 0:54 ` [PATCH v2 0/2] add-p P fixups Junio C Hamano
2024-07-23 9:15 ` Phillip Wood
2024-07-23 16:52 ` Junio C Hamano
2024-07-23 22:08 ` Rubén Justo
2024-07-24 15:21 ` phillip.wood123
2024-07-24 16:12 ` Rubén Justo
2024-07-25 9:45 ` Phillip Wood
2024-07-25 12:16 ` Rubén Justo
2024-07-25 13:42 ` [PATCH 0/4] squash fixups in rj/add-p-pager Rubén Justo
2024-07-25 13:44 ` [PATCH 1/4] add-patch: test for 'p' command Rubén Justo
2024-07-25 13:44 ` [PATCH 2/4] pager: do not close fd 2 unnecessarily Rubén Justo
2024-07-25 13:44 ` [PATCH 3/4] pager: introduce wait_for_pager Rubén Justo
2024-07-25 13:44 ` [PATCH 4/4] add-patch: render hunks through the pager Rubén Justo
2024-07-25 15:24 ` [PATCH v2 0/2] add-p P fixups Junio C Hamano
2024-07-25 16:41 ` Re* " Rubén Justo
2024-07-25 16:43 ` [PATCH 1/2] pager: introduce wait_for_pager Rubén Justo
2024-07-25 16:43 ` [PATCH 2/2] add-patch: render hunks through the pager Rubén Justo
2024-07-26 18:36 ` Junio C Hamano [this message]
2024-07-27 1:40 ` Junio C Hamano
2024-07-27 14:33 ` Rubén Justo
2024-07-26 18:24 ` Re* [PATCH v2 0/2] add-p P fixups Junio C Hamano
2024-07-26 19:22 ` Rubén Justo
2024-07-26 19:48 ` Junio C Hamano
2024-07-26 20:16 ` Rubén Justo
2024-07-28 9:11 ` Rubén Justo
2024-07-29 18:45 ` Junio C Hamano
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=xmqq8qxouhjv.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=phillip.wood@dunelm.org.uk \
--cc=rjusto@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).