Skip to content

Commit 238bf1d

Browse files
Denton-Lgitster
authored andcommitted
t3432: test rebase fast-forward behavior
When rebase is run on a branch that can be fast-forwarded, this should automatically be done. Create test to ensure this behavior happens. There are some cases that currently don't pass. The first case is where a feature and master have diverged, running "git rebase master... master" causes a full rebase to happen even though a fast-forward should happen. The second case is when we are doing "git rebase --fork-point" and a fork-point commit is found. Once again, a full rebase happens even though a fast-forward should happen. Mark these cases as failure so we can fix it later. Signed-off-by: Denton Liu <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent aececab commit 238bf1d

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

t/t3432-rebase-fast-forward.sh

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#!/bin/sh
2+
#
3+
# Copyright (c) 2019 Denton Liu
4+
#
5+
6+
test_description='ensure rebase fast-forwards commits when possible'
7+
8+
. ./test-lib.sh
9+
10+
test_expect_success setup '
11+
test_commit A &&
12+
test_commit B &&
13+
test_commit C &&
14+
test_commit D &&
15+
git checkout -t -b side
16+
'
17+
18+
test_rebase_same_head () {
19+
status="$1" &&
20+
shift &&
21+
test_expect_$status "git rebase $* with $changes is no-op" "
22+
oldhead=\$(git rev-parse HEAD) &&
23+
test_when_finished 'git reset --hard \$oldhead' &&
24+
git rebase $* &&
25+
newhead=\$(git rev-parse HEAD) &&
26+
test_cmp_rev \$oldhead \$newhead
27+
"
28+
}
29+
30+
changes='no changes'
31+
test_rebase_same_head success
32+
test_rebase_same_head success master
33+
test_rebase_same_head success --onto B B
34+
test_rebase_same_head success --onto B... B
35+
test_rebase_same_head success --onto master... master
36+
test_rebase_same_head success --no-fork-point
37+
test_rebase_same_head success --fork-point master
38+
test_rebase_same_head failure --fork-point --onto B B
39+
test_rebase_same_head failure --fork-point --onto B... B
40+
test_rebase_same_head success --fork-point --onto master... master
41+
42+
test_expect_success 'add work to side' '
43+
test_commit E
44+
'
45+
46+
changes='our changes'
47+
test_rebase_same_head success
48+
test_rebase_same_head success master
49+
test_rebase_same_head success --onto B B
50+
test_rebase_same_head success --onto B... B
51+
test_rebase_same_head success --onto master... master
52+
test_rebase_same_head success --no-fork-point
53+
test_rebase_same_head success --fork-point master
54+
test_rebase_same_head failure --fork-point --onto B B
55+
test_rebase_same_head failure --fork-point --onto B... B
56+
test_rebase_same_head success --fork-point --onto master... master
57+
58+
test_expect_success 'add work to upstream' '
59+
git checkout master &&
60+
test_commit F &&
61+
git checkout side
62+
'
63+
64+
changes='our and their changes'
65+
test_rebase_same_head success --onto B B
66+
test_rebase_same_head success --onto B... B
67+
test_rebase_same_head failure --onto master... master
68+
test_rebase_same_head failure --fork-point --onto B B
69+
test_rebase_same_head failure --fork-point --onto B... B
70+
test_rebase_same_head failure --fork-point --onto master... master
71+
72+
test_done

0 commit comments

Comments
 (0)