author | Junio C Hamano <gitster@pobox.com> | |
Mon, 15 Nov 2010 19:02:14 +0000 (11:02 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 15 Nov 2010 19:02:14 +0000 (11:02 -0800) |
* cb/maint-orphan-merge-noclobber:
do not overwrite untracked during merge from unborn branch
Conflicts:
t/t7607-merge-overwrite.sh
do not overwrite untracked during merge from unborn branch
Conflicts:
t/t7607-merge-overwrite.sh
1 | 2 | |||
---|---|---|---|---|
builtin/merge.c | patch | | diff1 | | diff2 | | blob | history |
t/t7607-merge-overwrite.sh | patch | | diff1 | | diff2 | | blob | history |
diff --cc builtin/merge.c
Simple merge
diff --cc t/t7607-merge-overwrite.sh
index e49dd8023cf2b244a0831a80f559a016d786820c,8317a574ce2a56162094e817499fb188043ba8da..d4a499dee2ec3daabdba75eb6185778567204b0b
test_cmp important c1.c
'
+test_expect_success 'will not overwrite untracked subtree' '
+ git reset --hard c0 &&
+ rm -rf sub &&
+ mkdir -p sub/f &&
+ cp important sub/f/important &&
+ test_must_fail git merge sub &&
+ test_path_is_missing .git/MERGE_HEAD &&
+ test_cmp important sub/f/important
+'
+
+test_expect_success 'will not overwrite untracked file in leading path' '
+ git reset --hard c0 &&
+ rm -rf sub &&
+ cp important sub &&
+ test_must_fail git merge sub &&
+ test_path_is_missing .git/MERGE_HEAD &&
+ test_cmp important sub
+'
+
+test_expect_failure SYMLINKS 'will not overwrite untracked symlink in leading path' '
+ git reset --hard c0 &&
+ rm -rf sub &&
+ mkdir sub2 &&
+ ln -s sub2 sub &&
+ test_must_fail git merge sub &&
+ test_path_is_missing .git/MERGE_HEAD
+'
+
+test_expect_success SYMLINKS 'will not be confused by symlink in leading path' '
+ git reset --hard c0 &&
+ rm -rf sub &&
+ ln -s sub2 sub &&
+ git add sub &&
+ git commit -m ln &&
+ git checkout sub
+'
+
+ cat >expect <<\EOF
+ error: Untracked working tree file 'c0.c' would be overwritten by merge.
+ fatal: read-tree failed
+ EOF
+
+ test_expect_success 'will not overwrite untracked file on unborn branch' '
+ git reset --hard c0 &&
+ git rm -fr . &&
+ git checkout --orphan new &&
+ cp important c0.c &&
+ test_must_fail git merge c0 2>out &&
+ test_cmp out expect &&
+ test_path_is_missing .git/MERGE_HEAD &&
+ test_cmp important c0.c
+ '
+
test_done