diff options
author | Christian Couder <chriscool@tuxfamily.org> | 2010-01-19 05:26:01 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2010-03-06 20:06:50 -0800 |
commit | 812d2a3d61b1bbb1931aff2ed6d2a17e939f5bf2 (patch) | |
tree | 8a4b55f654c0b5f9fe4a4ebfd226e79b949df17d /t/t7110-reset-merge.sh | |
parent | ab892a19e83edd1cf9a767bc09d3239f72469d05 (diff) | |
download | git-812d2a3d61b1bbb1931aff2ed6d2a17e939f5bf2.tar.gz git-812d2a3d61b1bbb1931aff2ed6d2a17e939f5bf2.tar.xz |
reset: disallow using --keep when there are unmerged entries
The use case for --keep option is to remove previous commits unrelated
to the current changes in the working tree. So in this use case we are
not supposed to have unmerged entries. This is why it seems safer to
just disallow using --keep when there are unmerged entries.
And this patch changes the error message when --keep was disallowed and
there were some unmerged entries from:
error: Entry 'file1' would be overwritten by merge. Cannot merge.
fatal: Could not reset index file to revision 'HEAD^'.
to:
fatal: Cannot do a keep reset in the middle of a merge.
which is nicer.
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t7110-reset-merge.sh')
-rwxr-xr-x | t/t7110-reset-merge.sh | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/t/t7110-reset-merge.sh b/t/t7110-reset-merge.sh index 1a9c1c749..70cdd8e61 100755 --- a/t/t7110-reset-merge.sh +++ b/t/t7110-reset-merge.sh @@ -237,7 +237,7 @@ test_expect_success '"reset --keep HEAD^" fails with pending merge' ' git reset --hard third && test_must_fail git merge branch1 && test_must_fail git reset --keep HEAD^ 2>err.log && - grep file1 err.log | grep "overwritten by merge" + grep "middle of a merge" err.log ' # The next test will test the following: @@ -258,18 +258,15 @@ test_expect_success '"reset --merge HEAD" is ok with pending merge' ' # # working index HEAD target working index HEAD # ---------------------------------------------------- -# file1: X U B B --keep X B B -test_expect_success '"reset --keep HEAD" is ok with pending merge' ' +# file1: X U B B --keep (disallowed) +test_expect_success '"reset --keep HEAD" fails with pending merge' ' git reset --hard third && test_must_fail git merge branch1 && - cat file1 >orig_file1 && - git reset --keep HEAD && - test "$(git rev-parse HEAD)" = "$(git rev-parse third)" && - test -z "$(git diff --cached)" && - test_cmp file1 orig_file1 + test_must_fail git reset --keep HEAD 2>err.log && + grep "middle of a merge" err.log ' -test_expect_success '--merge with added/deleted' ' +test_expect_success '--merge is ok with added/deleted merge' ' git reset --hard third && rm -f file2 && test_must_fail git merge branch3 && @@ -283,7 +280,7 @@ test_expect_success '--merge with added/deleted' ' git diff --exit-code --cached ' -test_expect_success '--keep with added/deleted' ' +test_expect_success '--keep fails with added/deleted merge' ' git reset --hard third && rm -f file2 && test_must_fail git merge branch3 && @@ -291,10 +288,8 @@ test_expect_success '--keep with added/deleted' ' test -f file3 && git diff --exit-code file3 && git diff --exit-code branch3 file3 && - git reset --keep HEAD && - test -f file3 && - ! test -f file2 && - git diff --exit-code --cached + test_must_fail git reset --keep HEAD 2>err.log && + grep "middle of a merge" err.log ' test_done |