Merge branch 'jt/commit-graph-per-object-store'
[gitweb.git] / t / t6044-merge-unrelated-index-changes.sh
index f9c2f8179e000d91a0565f9233874d1aaad576fe..5e3779ebc9310bfb25d0c6579f234ecf4fabd12e 100755 (executable)
@@ -116,7 +116,7 @@ test_expect_success 'recursive' '
        test_path_is_missing .git/MERGE_HEAD
 '
 
-test_expect_failure 'recursive, when merge branch matches merge base' '
+test_expect_success 'recursive, when merge branch matches merge base' '
        git reset --hard &&
        git checkout B^0 &&
 
@@ -126,6 +126,43 @@ test_expect_failure 'recursive, when merge branch matches merge base' '
        test_path_is_missing .git/MERGE_HEAD
 '
 
+test_expect_success 'merge-recursive, when index==head but head!=HEAD' '
+       git reset --hard &&
+       git checkout C^0 &&
+
+       # Make index match B
+       git diff C B -- | git apply --cached &&
+       # Merge B & F, with B as "head"
+       git merge-recursive A -- B F > out &&
+       test_i18ngrep "Already up to date" out
+'
+
+test_expect_success '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 &&
+
+       # We have staged changes; merge should error out
+       test_must_fail git merge -s recursive E^0 2>err &&
+       test_i18ngrep "changes to the following files would be overwritten" err
+'
+
+test_expect_success '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 &&
+
+       # We have staged changes; merge should error out
+       test_must_fail git merge -s recursive E^0 2>err &&
+       test_i18ngrep "changes to the following files would be overwritten" err
+'
+
 test_expect_success 'octopus, unrelated file touched' '
        git reset --hard &&
        git checkout B^0 &&