X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=t%2Ft3412-rebase-root.sh;h=5869061c5bfdee4a84b156b8ec9d6e331a2c906c;hb=7e7db5e4520388d3a6f1efbe2f7a29d43bd06a2b;hp=ef6f7a54ae23bc58198363b20019a58c54b021fc;hpb=a6c7a27691bd8b059d39c9bc71b19fb8e614fa54;p=git.git diff --git a/t/t3412-rebase-root.sh b/t/t3412-rebase-root.sh index ef6f7a54a..5869061c5 100755 --- a/t/t3412-rebase-root.sh +++ b/t/t3412-rebase-root.sh @@ -6,24 +6,20 @@ Tests if git rebase --root --onto can rebase the root commit. ' . ./test-lib.sh +log_with_names () { + git rev-list --topo-order --parents --pretty="tformat:%s" HEAD | + git name-rev --stdin --name-only --refs=refs/heads/$1 +} + + test_expect_success 'prepare repository' ' - echo 1 > A && - git add A && - git commit -m 1 && - echo 2 > A && - git add A && - git commit -m 2 && + test_commit 1 A && + test_commit 2 A && git symbolic-ref HEAD refs/heads/other && rm .git/index && - echo 3 > B && - git add B && - git commit -m 3 && - echo 1 > A && - git add A && - git commit -m 1b && - echo 4 > B && - git add B && - git commit -m 4 + test_commit 3 B && + test_commit 1b A 1 && + test_commit 4 B ' test_expect_success 'rebase --root expects --onto' ' @@ -69,7 +65,7 @@ test_expect_success 'pre-rebase got correct input (2)' ' test_expect_success 'rebase -i --root --onto ' ' git checkout -b work3 other && - GIT_EDITOR=: git rebase -i --root --onto master && + git rebase -i --root --onto master && git log --pretty=tformat:"%s" > rebased3 && test_cmp expect rebased3 ' @@ -80,7 +76,7 @@ test_expect_success 'pre-rebase got correct input (3)' ' test_expect_success 'rebase -i --root --onto ' ' git branch work4 other && - GIT_EDITOR=: git rebase -i --root --onto master work4 && + git rebase -i --root --onto master work4 && git log --pretty=tformat:"%s" > rebased4 && test_cmp expect rebased4 ' @@ -91,7 +87,7 @@ test_expect_success 'pre-rebase got correct input (4)' ' test_expect_success 'rebase -i -p with linear history' ' git checkout -b work5 other && - GIT_EDITOR=: git rebase -i -p --root --onto master && + git rebase -i -p --root --onto master && git log --pretty=tformat:"%s" > rebased5 && test_cmp expect rebased5 ' @@ -103,28 +99,30 @@ test_expect_success 'pre-rebase got correct input (5)' ' test_expect_success 'set up merge history' ' git checkout other^ && git checkout -b side && - echo 5 > C && - git add C && - git commit -m 5 && + test_commit 5 C && git checkout other && git merge side ' -sed 's/#/ /g' > expect-side <<'EOF' -* Merge branch 'side' into other -|\## -| * 5 -* | 4 -|/## -* 3 -* 2 -* 1 +cat > expect-side <<'EOF' +commit work6 work6~1 work6^2 +Merge branch 'side' into other +commit work6^2 work6~2 +5 +commit work6~1 work6~2 +4 +commit work6~2 work6~3 +3 +commit work6~3 work6~4 +2 +commit work6~4 +1 EOF test_expect_success 'rebase -i -p with merge' ' git checkout -b work6 other && - GIT_EDITOR=: git rebase -i -p --root --onto master && - git log --graph --topo-order --pretty=tformat:"%s" > rebased6 && + git rebase -i -p --root --onto master && + log_with_names work6 > rebased6 && test_cmp expect-side rebased6 ' @@ -132,32 +130,34 @@ test_expect_success 'set up second root and merge' ' git symbolic-ref HEAD refs/heads/third && rm .git/index && rm A B C && - echo 6 > D && - git add D && - git commit -m 6 && + test_commit 6 D && git checkout other && git merge third ' -sed 's/#/ /g' > expect-third <<'EOF' -* Merge branch 'third' into other -|\## -| * 6 -* | Merge branch 'side' into other -|\ \## -| * | 5 -* | | 4 -|/ /## -* | 3 -|/## -* 2 -* 1 +cat > expect-third <<'EOF' +commit work7 work7~1 work7^2 +Merge branch 'third' into other +commit work7^2 work7~4 +6 +commit work7~1 work7~2 work7~1^2 +Merge branch 'side' into other +commit work7~1^2 work7~3 +5 +commit work7~2 work7~3 +4 +commit work7~3 work7~4 +3 +commit work7~4 work7~5 +2 +commit work7~5 +1 EOF test_expect_success 'rebase -i -p with two roots' ' git checkout -b work7 other && - GIT_EDITOR=: git rebase -i -p --root --onto master && - git log --graph --topo-order --pretty=tformat:"%s" > rebased7 && + git rebase -i -p --root --onto master && + log_with_names work7 > rebased7 && test_cmp expect-third rebased7 ' @@ -172,14 +172,14 @@ EOF test_expect_success 'pre-rebase hook stops rebase' ' git checkout -b stops1 other && - GIT_EDITOR=: test_must_fail git rebase --root --onto master && + 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 && + 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) ' @@ -224,7 +224,7 @@ test_expect_success 'rebase --root with conflict (second part)' ' test_expect_success 'rebase -i --root with conflict (first part)' ' git checkout -b conflict2 other && - GIT_EDITOR=: test_must_fail git rebase -i --root --onto master && + test_must_fail git rebase -i --root --onto master && git ls-files -u | grep "B$" ' @@ -262,7 +262,7 @@ EOF test_expect_success 'rebase -i -p --root with conflict (first part)' ' git checkout -b conflict3 other && - GIT_EDITOR=: test_must_fail git rebase -i -p --root --onto master && + test_must_fail git rebase -i -p --root --onto master && git ls-files -u | grep "B$" ' @@ -273,8 +273,7 @@ test_expect_success 'fix the conflict' ' 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 && + log_with_names conflict3 >out && test_cmp expect-conflict-p out '