Compare
3bbf43483e3954291b9fb4caa228eedb9dd528c2..b758bc5bc4b35db0bc807d3ab33cd492e86d6b4d
l10n: AGENTS.md: fix counter fallbacks
Reading a counter with "cmd || echo 0" breaks whenever the command
writes output but still exits non-zero. On zero matches, "grep -c"
prints 0 and exits with status 1, so the command substitution
captured two zeros and the arithmetic that follows failed with a
syntax error instead of evaluating to 0.
Fix by ignoring the exit status with "|| true" and defaulting the
empty value with "${VAR:-0}". Apply this to ENTRY_COUNT in both
l10n_one_batch() and review_one_batch(), and to the BATCH counter
read from po/review-batch.txt, which used the same fragile fallback.
Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
Jiang Xin <worldhello.net@gmail.com> · 2026-09-17 07:21 UTC
10 files changed,
+40
−311
- Documentation/RelNotes/2.56.0.adoc
- GIT-VERSION-GEN
- builtin/commit.c
- po/AGENTS.md
- sequencer.c
- sequencer.h
- t/t3404-rebase-interactive.sh
- t/t3507-cherry-pick-conflict.sh
- t/t4151-am-abort.sh
- wt-status.h
modified Documentation/RelNotes/2.56.0.adoc
| @@ -867,12 +867,6 @@ Fixes since v2.55 | |||
| 867 | 867 | Additionally, an obsolete variable used for retired Azure Pipelines | |
| 868 | 868 | environments has been removed. | |
| 869 | 869 | ||
| 870 | - | * Teach 'am', 'revert', and 'rebase' that running 'commit --amend' or a | |
| 871 | - | partial 'commit <paths>' makes no sense during operations that stop | |
| 872 | - | and return control to the user to resolve conflicts left in the | |
| 873 | - | working tree, just like 'cherry-pick' and 'merge' do. | |
| 874 | - | (merge cc499d40e5 en/no-amend-during-conflicts later to maint). | |
| 875 | - | ||
| 876 | 870 | * The error path in 'git submodule--helper' has been updated to plug a | |
| 877 | 871 | memory leak when a repository handle could not be obtained, | |
| 878 | 872 | leveraging an updated idempotent repo_clear(). | |
| @@ -888,7 +882,8 @@ Fixes since v2.55 | |||
| 888 | 882 | (merge ec602484bd kh/doc-datamodel later to maint). | |
| 889 | 883 | ||
| 890 | 884 | * Running "git history" in a corrupt repository can (unsurprisingly) | |
| 891 | - | segfault when a necessary tree object is not found. | |
| 885 | + | segfault when a necessary tree object is not found, which has been | |
| 886 | + | made to die more gracefully. | |
| 892 | 887 | (merge 76621488e8 jc/history-missing-tree-errorfix later to maint). | |
| 893 | 888 | ||
| 894 | 889 | * The development helper script to lint gitlink references in the | |
| @@ -906,6 +901,10 @@ Fixes since v2.55 | |||
| 906 | 901 | repo_logmsg_reencode() during the rewording operation in 'git | |
| 907 | 902 | history' has been plugged. | |
| 908 | 903 | ||
| 904 | + | * The pathspec matching logic has been updated to avoid out-of-bounds | |
| 905 | + | memory accesses when a negative pathspec is shorter than the common | |
| 906 | + | prefix of positive pathspecs. | |
| 907 | + | ||
| 909 | 908 | * Other code cleanup, docfix, build fix, etc. | |
| 910 | 909 | (merge 026636128f ss/submittingpatches-typofix later to maint). | |
| 911 | 910 | (merge d2af22cc21 jc/rerere-doc-typofix later to maint). | |
modified GIT-VERSION-GEN
| @@ -1,6 +1,6 @@ | |||
| 1 | 1 | #!/bin/sh | |
| 2 | 2 | ||
| 3 | - | DEF_VER=v2.56.0-rc1 | |
| 3 | + | DEF_VER=v2.56.0-rc2 | |
| 4 | 4 | ||
| 5 | 5 | LF=' | |
| 6 | 6 | ' | |
modified builtin/commit.c
| @@ -515,25 +515,13 @@ static const char *prepare_index(const char **argv, const char *prefix, | |||
| 515 | 515 | */ | |
| 516 | 516 | commit_style = COMMIT_PARTIAL; | |
| 517 | 517 | ||
| 518 | - | switch (sequencer_ongoing_operation(the_repository, whence)) { | |
| 519 | - | case ONGOING_NONE: | |
| 520 | - | break; | |
| 521 | - | case ONGOING_MERGE: | |
| 522 | - | die(_("cannot do a partial commit during a merge.")); | |
| 523 | - | case ONGOING_CHERRY_PICK: | |
| 524 | - | die(_("cannot do a partial commit during a cherry-pick.")); | |
| 525 | - | case ONGOING_REBASE_NOW_EMPTY: | |
| 526 | - | /* | |
| 527 | - | * A pick that became empty is not a conflict, and creating | |
| 528 | - | * a new commit (partial or not) poses no problem. | |
| 529 | - | */ | |
| 530 | - | break; | |
| 531 | - | case ONGOING_REVERT: | |
| 532 | - | die(_("cannot do a partial commit during a revert.")); | |
| 533 | - | case ONGOING_AM: | |
| 534 | - | die(_("cannot do a partial commit during an am session.")); | |
| 535 | - | case ONGOING_REBASE_CONFLICT: | |
| 536 | - | die(_("cannot do a partial commit while resolving conflicts during a rebase.")); | |
| 518 | + | if (whence != FROM_COMMIT) { | |
| 519 | + | if (whence == FROM_MERGE) | |
| 520 | + | die(_("cannot do a partial commit during a merge.")); | |
| 521 | + | else if (is_from_cherry_pick(whence)) | |
| 522 | + | die(_("cannot do a partial commit during a cherry-pick.")); | |
| 523 | + | else if (is_from_rebase(whence)) | |
| 524 | + | die(_("cannot do a partial commit during a rebase.")); | |
| 537 | 525 | } | |
| 538 | 526 | ||
| 539 | 527 | if (list_paths(&partial, !current_head ? NULL : "HEAD", &pathspec)) | |
| @@ -905,7 +893,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix, | |||
| 905 | 893 | */ | |
| 906 | 894 | else if (whence == FROM_MERGE) | |
| 907 | 895 | hook_arg1 = "merge"; | |
| 908 | - | else if (is_from_cherry_pick(whence) || is_from_rebase_now_empty(whence)) { | |
| 896 | + | else if (is_from_cherry_pick(whence) || whence == FROM_REBASE_PICK) { | |
| 909 | 897 | hook_arg1 = "commit"; | |
| 910 | 898 | hook_arg2 = "CHERRY_PICK_HEAD"; | |
| 911 | 899 | } | |
| @@ -1098,7 +1086,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix, | |||
| 1098 | 1086 | if (amend) | |
| 1099 | 1087 | fputs(_(empty_amend_advice), stderr); | |
| 1100 | 1088 | else if (is_from_cherry_pick(whence) || | |
| 1101 | - | is_from_rebase_now_empty(whence)) { | |
| 1089 | + | whence == FROM_REBASE_PICK) { | |
| 1102 | 1090 | fputs(_(empty_cherry_pick_advice), stderr); | |
| 1103 | 1091 | if (whence == FROM_CHERRY_PICK_SINGLE) | |
| 1104 | 1092 | fputs(_(empty_cherry_pick_advice_single), stderr); | |
| @@ -1338,30 +1326,15 @@ static int parse_and_validate_options(int argc, const char *argv[], | |||
| 1338 | 1326 | use_editor = 0; | |
| 1339 | 1327 | ||
| 1340 | 1328 | /* Sanity check options */ | |
| 1341 | - | if (amend) { | |
| 1342 | - | if (!current_head) | |
| 1343 | - | die(_("You have nothing to amend.")); | |
| 1344 | - | /* | |
| 1345 | - | * Refuse to amend in the middle of any operation that is | |
| 1346 | - | * meant to record its result as a new commit on top of HEAD | |
| 1347 | - | * rather than by rewriting HEAD. | |
| 1348 | - | */ | |
| 1349 | - | switch (sequencer_ongoing_operation(s->repo, whence)) { | |
| 1350 | - | case ONGOING_NONE: | |
| 1351 | - | break; | |
| 1352 | - | case ONGOING_MERGE: | |
| 1329 | + | if (amend && !current_head) | |
| 1330 | + | die(_("You have nothing to amend.")); | |
| 1331 | + | if (amend && whence != FROM_COMMIT) { | |
| 1332 | + | if (whence == FROM_MERGE) | |
| 1353 | 1333 | die(_("You are in the middle of a merge -- cannot amend.")); | |
| 1354 | - | case ONGOING_CHERRY_PICK: | |
| 1334 | + | else if (is_from_cherry_pick(whence)) | |
| 1355 | 1335 | die(_("You are in the middle of a cherry-pick -- cannot amend.")); | |
| 1356 | - | case ONGOING_REBASE_NOW_EMPTY: | |
| 1357 | - | die(_("The now-empty commit has been dropped -- cannot amend.")); | |
| 1358 | - | case ONGOING_REVERT: | |
| 1359 | - | die(_("You are in the middle of a revert -- cannot amend.")); | |
| 1360 | - | case ONGOING_AM: | |
| 1361 | - | die(_("You are in the middle of an am session -- cannot amend.")); | |
| 1362 | - | case ONGOING_REBASE_CONFLICT: | |
| 1363 | - | die(_("You are resolving conflicts during a rebase -- cannot amend.")); | |
| 1364 | - | } | |
| 1336 | + | else if (whence == FROM_REBASE_PICK) | |
| 1337 | + | die(_("You are in the middle of a rebase -- cannot amend.")); | |
| 1365 | 1338 | } | |
| 1366 | 1339 | if (fixup_message && squash_message) | |
| 1367 | 1340 | die(_("options '%s' and '%s' cannot be used together"), "--squash", "--fixup"); | |
| @@ -1380,7 +1353,7 @@ static int parse_and_validate_options(int argc, const char *argv[], | |||
| 1380 | 1353 | if (amend && !use_message && !fixup_message) | |
| 1381 | 1354 | use_message = "HEAD"; | |
| 1382 | 1355 | if (!use_message && !is_from_cherry_pick(whence) && | |
| 1383 | - | !is_from_rebase_now_empty(whence) && renew_authorship) | |
| 1356 | + | !is_from_rebase(whence) && renew_authorship) | |
| 1384 | 1357 | die(_("--reset-author can be used only with -C, -c or --amend.")); | |
| 1385 | 1358 | if (use_message) { | |
| 1386 | 1359 | use_message_buffer = read_commit_message(use_message); | |
| @@ -1389,7 +1362,7 @@ static int parse_and_validate_options(int argc, const char *argv[], | |||
| 1389 | 1362 | author_message_buffer = use_message_buffer; | |
| 1390 | 1363 | } | |
| 1391 | 1364 | } | |
| 1392 | - | if ((is_from_cherry_pick(whence) || is_from_rebase_now_empty(whence)) && | |
| 1365 | + | if ((is_from_cherry_pick(whence) || whence == FROM_REBASE_PICK) && | |
| 1393 | 1366 | !renew_authorship) { | |
| 1394 | 1367 | author_message = "CHERRY_PICK_HEAD"; | |
| 1395 | 1368 | author_message_buffer = read_commit_message(author_message); | |
| @@ -1914,7 +1887,7 @@ int cmd_commit(int argc, | |||
| 1914 | 1887 | if (!reflog_msg) | |
| 1915 | 1888 | reflog_msg = is_from_cherry_pick(whence) | |
| 1916 | 1889 | ? "commit (cherry-pick)" | |
| 1917 | - | : is_from_rebase_now_empty(whence) | |
| 1890 | + | : is_from_rebase(whence) | |
| 1918 | 1891 | ? "commit (rebase)" | |
| 1919 | 1892 | : "commit"; | |
| 1920 | 1893 | commit_list_insert(current_head, &parents); | |
modified po/AGENTS.md
| @@ -543,9 +543,9 @@ step 8 after step 6. | |||
| 543 | 543 | DONE_PO="po/l10n-done.po" | |
| 544 | 544 | rm -f "$TODO_JSON" "$TODO_PO" "$DONE_JSON" "$DONE_PO" | |
| 545 | 545 | ||
| 546 | - | ENTRY_COUNT=$(grep -c '^msgid ' "$PENDING" 2>/dev/null || echo 0) | |
| 546 | + | ENTRY_COUNT=$(grep -c '^msgid ' "$PENDING" 2>/dev/null || true) | |
| 547 | + | ENTRY_COUNT=${ENTRY_COUNT:-0} | |
| 547 | 548 | ENTRY_COUNT=$((ENTRY_COUNT > 0 ? ENTRY_COUNT - 1 : 0)) | |
| 548 | - | ||
| 549 | 549 | if test "$ENTRY_COUNT" -gt $min_batch_size | |
| 550 | 550 | then | |
| 551 | 551 | if test "$ENTRY_COUNT" -gt $((min_batch_size * 8)) | |
| @@ -772,7 +772,8 @@ already present. | |||
| 772 | 772 | cp "$INPUT_PO" "$PENDING" | |
| 773 | 773 | fi | |
| 774 | 774 | ||
| 775 | - | ENTRY_COUNT=$(grep -c '^msgid ' "$PENDING" 2>/dev/null || echo 0) | |
| 775 | + | ENTRY_COUNT=$(grep -c '^msgid ' "$PENDING" 2>/dev/null || true) | |
| 776 | + | ENTRY_COUNT=${ENTRY_COUNT:-0} | |
| 776 | 777 | ENTRY_COUNT=$((ENTRY_COUNT > 0 ? ENTRY_COUNT - 1 : 0)) | |
| 777 | 778 | if test "$ENTRY_COUNT" -eq 0 | |
| 778 | 779 | then | |
| @@ -796,7 +797,8 @@ already present. | |||
| 796 | 797 | NUM=$ENTRY_COUNT | |
| 797 | 798 | fi | |
| 798 | 799 | ||
| 799 | - | BATCH=$(cat "$BATCH_FILE" 2>/dev/null || echo 0) | |
| 800 | + | BATCH=$(cat "$BATCH_FILE" 2>/dev/null || true) | |
| 801 | + | BATCH=${BATCH:-0} | |
| 800 | 802 | BATCH=$((BATCH + 1)) | |
| 801 | 803 | echo "$BATCH" >"$BATCH_FILE" | |
| 802 | 804 | ||
modified sequencer.c
| @@ -143,13 +143,6 @@ static GIT_PATH_FUNC(rebase_path_author_script, "rebase-merge/author-script") | |||
| 143 | 143 | * command is processed, this file is deleted. | |
| 144 | 144 | */ | |
| 145 | 145 | static GIT_PATH_FUNC(rebase_path_amend, "rebase-merge/amend") | |
| 146 | - | /* | |
| 147 | - | * The apply ("am") backend keeps its state in the rebase-apply directory; | |
| 148 | - | * the "applying" file within it marks a plain `git am` (as opposed to an | |
| 149 | - | * apply-based rebase). | |
| 150 | - | */ | |
| 151 | - | static GIT_PATH_FUNC(apply_dir, "rebase-apply") | |
| 152 | - | static GIT_PATH_FUNC(apply_path_applying, "rebase-apply/applying") | |
| 153 | 146 | /* | |
| 154 | 147 | * When we stop at a given patch via the "edit" command, this file contains | |
| 155 | 148 | * the commit object name of the corresponding patch. | |
| @@ -6994,7 +6987,7 @@ int sequencer_determine_whence(struct repository *r, enum commit_whence *whence) | |||
| 6994 | 6987 | !repo_get_oid(r, "REBASE_HEAD", &rebase_head) && | |
| 6995 | 6988 | !repo_get_oid(r, "CHERRY_PICK_HEAD", &cherry_pick_head) && | |
| 6996 | 6989 | oideq(&rebase_head, &cherry_pick_head)) | |
| 6997 | - | *whence = FROM_REBASE_NOW_EMPTY; | |
| 6990 | + | *whence = FROM_REBASE_PICK; | |
| 6998 | 6991 | else | |
| 6999 | 6992 | *whence = FROM_CHERRY_PICK_SINGLE; | |
| 7000 | 6993 | ||
| @@ -7004,56 +6997,6 @@ int sequencer_determine_whence(struct repository *r, enum commit_whence *whence) | |||
| 7004 | 6997 | return 0; | |
| 7005 | 6998 | } | |
| 7006 | 6999 | ||
| 7007 | - | enum ongoing_operation sequencer_ongoing_operation(struct repository *r, | |
| 7008 | - | enum commit_whence whence) | |
| 7009 | - | { | |
| 7010 | - | /* | |
| 7011 | - | * The merge, cherry-pick, and (empty) rebase-pick stops are already | |
| 7012 | - | * distinguished by 'whence'. | |
| 7013 | - | */ | |
| 7014 | - | switch (whence) { | |
| 7015 | - | case FROM_MERGE: | |
| 7016 | - | return ONGOING_MERGE; | |
| 7017 | - | case FROM_CHERRY_PICK_SINGLE: | |
| 7018 | - | case FROM_CHERRY_PICK_MULTI: | |
| 7019 | - | return ONGOING_CHERRY_PICK; | |
| 7020 | - | case FROM_REBASE_NOW_EMPTY: | |
| 7021 | - | return ONGOING_REBASE_NOW_EMPTY; | |
| 7022 | - | case FROM_COMMIT: | |
| 7023 | - | break; | |
| 7024 | - | } | |
| 7025 | - | ||
| 7026 | - | /* | |
| 7027 | - | * 'whence' is FROM_COMMIT, but we may still be in the middle of an | |
| 7028 | - | * operation that records its result on top of HEAD; detect those | |
| 7029 | - | * from their on-disk state. | |
| 7030 | - | */ | |
| 7031 | - | ||
| 7032 | - | /* In the middle of a revert? */ | |
| 7033 | - | if (refs_ref_exists(get_main_ref_store(r), "REVERT_HEAD")) | |
| 7034 | - | return ONGOING_REVERT; | |
| 7035 | - | ||
| 7036 | - | /* In the middle of an `am`? */ | |
| 7037 | - | if (file_exists(apply_path_applying())) | |
| 7038 | - | return ONGOING_AM; | |
| 7039 | - | ||
| 7040 | - | /* | |
| 7041 | - | * In the middle of a rebase that stopped for conflict resolution? | |
| 7042 | - | * The apply backend only ever stops for conflicts, so the presence | |
| 7043 | - | * of its state directory is enough. The merge backend writes | |
| 7044 | - | * stopped-sha whenever it hands control back to the user, but omits | |
| 7045 | - | * `amend` unless it stopped with HEAD already pointing at the commit | |
| 7046 | - | * to be amended (a clean edit/reword stop); its absence therefore | |
| 7047 | - | * marks a conflicted stop. | |
| 7048 | - | */ | |
| 7049 | - | if (file_exists(apply_dir()) || | |
| 7050 | - | (file_exists(rebase_path_stopped_sha()) && | |
| 7051 | - | !file_exists(rebase_path_amend()))) | |
| 7052 | - | return ONGOING_REBASE_CONFLICT; | |
| 7053 | - | ||
| 7054 | - | return ONGOING_NONE; | |
| 7055 | - | } | |
| 7056 | - | ||
| 7057 | 7000 | int sequencer_get_update_refs_state(const char *wt_dir, | |
| 7058 | 7001 | struct string_list *refs) | |
| 7059 | 7002 | { | |
modified sequencer.h
| @@ -282,30 +282,6 @@ int sequencer_get_last_command(struct repository* r, | |||
| 282 | 282 | enum replay_action *action); | |
| 283 | 283 | int sequencer_determine_whence(struct repository *r, enum commit_whence *whence); | |
| 284 | 284 | ||
| 285 | - | /* | |
| 286 | - | * An in-progress operation that records its result (often a conflict | |
| 287 | - | * resolution) as a new commit on top of HEAD. Some ways of invoking | |
| 288 | - | * "git commit" -- amending HEAD, or a partial commit -- are almost | |
| 289 | - | * always a mistake during such an operation. | |
| 290 | - | */ | |
| 291 | - | enum ongoing_operation { | |
| 292 | - | ONGOING_NONE = 0, | |
| 293 | - | ONGOING_MERGE, | |
| 294 | - | ONGOING_CHERRY_PICK, | |
| 295 | - | ONGOING_REBASE_NOW_EMPTY, | |
| 296 | - | ONGOING_REVERT, | |
| 297 | - | ONGOING_AM, | |
| 298 | - | ONGOING_REBASE_CONFLICT | |
| 299 | - | }; | |
| 300 | - | ||
| 301 | - | /* | |
| 302 | - | * Return which in-progress operation, if any, is underway; see enum | |
| 303 | - | * ongoing_operation. 'whence' is the origin already computed for the | |
| 304 | - | * pending commit. | |
| 305 | - | */ | |
| 306 | - | enum ongoing_operation sequencer_ongoing_operation(struct repository *r, | |
| 307 | - | enum commit_whence whence); | |
| 308 | - | ||
| 309 | 285 | /** | |
| 310 | 286 | * Append the set of ref-OID pairs that are currently stored for the 'git | |
| 311 | 287 | * rebase --update-refs' feature if such a rebase is currently happening. | |
modified t/t3404-rebase-interactive.sh
| @@ -1858,7 +1858,7 @@ test_expect_success 'post-commit hook is called' ' | |||
| 1858 | 1858 | test_cmp expect actual | |
| 1859 | 1859 | ' | |
| 1860 | 1860 | ||
| 1861 | - | test_expect_success 'partial commit is allowed when a rebase pick becomes empty' ' | |
| 1861 | + | test_expect_success 'correct error message for partial commit after empty pick' ' | |
| 1862 | 1862 | test_when_finished "git rebase --abort" && | |
| 1863 | 1863 | ( | |
| 1864 | 1864 | set_fake_editor && | |
| @@ -1867,7 +1867,8 @@ test_expect_success 'partial commit is allowed when a rebase pick becomes empty' | |||
| 1867 | 1867 | test_must_fail git rebase -i A D | |
| 1868 | 1868 | ) && | |
| 1869 | 1869 | echo x >file1 && | |
| 1870 | - | git commit file1 | |
| 1870 | + | test_must_fail git commit file1 2>err && | |
| 1871 | + | test_grep "cannot do a partial commit during a rebase." err | |
| 1871 | 1872 | ' | |
| 1872 | 1873 | ||
| 1873 | 1874 | test_expect_success 'correct error message for commit --amend after empty pick' ' | |
| @@ -1880,128 +1881,7 @@ test_expect_success 'correct error message for commit --amend after empty pick' | |||
| 1880 | 1881 | ) && | |
| 1881 | 1882 | echo x>file1 && | |
| 1882 | 1883 | test_must_fail git commit -a --amend 2>err && | |
| 1883 | - | test_grep "now-empty commit has been dropped -- cannot amend." err | |
| 1884 | - | ' | |
| 1885 | - | ||
| 1886 | - | test_expect_success 'commit --amend is refused at a rebase conflict stop' ' | |
| 1887 | - | test_when_finished "git rebase --abort" && | |
| 1888 | - | git checkout --detach conflict-branch && | |
| 1889 | - | ( | |
| 1890 | - | set_fake_editor && | |
| 1891 | - | FAKE_LINES="1 3" && | |
| 1892 | - | export FAKE_LINES && | |
| 1893 | - | test_must_fail git rebase -i A | |
| 1894 | - | ) && | |
| 1895 | - | test_path_is_file .git/rebase-merge/patch && | |
| 1896 | - | test_path_is_missing .git/rebase-merge/amend && | |
| 1897 | - | echo resolved >conflict && | |
| 1898 | - | git add conflict && | |
| 1899 | - | test_must_fail git commit --amend --no-edit 2>err && | |
| 1900 | - | test_grep "You are resolving conflicts during a rebase -- cannot amend" err | |
| 1901 | - | ' | |
| 1902 | - | ||
| 1903 | - | test_expect_success 'commit --amend is refused when an "edit" pick conflicts' ' | |
| 1904 | - | test_when_finished "git rebase --abort" && | |
| 1905 | - | git checkout --detach conflict-branch && | |
| 1906 | - | ( | |
| 1907 | - | set_fake_editor && | |
| 1908 | - | FAKE_LINES="1 edit 3" && | |
| 1909 | - | export FAKE_LINES && | |
| 1910 | - | test_must_fail git rebase -i A | |
| 1911 | - | ) && | |
| 1912 | - | test_path_is_file .git/rebase-merge/patch && | |
| 1913 | - | test_path_is_missing .git/rebase-merge/amend && | |
| 1914 | - | echo resolved >conflict && | |
| 1915 | - | git add conflict && | |
| 1916 | - | test_must_fail git commit --amend --no-edit 2>err && | |
| 1917 | - | test_grep "You are resolving conflicts during a rebase -- cannot amend" err | |
| 1918 | - | ' | |
| 1919 | - | ||
| 1920 | - | test_expect_success 'commit --amend is allowed at a rebase edit stop' ' | |
| 1921 | - | test_when_finished "git rebase --abort" && | |
| 1922 | - | git checkout --detach no-conflict-branch && | |
| 1923 | - | ( | |
| 1924 | - | set_fake_editor && | |
| 1925 | - | FAKE_LINES="edit 1 2 3 4" && | |
| 1926 | - | export FAKE_LINES && | |
| 1927 | - | git rebase -i A | |
| 1928 | - | ) && | |
| 1929 | - | test_path_is_file .git/rebase-merge/amend && | |
| 1930 | - | echo tweak >fileJ && | |
| 1931 | - | git add fileJ && | |
| 1932 | - | git commit --amend --no-edit | |
| 1933 | - | ' | |
| 1934 | - | ||
| 1935 | - | test_expect_success 'commit --amend is allowed at a rebase break stop' ' | |
| 1936 | - | test_when_finished "git rebase --abort" && | |
| 1937 | - | git checkout --detach no-conflict-branch && | |
| 1938 | - | ( | |
| 1939 | - | set_fake_editor && | |
| 1940 | - | FAKE_LINES="break 1 2 3 4" && | |
| 1941 | - | export FAKE_LINES && | |
| 1942 | - | git rebase -i A | |
| 1943 | - | ) && | |
| 1944 | - | test_must_fail git rev-parse --verify REBASE_HEAD && | |
| 1945 | - | echo tweak >fileJ && | |
| 1946 | - | git add fileJ && | |
| 1947 | - | git commit --amend --no-edit | |
| 1948 | - | ' | |
| 1949 | - | ||
| 1950 | - | test_expect_success 'commit --amend is refused at an apply-backend conflict stop' ' | |
| 1951 | - | test_when_finished "rm -rf apply-backend" && | |
| 1952 | - | test_create_repo apply-backend && | |
| 1953 | - | ( | |
| 1954 | - | cd apply-backend && | |
| 1955 | - | test_commit base file && | |
| 1956 | - | git branch -M mainline && | |
| 1957 | - | test_commit upstream file upstream && | |
| 1958 | - | git checkout -b side mainline~1 && | |
| 1959 | - | test_commit conflicting file side && | |
| 1960 | - | test_commit unrelated other && | |
| 1961 | - | test_must_fail git rebase --apply mainline && | |
| 1962 | - | # the apply backend only ever stops for conflicts, and | |
| 1963 | - | # leaves HEAD on the previously-applied commit | |
| 1964 | - | test_path_is_dir .git/rebase-apply && | |
| 1965 | - | test_path_is_missing .git/rebase-apply/applying && | |
| 1966 | - | echo resolved >file && | |
| 1967 | - | git add file && | |
| 1968 | - | test_must_fail git commit --amend --no-edit 2>err && | |
| 1969 | - | test_grep "You are resolving conflicts during a rebase -- cannot amend" err | |
| 1970 | - | ) | |
| 1971 | - | ' | |
| 1972 | - | ||
| 1973 | - | test_expect_success 'partial commit is refused at a rebase conflict stop' ' | |
| 1974 | - | test_when_finished "git rebase --abort" && | |
| 1975 | - | git checkout --detach conflict-branch && | |
| 1976 | - | ( | |
| 1977 | - | set_fake_editor && | |
| 1978 | - | FAKE_LINES="1 3" && | |
| 1979 | - | export FAKE_LINES && | |
| 1980 | - | test_must_fail git rebase -i A | |
| 1981 | - | ) && | |
| 1982 | - | echo resolved >conflict && | |
| 1983 | - | git add conflict && | |
| 1984 | - | test_must_fail git commit conflict 2>err && | |
| 1985 | - | test_grep "cannot do a partial commit while resolving conflicts during a rebase." err | |
| 1986 | - | ' | |
| 1987 | - | ||
| 1988 | - | test_expect_success 'partial commit is refused at an apply-backend conflict stop' ' | |
| 1989 | - | test_when_finished "rm -rf apply-backend" && | |
| 1990 | - | test_create_repo apply-backend && | |
| 1991 | - | ( | |
| 1992 | - | cd apply-backend && | |
| 1993 | - | test_commit base file && | |
| 1994 | - | git branch -M mainline && | |
| 1995 | - | test_commit upstream file upstream && | |
| 1996 | - | git checkout -b side mainline~1 && | |
| 1997 | - | test_commit conflicting file side && | |
| 1998 | - | test_commit unrelated other && | |
| 1999 | - | test_must_fail git rebase --apply mainline && | |
| 2000 | - | echo resolved >file && | |
| 2001 | - | git add file && | |
| 2002 | - | test_must_fail git commit file 2>err && | |
| 2003 | - | test_grep "cannot do a partial commit while resolving conflicts during a rebase." err | |
| 2004 | - | ) | |
| 1884 | + | test_grep "middle of a rebase -- cannot amend." err | |
| 2005 | 1885 | ' | |
| 2006 | 1886 | ||
| 2007 | 1887 | test_expect_success 'todo has correct onto hash' ' | |
modified t/t3507-cherry-pick-conflict.sh
| @@ -365,28 +365,6 @@ test_expect_success 'failed revert sets REVERT_HEAD' ' | |||
| 365 | 365 | test_cmp_rev picked REVERT_HEAD | |
| 366 | 366 | ' | |
| 367 | 367 | ||
| 368 | - | test_expect_success 'commit --amend of revert fails' ' | |
| 369 | - | pristine_detach initial && | |
| 370 | - | ||
| 371 | - | test_must_fail git revert picked && | |
| 372 | - | echo resolved >foo && | |
| 373 | - | git add foo && | |
| 374 | - | test_must_fail git commit --amend 2>err && | |
| 375 | - | ||
| 376 | - | test_grep "in the middle of a revert -- cannot amend." err | |
| 377 | - | ' | |
| 378 | - | ||
| 379 | - | test_expect_success 'partial commit during a revert fails' ' | |
| 380 | - | pristine_detach initial && | |
| 381 | - | ||
| 382 | - | test_must_fail git revert picked && | |
| 383 | - | echo resolved >foo && | |
| 384 | - | git add foo && | |
| 385 | - | test_must_fail git commit foo 2>err && | |
| 386 | - | ||
| 387 | - | test_grep "cannot do a partial commit during a revert." err | |
| 388 | - | ' | |
| 389 | - | ||
| 390 | 368 | test_expect_success 'successful revert does not set REVERT_HEAD' ' | |
| 391 | 369 | pristine_detach base && | |
| 392 | 370 | git revert base && | |
modified t/t4151-am-abort.sh
| @@ -63,28 +63,6 @@ do | |||
| 63 | 63 | ||
| 64 | 64 | done | |
| 65 | 65 | ||
| 66 | - | test_expect_success 'commit --amend during a failed am fails' ' | |
| 67 | - | git reset --hard initial && | |
| 68 | - | cp file-2-expect file-2 && | |
| 69 | - | test_must_fail git am 000[1245]-*.patch && | |
| 70 | - | echo resolved >file-1 && | |
| 71 | - | git add file-1 && | |
| 72 | - | test_must_fail git commit --amend 2>err && | |
| 73 | - | test_grep "in the middle of an am session -- cannot amend." err && | |
| 74 | - | git am --abort | |
| 75 | - | ' | |
| 76 | - | ||
| 77 | - | test_expect_success 'partial commit during a failed am fails' ' | |
| 78 | - | git reset --hard initial && | |
| 79 | - | cp file-2-expect file-2 && | |
| 80 | - | test_must_fail git am 000[1245]-*.patch && | |
| 81 | - | echo resolved >file-1 && | |
| 82 | - | git add file-1 && | |
| 83 | - | test_must_fail git commit file-1 2>err && | |
| 84 | - | test_grep "cannot do a partial commit during an am session." err && | |
| 85 | - | git am --abort | |
| 86 | - | ' | |
| 87 | - | ||
| 88 | 66 | test_expect_success 'am -3 --skip removes otherfile-4' ' | |
| 89 | 67 | git reset --hard initial && | |
| 90 | 68 | test_must_fail git am -3 0003-*.patch && | |
modified wt-status.h
| @@ -41,7 +41,7 @@ enum commit_whence { | |||
| 41 | 41 | FROM_MERGE, /* commit came from merge */ | |
| 42 | 42 | FROM_CHERRY_PICK_SINGLE, /* commit came from cherry-pick */ | |
| 43 | 43 | FROM_CHERRY_PICK_MULTI, /* commit came from a sequence of cherry-picks */ | |
| 44 | - | FROM_REBASE_NOW_EMPTY /* rebase applied a pick that became empty */ | |
| 44 | + | FROM_REBASE_PICK /* commit came from a pick/reword/edit */ | |
| 45 | 45 | }; | |
| 46 | 46 | ||
| 47 | 47 | static inline int is_from_cherry_pick(enum commit_whence whence) | |
| @@ -50,9 +50,9 @@ static inline int is_from_cherry_pick(enum commit_whence whence) | |||
| 50 | 50 | whence == FROM_CHERRY_PICK_MULTI; | |
| 51 | 51 | } | |
| 52 | 52 | ||
| 53 | - | static inline int is_from_rebase_now_empty(enum commit_whence whence) | |
| 53 | + | static inline int is_from_rebase(enum commit_whence whence) | |
| 54 | 54 | { | |
| 55 | - | return whence == FROM_REBASE_NOW_EMPTY; | |
| 55 | + | return whence == FROM_REBASE_PICK; | |
| 56 | 56 | } | |
| 57 | 57 | ||
| 58 | 58 | struct wt_status_change_data { | |