@@ -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