summaryrefslogtreecommitdiff
path: root/t/t6436-merge-overwrite.sh
diff options
context:
space:
mode:
Diffstat (limited to 't/t6436-merge-overwrite.sh')
-rwxr-xr-xt/t6436-merge-overwrite.sh30
1 files changed, 21 insertions, 9 deletions
diff --git a/t/t6436-merge-overwrite.sh b/t/t6436-merge-overwrite.sh
index dd8ab7e..4f43764 100755
--- a/t/t6436-merge-overwrite.sh
+++ b/t/t6436-merge-overwrite.sh
@@ -4,6 +4,9 @@ test_description='git-merge
Do not overwrite changes.'
+GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
+
. ./test-lib.sh
test_expect_success 'setup' '
@@ -65,7 +68,8 @@ test_expect_success 'will not overwrite removed file' '
git commit -m "rm c1.c" &&
cp important c1.c &&
test_must_fail git merge c1a &&
- test_cmp important c1.c
+ test_cmp important c1.c &&
+ rm c1.c # Do not leave untracked file in way of future tests
'
test_expect_success 'will not overwrite re-added file' '
@@ -97,11 +101,19 @@ test_expect_success 'will not overwrite unstaged changes in renamed file' '
git mv c1.c other.c &&
git commit -m rename &&
cp important other.c &&
- test_must_fail git merge c1a >out &&
- test_i18ngrep "Refusing to lose dirty file at other.c" out &&
- test_path_is_file other.c~HEAD &&
- test $(git hash-object other.c~HEAD) = $(git rev-parse c1a:c1.c) &&
- test_cmp important other.c
+ if test "$GIT_TEST_MERGE_ALGORITHM" = ort
+ then
+ test_must_fail git merge c1a >out 2>err &&
+ test_grep "would be overwritten by merge" err &&
+ test_cmp important other.c &&
+ test_path_is_missing .git/MERGE_HEAD
+ else
+ test_must_fail git merge c1a >out &&
+ test_grep "Refusing to lose dirty file at other.c" out &&
+ test_path_is_file other.c~HEAD &&
+ test $(git hash-object other.c~HEAD) = $(git rev-parse c1a:c1.c) &&
+ test_cmp important other.c
+ fi
'
test_expect_success 'will not overwrite untracked subtree' '
@@ -128,7 +140,7 @@ test_expect_success 'will not overwrite untracked file in leading path' '
cp important sub &&
cp important sub2 &&
test_must_fail git merge sub 2>out &&
- test_i18ncmp out expect &&
+ test_cmp out expect &&
test_path_is_missing .git/MERGE_HEAD &&
test_cmp important sub &&
test_cmp important sub2 &&
@@ -163,7 +175,7 @@ test_expect_success 'will not overwrite untracked file on unborn branch' '
git checkout --orphan new &&
cp important c0.c &&
test_must_fail git merge c0 2>out &&
- test_i18ncmp out expect
+ test_cmp out expect
'
test_expect_success 'will not overwrite untracked file on unborn branch .git/MERGE_HEAD sanity etc.' '
@@ -185,7 +197,7 @@ test_expect_success 'set up unborn branch and content' '
'
test_expect_success 'will not clobber WT/index when merging into unborn' '
- git merge master &&
+ git merge main &&
grep foo tracked-file &&
git show :tracked-file >expect &&
grep foo expect &&