Skip to content

Commit 2ea3c17

Browse files
trastgitster
authored andcommitted
t3412: use log|name-rev instead of log --graph
Replace all 'git log --graph' calls for history verification with the combination of 'git log ...| git name-rev' first introduced by a6c7a27 (rebase -i: correctly remember --root flag across --continue, 2009-01-26). This should be less susceptible to format changes than the --graph code. Signed-off-by: Thomas Rast <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e80f97e commit 2ea3c17

File tree

1 file changed

+39
-26
lines changed

1 file changed

+39
-26
lines changed

t/t3412-rebase-root.sh

Lines changed: 39 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ Tests if git rebase --root --onto <newparent> can rebase the root commit.
1010
GIT_EDITOR=:
1111
export GIT_EDITOR
1212

13+
log_with_names () {
14+
git rev-list --topo-order --parents --pretty="tformat:%s" HEAD |
15+
git name-rev --stdin --name-only --refs=refs/heads/$1
16+
}
17+
18+
1319
test_expect_success 'prepare repository' '
1420
test_commit 1 A &&
1521
test_commit 2 A &&
@@ -102,21 +108,25 @@ test_expect_success 'set up merge history' '
102108
git merge side
103109
'
104110

105-
sed 's/#/ /g' > expect-side <<'EOF'
106-
* Merge branch 'side' into other
107-
|\##
108-
| * 5
109-
* | 4
110-
|/##
111-
* 3
112-
* 2
113-
* 1
111+
cat > expect-side <<'EOF'
112+
commit work6 work6~1 work6^2
113+
Merge branch 'side' into other
114+
commit work6^2 work6~2
115+
5
116+
commit work6~1 work6~2
117+
4
118+
commit work6~2 work6~3
119+
3
120+
commit work6~3 work6~4
121+
2
122+
commit work6~4
123+
1
114124
EOF
115125

116126
test_expect_success 'rebase -i -p with merge' '
117127
git checkout -b work6 other &&
118128
git rebase -i -p --root --onto master &&
119-
git log --graph --topo-order --pretty=tformat:"%s" > rebased6 &&
129+
log_with_names work6 > rebased6 &&
120130
test_cmp expect-side rebased6
121131
'
122132

@@ -129,25 +139,29 @@ test_expect_success 'set up second root and merge' '
129139
git merge third
130140
'
131141

132-
sed 's/#/ /g' > expect-third <<'EOF'
133-
* Merge branch 'third' into other
134-
|\##
135-
| * 6
136-
* | Merge branch 'side' into other
137-
|\ \##
138-
| * | 5
139-
* | | 4
140-
|/ /##
141-
* | 3
142-
|/##
143-
* 2
144-
* 1
142+
cat > expect-third <<'EOF'
143+
commit work7 work7~1 work7^2
144+
Merge branch 'third' into other
145+
commit work7^2 work7~4
146+
6
147+
commit work7~1 work7~2 work7~1^2
148+
Merge branch 'side' into other
149+
commit work7~1^2 work7~3
150+
5
151+
commit work7~2 work7~3
152+
4
153+
commit work7~3 work7~4
154+
3
155+
commit work7~4 work7~5
156+
2
157+
commit work7~5
158+
1
145159
EOF
146160

147161
test_expect_success 'rebase -i -p with two roots' '
148162
git checkout -b work7 other &&
149163
git rebase -i -p --root --onto master &&
150-
git log --graph --topo-order --pretty=tformat:"%s" > rebased7 &&
164+
log_with_names work7 > rebased7 &&
151165
test_cmp expect-third rebased7
152166
'
153167

@@ -263,8 +277,7 @@ test_expect_success 'fix the conflict' '
263277

264278
test_expect_success 'rebase -i -p --root with conflict (second part)' '
265279
git rebase --continue &&
266-
git rev-list --topo-order --parents --pretty="tformat:%s" HEAD |
267-
git name-rev --stdin --name-only --refs=refs/heads/conflict3 >out &&
280+
log_with_names conflict3 >out &&
268281
test_cmp expect-conflict-p out
269282
'
270283

0 commit comments

Comments
 (0)