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 <avarab@gmail.com> Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Aug 25, 2019 at 05:12 UTC 4336d365123e45be0ed4a7286df54ccce560d55f
1 file changed +48 -31
t/t3432-rebase-fast-forward.sh
+48 -31
@@ -18,55 +18,72 @@ test_expect_success setup '
18 test_rebase_same_head () {
19 status="$1" &&
20 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" "
26 oldhead=\$(git rev-parse HEAD) &&
27 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 &&
36 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
44 "
45 }
46
47 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
58
42 -test_expect_success 'add work to side' '
59 +test_expect_success 'add work same to side' '
60 test_commit E
61 '
62
63 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
74
58 -test_expect_success 'add work to upstream' '
75 +test_expect_success 'add work same to upstream' '
76 git checkout master &&
77 test_commit F &&
78 git checkout side
79 '
80
81 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
88
89 test_done