summaryrefslogtreecommitdiff
path: root/t/t6044-merge-unrelated-index-changes.sh
diff options
context:
space:
mode:
authorLibravatar Elijah Newren <newren@gmail.com>2018-06-30 18:25:01 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2018-07-11 09:38:36 -0700
commit7f5271fa1584d99fb3c83f308f35295ed78c8b8b (patch)
treedc14c7771369f587d6e0c20f47f925840f25b49f /t/t6044-merge-unrelated-index-changes.sh
parentmerge-recursive: fix assumption that head tree being merged is HEAD (diff)
downloadtgif-7f5271fa1584d99fb3c83f308f35295ed78c8b8b.tar.xz
t6044: add more testcases with staged changes before a merge is invoked
According to Documentation/git-merge.txt, ...[merge will] abort if there are any changes registered in the index relative to the `HEAD` commit. (One exception is when the changed index entries are in the state that would result from the merge already.) Add some tests showing that this exception, while it does accurately state what would be a safe condition under which we could allow the merge to proceed, is not what is actually implemented. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t6044-merge-unrelated-index-changes.sh')
-rwxr-xr-xt/t6044-merge-unrelated-index-changes.sh29
1 files changed, 29 insertions, 0 deletions
diff --git a/t/t6044-merge-unrelated-index-changes.sh b/t/t6044-merge-unrelated-index-changes.sh
index ef8a502baf..9601255890 100755
--- a/t/t6044-merge-unrelated-index-changes.sh
+++ b/t/t6044-merge-unrelated-index-changes.sh
@@ -137,6 +137,35 @@ test_expect_success 'merge-recursive, when index==head but head!=HEAD' '
test_i18ngrep "Already up to date" out
'
+test_expect_failure 'recursive, when file has staged changes not matching HEAD nor what a merge would give' '
+ git reset --hard &&
+ git checkout B^0 &&
+
+ mkdir subdir &&
+ test_seq 1 10 >subdir/a &&
+ git add subdir/a &&
+
+ # HEAD has no subdir/a; merge would write 1..11 to subdir/a;
+ # Since subdir/a matches neither HEAD nor what the merge would write
+ # to that file, the merge should fail to avoid overwriting what is
+ # currently found in subdir/a
+ test_must_fail git merge -s recursive E^0
+'
+
+test_expect_failure 'recursive, when file has staged changes matching what a merge would give' '
+ git reset --hard &&
+ git checkout B^0 &&
+
+ mkdir subdir &&
+ test_seq 1 11 >subdir/a &&
+ git add subdir/a &&
+
+ # HEAD has no subdir/a; merge would write 1..11 to subdir/a;
+ # Since subdir/a matches what the merge would write to that file,
+ # the merge should be safe to proceed
+ git merge -s recursive E^0
+'
+
test_expect_success 'octopus, unrelated file touched' '
git reset --hard &&
git checkout B^0 &&