summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorLibravatar Christian Couder <chriscool@tuxfamily.org>2010-01-19 05:26:01 +0100
committerLibravatar Junio C Hamano <gitster@pobox.com>2010-03-06 20:06:50 -0800
commit812d2a3d61b1bbb1931aff2ed6d2a17e939f5bf2 (patch)
tree8a4b55f654c0b5f9fe4a4ebfd226e79b949df17d /t
parentreset: disallow "reset --keep" outside a work tree (diff)
downloadtgif-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')
-rwxr-xr-xt/t7110-reset-merge.sh23
-rwxr-xr-xt/t7111-reset-table.sh2
2 files changed, 10 insertions, 15 deletions
diff --git a/t/t7110-reset-merge.sh b/t/t7110-reset-merge.sh
index 1a9c1c7494..70cdd8e618 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
diff --git a/t/t7111-reset-table.sh b/t/t7111-reset-table.sh
index 2ebda97828..ce421ad5ac 100755
--- a/t/t7111-reset-table.sh
+++ b/t/t7111-reset-table.sh
@@ -115,7 +115,7 @@ X U B B soft XXXXX
X U B B mixed X B B
X U B B hard B B B
X U B B merge B B B
-X U B B keep X B B
+X U B B keep XXXXX
EOF
test_done