Merge branch 'en/am-abort-fix' into en/removing-untracked-fixes
* en/am-abort-fix: am: fix incorrect exit status on am fail to abort t4151: add a few am --abort tests git-am.txt: clarify --abort behavior
This commit is contained in:
@ -178,6 +178,8 @@ default. You can use `--no-utf8` to override this.
|
|||||||
|
|
||||||
--abort::
|
--abort::
|
||||||
Restore the original branch and abort the patching operation.
|
Restore the original branch and abort the patching operation.
|
||||||
|
Revert contents of files involved in the am operation to their
|
||||||
|
pre-am state.
|
||||||
|
|
||||||
--quit::
|
--quit::
|
||||||
Abort the patching operation but keep HEAD and the index
|
Abort the patching operation but keep HEAD and the index
|
||||||
|
@ -2106,7 +2106,8 @@ static void am_abort(struct am_state *state)
|
|||||||
if (!has_orig_head)
|
if (!has_orig_head)
|
||||||
oidcpy(&orig_head, the_hash_algo->empty_tree);
|
oidcpy(&orig_head, the_hash_algo->empty_tree);
|
||||||
|
|
||||||
clean_index(&curr_head, &orig_head);
|
if (clean_index(&curr_head, &orig_head))
|
||||||
|
die(_("failed to clean index"));
|
||||||
|
|
||||||
if (has_orig_head)
|
if (has_orig_head)
|
||||||
update_ref("am --abort", "HEAD", &orig_head,
|
update_ref("am --abort", "HEAD", &orig_head,
|
||||||
|
@ -23,7 +23,13 @@ test_expect_success setup '
|
|||||||
test_tick &&
|
test_tick &&
|
||||||
git commit -a -m $i || return 1
|
git commit -a -m $i || return 1
|
||||||
done &&
|
done &&
|
||||||
|
git branch changes &&
|
||||||
git format-patch --no-numbered initial &&
|
git format-patch --no-numbered initial &&
|
||||||
|
git checkout -b conflicting initial &&
|
||||||
|
echo different >>file-1 &&
|
||||||
|
echo whatever >new-file &&
|
||||||
|
git add file-1 new-file &&
|
||||||
|
git commit -m different &&
|
||||||
git checkout -b side initial &&
|
git checkout -b side initial &&
|
||||||
echo local change >file-2-expect
|
echo local change >file-2-expect
|
||||||
'
|
'
|
||||||
@ -191,4 +197,37 @@ test_expect_success 'am --abort leaves index stat info alone' '
|
|||||||
git diff-files --exit-code --quiet
|
git diff-files --exit-code --quiet
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'git am --abort return failed exit status when it fails' '
|
||||||
|
test_when_finished "rm -rf file-2/ && git reset --hard && git am --abort" &&
|
||||||
|
git checkout changes &&
|
||||||
|
git format-patch -1 --stdout conflicting >changes.mbox &&
|
||||||
|
test_must_fail git am --3way changes.mbox &&
|
||||||
|
|
||||||
|
git rm file-2 &&
|
||||||
|
mkdir file-2 &&
|
||||||
|
echo precious >file-2/somefile &&
|
||||||
|
test_must_fail git am --abort &&
|
||||||
|
test_path_is_dir file-2/
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'git am --abort cleans relevant files' '
|
||||||
|
git checkout changes &&
|
||||||
|
git format-patch -1 --stdout conflicting >changes.mbox &&
|
||||||
|
test_must_fail git am --3way changes.mbox &&
|
||||||
|
|
||||||
|
test_path_is_file new-file &&
|
||||||
|
echo further changes >>file-1 &&
|
||||||
|
echo change other file >>file-2 &&
|
||||||
|
|
||||||
|
# Abort, and expect the files touched by am to be reverted
|
||||||
|
git am --abort &&
|
||||||
|
|
||||||
|
test_path_is_missing new-file &&
|
||||||
|
|
||||||
|
# Files not involved in am operation are left modified
|
||||||
|
git diff --name-only changes >actual &&
|
||||||
|
test_write_lines file-2 >expect &&
|
||||||
|
test_cmp expect actual
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
Reference in New Issue
Block a user