add test to show explicitly that merge doesn't overwrite untracked files
or unstaged even when they have the same content than files int the
merged commit
Signed-off-by: Jonathan Bressat <redacted>
Signed-off-by: COGONI Guillaume <redacted>
---
t/t6436-merge-overwrite.sh | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/t/t6436-merge-overwrite.sh b/t/t6436-merge-overwrite.sh
index c0b7bd7c3f..bb323b1ee3 100755
--- a/t/t6436-merge-overwrite.sh
+++ b/t/t6436-merge-overwrite.sh
@@ -204,4 +204,38 @@ test_expect_success 'will not clobber WT/index when merging into unborn' '
grep bar untracked-file
'
+test_expect_success 'create branch A' '
+ git reset --hard c0 &&
+ git checkout -b A
+'
+
+test_expect_success 'fastforward will not overwrite untracked file with the same content' '
+ test_when_finished "git branch -D B && git reset --hard c0 && git clean --force" &&
+ git checkout -b B &&
+ test_commit --no-tag "tracked" file "content" &&
+ git checkout A &&
+ echo content >file &&
+ test_must_fail git merge B
+'
+
+test_expect_success 'will not overwrite untracked file with the same content' '
+ test_when_finished "git branch -D B && git reset --hard c0 && git clean --force" &&
+ git checkout -b B &&
+ test_commit --no-tag "tracked" file "content" fileB "content" &&
+ git checkout A &&
+ test_commit --no-tag "exA" fileA "content" &&
+ echo content >file &&
+ test_must_fail git merge B
+'
+
+test_expect_success 'will not overwrite unstaged file with the same content' '
+ test_when_finished "git branch -D B && git reset --hard c0 && git clean --force" &&
+ test_commit --no-tag "unstaged" file "other" &&
+ git checkout -b B &&
+ test_commit --no-tag "staged" file "content" &&
+ git checkout A &&
+ echo content >file &&
+ test_must_fail git merge B
+'
+
test_done
--
2.35.1.10.g88248585b1.dirty