From: Junio C Hamano <gitster@pobox.com>
To: "René Scharfe" <l.s.r@web.de>
Cc: Git List <git@vger.kernel.org>
Subject: Re: [PATCH 2/2] add-patch: quit on EOF
Date: Sat, 25 Oct 2025 09:20:10 -0700 [thread overview]
Message-ID: <xmqqfrb7nebp.fsf@gitster.g> (raw)
In-Reply-To: <13529bee-1e02-4c20-9461-6569312bfe4f@web.de> ("René Scharfe"'s message of "Sat, 25 Oct 2025 07:48:28 +0200")
René Scharfe <l.s.r@web.de> writes:
> If we reach the end of the input, e.g. because the user pressed ctrl-D
> on Linux, there is no point in showing any more prompts, as we won't get
> any reply. Do the same as option 'q' would: Quit.
>
> Signed-off-by: René Scharfe <l.s.r@web.de>
> ---
> add-patch.c | 4 +++-
> t/t3701-add-interactive.sh | 11 +++++++++++
> 2 files changed, 14 insertions(+), 1 deletion(-)
The code breaks out of the loop (either with or without setting the
'quit' flag), after which there is "which hunks are going to be
used?" check, followed by "apply the selected hunks". So the new
ctrl-D behaviour does not change the end-result left in the files.
The effect of the hunks chosen for application will not be abandoned.
If you are one of those unfortunate folks living dangeously with
interactive.singlekey set to true, your ctrl-D would have given you
Unknown command '' (use '?' for help)
in the code before this change, so, this would give them strict
improvement.
The current code happens to *work* for those without the single key
setting, in the sense that when we move to subsequent files, the
first call to read_single_character() in patfch_update_file() for
them immediately return EOF, breaking out of the loop before any
hunks for the file gets marked for application, so we'll iterate
through the remaining files without doing anything to these files.
But we do show the first hunk of all of them before quitting. And
this patch squelches these useless output.
OK. This makes sense and makes the change in this patch worthwhile.
I wonder if we want to 'echo" something in this case, though. If I
say 'q', whether interactive.singlekey is active or not, I see
(1/1) Stage this hunk [y,n,q,a,d,s,e,p,P,?]? q
on the last line before getting the shell prompt back. With this
change, I won't see anything after the prompt. Perhaps it is OK? I
dunno. Perhaps we want to pretend as if 'q' were given instead of
EOF, like the following? I dunno.
Will queue as-is.
Thanks.
add-patch.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git c/add-patch.c w/add-patch.c
index cd71a0359a..f201ead08e 100644
--- c/add-patch.c
+++ w/add-patch.c
@@ -1558,8 +1558,8 @@ static int patch_update_file(struct add_p_state *s,
fputs(s->s.reset_color_interactive, stdout);
fflush(stdout);
if (read_single_character(s) == EOF) {
- quit = 1;
- break;
+ puts("q");
+ strbuf_addch(&s->answer, 'q');
}
if (!s->answer.len)
next prev parent reply other threads:[~2025-10-25 16:20 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-25 5:46 [PATCH 1/2] add-patch: quit without skipping undecided hunks René Scharfe
2025-10-25 5:48 ` [PATCH 2/2] add-patch: quit on EOF René Scharfe
2025-10-25 16:20 ` Junio C Hamano [this message]
2025-10-25 17:23 ` René Scharfe
2025-10-26 0:37 ` Junio C Hamano
2025-10-26 0:46 ` Junio C Hamano
2025-10-26 16:11 ` René Scharfe
2025-10-25 15:42 ` [PATCH 1/2] add-patch: quit without skipping undecided hunks 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=xmqqfrb7nebp.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=l.s.r@web.de \
/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).