Skip to content

Commit 4336d36

Browse files
avargitster
authored andcommitted
t3432: distinguish "noop-same" v.s. "work-same" in "same head" tests
Change "same head" introduced in the preceding commit to check whether the rebase.c code lands in the can_fast_forward() case in, and thus prints out an "is up to date" and aborts early. In some of these cases we make it past that and to "rewinding head", then do a rebase, only to find out there's nothing to change so HEAD stays at the same OID. These tests presumed these two cases were the same thing. In terms of where HEAD ends up they are, but we're not only interested in rebase semantics, but also whether or not we're needlessly doing work when we could avoid it entirely. I'm adding "same" and "diff" here because I'll follow-up and add --no-ff tests, where some of those will be "diff"-erent, so add the "diff" code already. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Denton Liu <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 793ac7e commit 4336d36

File tree

1 file changed

+48
-31
lines changed

1 file changed

+48
-31
lines changed

t/t3432-rebase-fast-forward.sh

Lines changed: 48 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,55 +18,72 @@ test_expect_success setup '
1818
test_rebase_same_head () {
1919
status="$1" &&
2020
shift &&
21-
test_expect_$status "git rebase $* with $changes is no-op" "
21+
what="$1" &&
22+
shift &&
23+
cmp="$1" &&
24+
shift &&
25+
test_expect_$status "git rebase $* with $changes is $what" "
2226
oldhead=\$(git rev-parse HEAD) &&
2327
test_when_finished 'git reset --hard \$oldhead' &&
24-
git rebase $* &&
28+
git rebase $* >stdout &&
29+
if test $what = work
30+
then
31+
test_i18ngrep 'rewinding head' stdout
32+
elif test $what = noop
33+
then
34+
test_i18ngrep 'is up to date' stdout
35+
fi &&
2536
newhead=\$(git rev-parse HEAD) &&
26-
test_cmp_rev \$oldhead \$newhead
37+
if test $cmp = same
38+
then
39+
test_cmp_rev \$oldhead \$newhead
40+
elif test $cmp = diff
41+
then
42+
! test_cmp_rev \$oldhead \$newhead
43+
fi
2744
"
2845
}
2946

3047
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
48+
test_rebase_same_head success work same
49+
test_rebase_same_head success noop same master
50+
test_rebase_same_head success noop same --onto B B
51+
test_rebase_same_head success noop same --onto B... B
52+
test_rebase_same_head success noop same --onto master... master
53+
test_rebase_same_head success noop same --no-fork-point
54+
test_rebase_same_head success work same --fork-point master
55+
test_rebase_same_head failure noop same --fork-point --onto B B
56+
test_rebase_same_head failure work same --fork-point --onto B... B
57+
test_rebase_same_head success work same --fork-point --onto master... master
4158

42-
test_expect_success 'add work to side' '
59+
test_expect_success 'add work same to side' '
4360
test_commit E
4461
'
4562

4663
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
64+
test_rebase_same_head success work same
65+
test_rebase_same_head success noop same master
66+
test_rebase_same_head success noop same --onto B B
67+
test_rebase_same_head success noop same --onto B... B
68+
test_rebase_same_head success noop same --onto master... master
69+
test_rebase_same_head success noop same --no-fork-point
70+
test_rebase_same_head success work same --fork-point master
71+
test_rebase_same_head failure work same --fork-point --onto B B
72+
test_rebase_same_head failure work same --fork-point --onto B... B
73+
test_rebase_same_head success work same --fork-point --onto master... master
5774

58-
test_expect_success 'add work to upstream' '
75+
test_expect_success 'add work same to upstream' '
5976
git checkout master &&
6077
test_commit F &&
6178
git checkout side
6279
'
6380

6481
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
82+
test_rebase_same_head success noop same --onto B B
83+
test_rebase_same_head success noop same --onto B... B
84+
test_rebase_same_head failure work same --onto master... master
85+
test_rebase_same_head failure work same --fork-point --onto B B
86+
test_rebase_same_head failure work same --fork-point --onto B... B
87+
test_rebase_same_head failure work same --fork-point --onto master... master
7188

7289
test_done

0 commit comments

Comments
 (0)