Subject: Re: [PATCH 2/2] add-patch: quit on EOF

From: Junio C Hamano <[email-masked]>
Date: Sat, 25 Oct 2025 17:37:26 -0700

René Scharfe <[email-masked]> writes:

> On 10/25/25 6:20 PM, Junio C Hamano wrote:
>> 
>> 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.
> I'm used to no feedback when writing to a file using cat and finishing
> with ctrl-D to signal end-of-file.  So I don't need a q "echoed", and
> would actually be slightly surprised.  But that's just me.

I do not have a strong preference either way myself. It just looked
a bit abrupt the way the session transcript ends, when it gets shut
down with ctrl-D, but after all it is a shutdown, so it may be more
natural that way ;-).

I am kind of surprised that this EOF behaviour has not been brought
up until now, and your patch did not have to touch expected output
of existing tests (certainly they are taking prepackaged series of
commands but I would not imagine all the previous test authors are
careful enough to end their tests with 'q').  Perhaps we do not have
enough multi-hunk and/or multi-file tests on "git add -p" and when
the tests react to EOF they were already at the "final" hunk of the
"final" file and nobody noticed the unnecessary output to skip all
the remaining hunks and files, perhaps.