[PATCH v4 0/2] improve interactive-patch
- From
Rubén Justo <rjusto@gmail.com>
- Date
- Mar 29, 2024, 03:56 UTC
- Message-ID
- <a9c515fe-6664-4b5d-abca-d88fdd32a883@gmail.com>
- In-Reply-To
- <60d978d0-f69a-4b65-b4ba-d30dac8f112a@gmail.com>
Let's reduce the verbosity in the interactive-patch process, in order to make it less confusing.
Rubén Justo (2): add-patch: introduce 'p' in interactive-patch add-patch: do not print hunks repeatedly
Documentation/git-add.txt | 1 + add-patch.c | 23 +++++++++++++++++------ t/t3701-add-interactive.sh | 22 +++++++++++----------- 3 files changed, 29 insertions(+), 17 deletions(-)
Range-diff against v3:
1: 545ca3f0b3 ! 1: 338f1ebc9e add-patch: introduce 'p' in interactive-patch
@@ Documentation/git-add.txt: patch::
K - leave this hunk undecided, see previous hunk
s - split the current hunk into smaller hunks
e - manually edit the current hunk
-+ p - print the current hunk again
++ p - print the current hunk
? - print help
+
After deciding the fate for all hunks, if there is any hunk
@@ add-patch.c: N_("j - leave this hunk undecided, see next undecided hunk\n"
"/ - search for a hunk matching the given regex\n"
"s - split the current hunk into smaller hunks\n"
"e - manually edit the current hunk\n"
-+ "p - print the current hunk again\n"
++ "p - print the current hunk\n"
"? - print help\n");
static int patch_update_file(struct add_p_state *s,
2: b6b98e5dbb ! 2: e17b8d70f1 add-patch: do not print hunks repeatedly
@@ add-patch.c: static int patch_update_file(struct add_p_state *s,
permitted |= ALLOW_GOTO_PREVIOUS_UNDECIDED_HUNK;
strbuf_addstr(&s->buf, ",k");
@@ add-patch.c: static int patch_update_file(struct add_p_state *s,
- if (!(permitted & ALLOW_SPLIT))
+ hunk_index = i;
+ } else if (s->answer.buf[0] == 's') {
+ size_t splittable_into = hunk->splittable_into;
+- if (!(permitted & ALLOW_SPLIT))
++ if (!(permitted & ALLOW_SPLIT)) {
err(s, _("Sorry, cannot split this hunk"));
- else if (!split_hunk(s, file_diff,
+- else if (!split_hunk(s, file_diff,
- hunk - file_diff->hunk))
++ } else if (!split_hunk(s, file_diff,
+ hunk - file_diff->hunk)) {
color_fprintf_ln(stdout, s->s.header_color,
_("Split into %d hunks."),-- 2.44.0.370.ge17b8d70f1