summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2015-11-05 20:18:11 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-11-05 20:18:11 (GMT)
commit5e6154fb145d66af36e10ef4db7e1d1e9502c501 (patch)
tree98e62ba6a698d6a4ed266b98e9a95bc5fe1b1c1a /t
parentc378862b1ec23dd526e318b4c1bfbf826f8dd6b6 (diff)
parent72fac66bca302dbecbe42dfa0ddc7e42db2fe567 (diff)
downloadgit-5e6154fb145d66af36e10ef4db7e1d1e9502c501.zip
git-5e6154fb145d66af36e10ef4db7e1d1e9502c501.tar.gz
git-5e6154fb145d66af36e10ef4db7e1d1e9502c501.tar.bz2
Merge branch 'jk/delete-modechange-conflict' into maint
Merging a branch that removes a path and another that changes the mode bits on the same path should have conflicted at the path, but it didn't and silently favoured the removal. * jk/delete-modechange-conflict: merge: detect delete/modechange conflict t6031: generalize for recursive and resolve strategies t6031: move triple-rename test to t3030
Diffstat (limited to 't')
-rwxr-xr-xt/t3030-merge-recursive.sh30
-rwxr-xr-xt/t6031-merge-filemode.sh100
-rwxr-xr-xt/t6031-merge-recursive.sh87
3 files changed, 130 insertions, 87 deletions
diff --git a/t/t3030-merge-recursive.sh b/t/t3030-merge-recursive.sh
index 82e1854..6224187 100755
--- a/t/t3030-merge-recursive.sh
+++ b/t/t3030-merge-recursive.sh
@@ -629,5 +629,35 @@ test_expect_failure 'merge-recursive rename vs. rename/symlink' '
test_cmp expected actual
'
+test_expect_success 'merging with triple rename across D/F conflict' '
+ git reset --hard HEAD &&
+ git checkout -b main &&
+ git rm -rf . &&
+
+ echo "just a file" >sub1 &&
+ mkdir -p sub2 &&
+ echo content1 >sub2/file1 &&
+ echo content2 >sub2/file2 &&
+ echo content3 >sub2/file3 &&
+ mkdir simple &&
+ echo base >simple/bar &&
+ git add -A &&
+ test_tick &&
+ git commit -m base &&
+
+ git checkout -b other &&
+ echo more >>simple/bar &&
+ test_tick &&
+ git commit -a -m changesimplefile &&
+
+ git checkout main &&
+ git rm sub1 &&
+ git mv sub2 sub1 &&
+ test_tick &&
+ git commit -m changefiletodir &&
+
+ test_tick &&
+ git merge other
+'
test_done
diff --git a/t/t6031-merge-filemode.sh b/t/t6031-merge-filemode.sh
new file mode 100755
index 0000000..7d06461
--- /dev/null
+++ b/t/t6031-merge-filemode.sh
@@ -0,0 +1,100 @@
+#!/bin/sh
+
+test_description='merge: handle file mode'
+. ./test-lib.sh
+
+test_expect_success 'set up mode change in one branch' '
+ : >file1 &&
+ git add file1 &&
+ git commit -m initial &&
+ git checkout -b a1 master &&
+ : >dummy &&
+ git add dummy &&
+ git commit -m a &&
+ git checkout -b b1 master &&
+ test_chmod +x file1 &&
+ git add file1 &&
+ git commit -m b1
+'
+
+do_one_mode () {
+ strategy=$1
+ us=$2
+ them=$3
+ test_expect_success "resolve single mode change ($strategy, $us)" '
+ git checkout -f $us &&
+ git merge -s $strategy $them &&
+ git ls-files -s file1 | grep ^100755
+ '
+
+ test_expect_success FILEMODE "verify executable bit on file ($strategy, $us)" '
+ test -x file1
+ '
+}
+
+do_one_mode recursive a1 b1
+do_one_mode recursive b1 a1
+do_one_mode resolve a1 b1
+do_one_mode resolve b1 a1
+
+test_expect_success 'set up mode change in both branches' '
+ git reset --hard HEAD &&
+ git checkout -b a2 master &&
+ : >file2 &&
+ H=$(git hash-object file2) &&
+ test_chmod +x file2 &&
+ git commit -m a2 &&
+ git checkout -b b2 master &&
+ : >file2 &&
+ git add file2 &&
+ git commit -m b2 &&
+ {
+ echo "100755 $H 2 file2"
+ echo "100644 $H 3 file2"
+ } >expect
+'
+
+do_both_modes () {
+ strategy=$1
+ test_expect_success "detect conflict on double mode change ($strategy)" '
+ git reset --hard &&
+ git checkout -f a2 &&
+ test_must_fail git merge -s $strategy b2 &&
+ git ls-files -u >actual &&
+ test_cmp actual expect &&
+ git ls-files -s file2 | grep ^100755
+ '
+
+ test_expect_success FILEMODE "verify executable bit on file ($strategy)" '
+ test -x file2
+ '
+}
+
+# both sides are equivalent, so no need to run both ways
+do_both_modes recursive
+do_both_modes resolve
+
+test_expect_success 'set up delete/modechange scenario' '
+ git reset --hard &&
+ git checkout -b deletion master &&
+ git rm file1 &&
+ git commit -m deletion
+'
+
+do_delete_modechange () {
+ strategy=$1
+ us=$2
+ them=$3
+ test_expect_success "detect delete/modechange conflict ($strategy, $us)" '
+ git reset --hard &&
+ git checkout $us &&
+ test_must_fail git merge -s $strategy $them
+ '
+}
+
+do_delete_modechange recursive b1 deletion
+do_delete_modechange recursive deletion b1
+do_delete_modechange resolve b1 deletion
+do_delete_modechange resolve deletion b1
+
+test_done
diff --git a/t/t6031-merge-recursive.sh b/t/t6031-merge-recursive.sh
deleted file mode 100755
index 6464a16..0000000
--- a/t/t6031-merge-recursive.sh
+++ /dev/null
@@ -1,87 +0,0 @@
-#!/bin/sh
-
-test_description='merge-recursive: handle file mode'
-. ./test-lib.sh
-
-test_expect_success 'mode change in one branch: keep changed version' '
- : >file1 &&
- git add file1 &&
- git commit -m initial &&
- git checkout -b a1 master &&
- : >dummy &&
- git add dummy &&
- git commit -m a &&
- git checkout -b b1 master &&
- test_chmod +x file1 &&
- git add file1 &&
- git commit -m b1 &&
- git checkout a1 &&
- git merge-recursive master -- a1 b1 &&
- git ls-files -s file1 | grep ^100755
-'
-
-test_expect_success FILEMODE 'verify executable bit on file' '
- test -x file1
-'
-
-test_expect_success 'mode change in both branches: expect conflict' '
- git reset --hard HEAD &&
- git checkout -b a2 master &&
- : >file2 &&
- H=$(git hash-object file2) &&
- test_chmod +x file2 &&
- git commit -m a2 &&
- git checkout -b b2 master &&
- : >file2 &&
- git add file2 &&
- git commit -m b2 &&
- git checkout a2 &&
- (
- git merge-recursive master -- a2 b2
- test $? = 1
- ) &&
- git ls-files -u >actual &&
- (
- echo "100755 $H 2 file2"
- echo "100644 $H 3 file2"
- ) >expect &&
- test_cmp actual expect &&
- git ls-files -s file2 | grep ^100755
-'
-
-test_expect_success FILEMODE 'verify executable bit on file' '
- test -x file2
-'
-
-test_expect_success 'merging with triple rename across D/F conflict' '
- git reset --hard HEAD &&
- git checkout -b main &&
- git rm -rf . &&
-
- echo "just a file" >sub1 &&
- mkdir -p sub2 &&
- echo content1 >sub2/file1 &&
- echo content2 >sub2/file2 &&
- echo content3 >sub2/file3 &&
- mkdir simple &&
- echo base >simple/bar &&
- git add -A &&
- test_tick &&
- git commit -m base &&
-
- git checkout -b other &&
- echo more >>simple/bar &&
- test_tick &&
- git commit -a -m changesimplefile &&
-
- git checkout main &&
- git rm sub1 &&
- git mv sub2 sub1 &&
- test_tick &&
- git commit -m changefiletodir &&
-
- test_tick &&
- git merge other
-'
-
-test_done