summaryrefslogtreecommitdiff
path: root/add-patch.c
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2025-10-06 19:20:31 +0200
committerJunio C Hamano <gitster@pobox.com>2025-10-06 10:51:42 -0700
commitc309b65a7c8a0dc8a1566ac3587d37d935632e4d (patch)
tree0a0bdaa6d684dc019c44498dc24e18842d918557 /add-patch.c
parent2c3cc43f96f9568d5475e46bd1442c5551129ce8 (diff)
add-patch: document that option J rolls over
The variable "permitted" is not reset after moving to a different hunk, so it only accumulates permission and doesn't necessarily reflect those of the current hunk. This may be a bug, but is actually useful with the option J, which can be used at the last hunk to roll over to the first hunk. Make this particular behavior official. Also adjust the error message, as it will only be shown if there's just a single hunk. Suggested-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'add-patch.c')
-rw-r--r--add-patch.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/add-patch.c b/add-patch.c
index 912266a3f8..1f466ec9c0 100644
--- a/add-patch.c
+++ b/add-patch.c
@@ -1398,7 +1398,7 @@ static size_t display_hunks(struct add_p_state *s,
static const char help_patch_remainder[] =
N_("j - go to the next undecided hunk\n"
- "J - go to the next hunk\n"
+ "J - go to the next hunk, roll over at the bottom\n"
"k - go to the previous undecided hunk\n"
"K - go to the previous hunk\n"
"g - select a hunk to go to\n"
@@ -1493,7 +1493,7 @@ static int patch_update_file(struct add_p_state *s,
permitted |= ALLOW_GOTO_NEXT_UNDECIDED_HUNK;
strbuf_addstr(&s->buf, ",j");
}
- if (hunk_index + 1 < file_diff->hunk_nr) {
+ if (file_diff->hunk_nr > 1) {
permitted |= ALLOW_GOTO_NEXT_HUNK;
strbuf_addstr(&s->buf, ",J");
}
@@ -1584,7 +1584,7 @@ soft_increment:
if (permitted & ALLOW_GOTO_NEXT_HUNK)
hunk_index++;
else
- err(s, _("No next hunk"));
+ err(s, _("No other hunk"));
} else if (s->answer.buf[0] == 'k') {
if (permitted & ALLOW_GOTO_PREVIOUS_UNDECIDED_HUNK)
hunk_index = undecided_previous;