add-patch: roll over to next undecided hunk
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v3 Latest6 patches 5 repliesIn review
- v25 patches 9 repliesSuperseded
- v11 patch 8 repliesSuperseded
Changes since v1 from the cover letter
- added patch 5 for a and d
- made error messages direction-neutral
- removed stray "only" from commit message of patch 2
Patches in v3 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/6 | add-patch: improve help for options j, J, k, and KDocumentation/ add-patch.c | +8 | 0 replies | |
| 2/6 | add-patch: document that option J rolls overDocumentation/ add-patch.c t/ | +18 | 0 replies | |
| 3/6 | add-patch: let options y, n, j, and e roll over to next undecidedDocumentation/ add-patch.c t/ | +33 | 0 replies | |
| 4/6 | add-patch: let options k and K roll over like j and JDocumentation/ add-patch.c t/ | +37 | 0 replies | |
| 5/6 | add-patch: let options a and d roll over like y and nadd-patch.c t/ | +21 | 0 replies | |
| 6/6 | add-patch: reset "permitted" at loop startadd-patch.c t/ | +24 | 2 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.
Cover letter [PATCH v3 0/6] add-patch: roll over to next undecided hunk
Changes since v1:
- added patch 5 for a and d
- made error messages direction-neutral
- removed stray "only" from commit message of patch 2
add-patch: improve help for options j, J, k, and K
add-patch: document that option J rolls over
add-patch: let options y, n, j, and e roll over to next undecided
add-patch: let options k and K roll over like j and J
add-patch: let options a and d roll over like y and n
add-patch: reset "permitted" at loop start
Documentation/git-add.adoc | 8 ++-- add-patch.c | 75 ++++++++++++++++++++++++++----------- t/t3701-add-interactive.sh | 76 ++++++++++++++++++++++++++++++-------- 3 files changed, 118 insertions(+), 41 deletions(-)
Interdiff against v2:
add-patch.c +19 -4
@@ -1418,6 +1418,17 @@ static size_t inc_mod(size_t a, size_t m)return a < m -1 ? a +1 :0 ; } +static bool get_first_undecided (const struct file_diff *file_diff,size_t *idx) +{ +for (size_t i =0 ; i < file_diff->hunk_nr; i++) { +if (file_diff->hunk[i].use ==UNDECIDED_HUNK ) { + *idx = i; +return true; + } + } +return false; +} +static int patch_update_file (struct add_p_state *s,struct file_diff *file_diff) {
@@ -1573,6 +1584,8 @@ static int patch_update_file(struct add_p_state *s,if (hunk->use ==UNDECIDED_HUNK ) hunk->use =USE_HUNK ; } +if (!get_first_undecided (file_diff, &hunk_index)) + hunk_index =0 ; }else if (hunk->use ==UNDECIDED_HUNK ) { hunk->use =USE_HUNK ; }
@@ -1583,6 +1596,8 @@ static int patch_update_file(struct add_p_state *s,if (hunk->use ==UNDECIDED_HUNK ) hunk->use =SKIP_HUNK ; } +if (!get_first_undecided (file_diff, &hunk_index)) + hunk_index =0 ; }else if (hunk->use ==UNDECIDED_HUNK ) { hunk->use =SKIP_HUNK ; }
@@ -1595,22 +1610,22 @@ static int patch_update_file(struct add_p_state *s, hunk_index =dec_mod (hunk_index, file_diff->hunk_nr); else - err(s, _("No previous hunk")); + err(s, _("No other hunk")); }else if (s->answer.buf[0 ] =='J' ) {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;else -err (s,_ ("No previous hunk" )); +err (s,_ ("No other undecided hunk" )); }else if (s->answer.buf[0 ] =='j' ) {if (permitted &ALLOW_GOTO_NEXT_UNDECIDED_HUNK ) hunk_index = undecided_next;else -err (s,_ ("No next hunk" )); +err (s,_ ("No other undecided hunk" )); }else if (s->answer.buf[0 ] =='g' ) {char *pend;unsigned long response;
t/t3701-add-interactive.sh +6 -6
@@ -1364,24 +1364,24 @@ test_expect_success 'options J, K roll over' ' test_cmp expect actual ' -test_expect_success 'options y, n, j, k, e roll over to next undecided (1)' ' +test_expect_success 'options y, n, a, d, j, k, e roll over to next undecided (1)' ' test_write_lines a b c d e f g h i j k l m n o p q >file && git add file && test_write_lines X b c d e f g h X j k l m n o p X >file && test_set_editor : && - test_write_lines g3 y g3 n g3 j g3 e k q | git add -p >out && - test_write_lines 1 3 1 3 1 3 1 3 1 2 >expect && + test_write_lines g3 y g3 n g3 a g3 d g3 j g3 e k q | git add -p >out && + test_write_lines 1 3 1 3 1 3 1 3 1 3 1 3 1 2 >expect && sed -n -e "s-/.*--" -e "s/^(//p" <out >actual && test_cmp expect actual ' -test_expect_success 'options y, n, j, k, e roll over to next undecided (2)' ' +test_expect_success 'options y, n, a, d, j, k, e roll over to next undecided (2)' ' test_write_lines a b c d e f g h i j k l m n o p q >file && git add file && test_write_lines X b c d e f g h X j k l m n o p X >file && test_set_editor : && - test_write_lines y g3 y g3 n g3 j g3 e g1 k q | git add -p >out && - test_write_lines 1 2 3 2 3 2 3 2 3 2 1 2 >expect && + test_write_lines y g3 y g3 n g3 a g3 d g3 j g3 e g1 k q | git add -p >out && + test_write_lines 1 2 3 2 3 2 3 2 3 2 3 2 3 2 1 2 >expect && sed -n -e "s-/.*--" -e "s/^(//p" <out >actual && test_cmp expect actual '
Signature · 1 line
2.51.0