git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "René Scharfe" <l.s.r@web.de>
To: Git List <git@vger.kernel.org>
Subject: [PATCH 1/2] add-patch: quit without skipping undecided hunks
Date: Sat, 25 Oct 2025 07:46:42 +0200	[thread overview]
Message-ID: <0985f775-fb01-4de0-99a8-4775b602829a@web.de> (raw)

Option q implies d, i.e., it marks any undecided hunks towards the
bottom of the hunk array as skipped.  This is unnecessary; later code
treats undecided and skipped hunks the same: The only functions that
use UNDECIDED_HUNK and SKIP_HUNK are patch_update_file() itself (but
not after its big for loop) and its helpers get_first_undecided() and
display_hunks().

Streamline the handling of option q by quitting immediately.

Signed-off-by: René Scharfe <l.s.r@web.de>
---
 add-patch.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/add-patch.c b/add-patch.c
index ae9a20d8f2..a70def1f81 100644
--- a/add-patch.c
+++ b/add-patch.c
@@ -1601,7 +1601,7 @@ static int patch_update_file(struct add_p_state *s,
 			} else if (hunk->use == UNDECIDED_HUNK) {
 				hunk->use = USE_HUNK;
 			}
-		} else if (ch == 'd' || ch == 'q') {
+		} else if (ch == 'd') {
 			if (file_diff->hunk_nr) {
 				for (; hunk_index < file_diff->hunk_nr; hunk_index++) {
 					hunk = file_diff->hunk + hunk_index;
@@ -1613,10 +1613,9 @@ static int patch_update_file(struct add_p_state *s,
 			} else if (hunk->use == UNDECIDED_HUNK) {
 				hunk->use = SKIP_HUNK;
 			}
-			if (ch == 'q') {
-				quit = 1;
-				break;
-			}
+		} else if (ch == 'q') {
+			quit = 1;
+			break;
 		} else if (s->answer.buf[0] == 'K') {
 			if (permitted & ALLOW_GOTO_PREVIOUS_HUNK)
 				hunk_index = dec_mod(hunk_index,
-- 
2.51.1

             reply	other threads:[~2025-10-25  5:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-25  5:46 René Scharfe [this message]
2025-10-25  5:48 ` [PATCH 2/2] add-patch: quit on EOF René Scharfe
2025-10-25 16:20   ` Junio C Hamano
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=0985f775-fb01-4de0-99a8-4775b602829a@web.de \
    --to=l.s.r@web.de \
    --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 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).