]> asedeno.scripts.mit.edu Git - git.git/blobdiff - t/t3412-rebase-root.sh
tests: Avoid single-shot environment export for shell function invocation
[git.git] / t / t3412-rebase-root.sh
index 6359580262e9a171e46c60749b1827324e6535f9..3d8ff674c0c153473d5b3cc35ca60e90d7d0be2b 100755 (executable)
@@ -172,16 +172,126 @@ EOF
 
 test_expect_success 'pre-rebase hook stops rebase' '
        git checkout -b stops1 other &&
-       GIT_EDITOR=: test_must_fail git rebase --root --onto master &&
+       (
+               GIT_EDITOR=:
+               export GIT_EDITOR
+               test_must_fail git rebase --root --onto master
+       ) &&
        test "z$(git symbolic-ref HEAD)" = zrefs/heads/stops1
        test 0 = $(git rev-list other...stops1 | wc -l)
 '
 
 test_expect_success 'pre-rebase hook stops rebase -i' '
        git checkout -b stops2 other &&
-       GIT_EDITOR=: test_must_fail git rebase --root --onto master &&
+       (
+               GIT_EDITOR=:
+               export GIT_EDITOR
+               test_must_fail git rebase --root --onto master
+       ) &&
        test "z$(git symbolic-ref HEAD)" = zrefs/heads/stops2
        test 0 = $(git rev-list other...stops2 | wc -l)
 '
 
+test_expect_success 'remove pre-rebase hook' '
+       rm -f .git/hooks/pre-rebase
+'
+
+test_expect_success 'set up a conflict' '
+       git checkout master &&
+       echo conflict > B &&
+       git add B &&
+       git commit -m conflict
+'
+
+test_expect_success 'rebase --root with conflict (first part)' '
+       git checkout -b conflict1 other &&
+       test_must_fail git rebase --root --onto master &&
+       git ls-files -u | grep "B$"
+'
+
+test_expect_success 'fix the conflict' '
+       echo 3 > B &&
+       git add B
+'
+
+cat > expect-conflict <<EOF
+6
+5
+4
+3
+conflict
+2
+1
+EOF
+
+test_expect_success 'rebase --root with conflict (second part)' '
+       git rebase --continue &&
+       git log --pretty=tformat:"%s" > conflict1 &&
+       test_cmp expect-conflict conflict1
+'
+
+test_expect_success 'rebase -i --root with conflict (first part)' '
+       git checkout -b conflict2 other &&
+       (
+               GIT_EDITOR=:
+               export GIT_EDITOR
+               test_must_fail git rebase -i --root --onto master
+       ) &&
+       git ls-files -u | grep "B$"
+'
+
+test_expect_success 'fix the conflict' '
+       echo 3 > B &&
+       git add B
+'
+
+test_expect_success 'rebase -i --root with conflict (second part)' '
+       git rebase --continue &&
+       git log --pretty=tformat:"%s" > conflict2 &&
+       test_cmp expect-conflict conflict2
+'
+
+cat >expect-conflict-p <<\EOF
+commit conflict3 conflict3~1 conflict3^2
+Merge branch 'third' into other
+commit conflict3^2 conflict3~4
+6
+commit conflict3~1 conflict3~2 conflict3~1^2
+Merge branch 'side' into other
+commit conflict3~1^2 conflict3~3
+5
+commit conflict3~2 conflict3~3
+4
+commit conflict3~3 conflict3~4
+3
+commit conflict3~4 conflict3~5
+conflict
+commit conflict3~5 conflict3~6
+2
+commit conflict3~6
+1
+EOF
+
+test_expect_success 'rebase -i -p --root with conflict (first part)' '
+       git checkout -b conflict3 other &&
+       (
+               GIT_EDITOR=:
+               export GIT_EDITOR
+               test_must_fail git rebase -i -p --root --onto master
+       ) &&
+       git ls-files -u | grep "B$"
+'
+
+test_expect_success 'fix the conflict' '
+       echo 3 > B &&
+       git add B
+'
+
+test_expect_success 'rebase -i -p --root with conflict (second part)' '
+       git rebase --continue &&
+       git rev-list --topo-order --parents --pretty="tformat:%s" HEAD |
+       git name-rev --stdin --name-only --refs=refs/heads/conflict3 >out &&
+       test_cmp expect-conflict-p out
+'
+
 test_done