interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / t / t3432-rebase-fast-forward.sh

147 lines · 5344 bytes Raw Blame History
1#!/bin/sh
2#
3# Copyright (c) 2019 Denton Liu
4#
5
6test_description='ensure rebase fast-forwards commits when possible'
7
8GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
9export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
10
11. ./test-lib.sh
12
13test_expect_success setup '
14 # Commit dates are hardcoded to 2005, and the reflog entries will have
15 # a matching timestamp. Maintenance may thus immediately expire
16 # reflogs if it was running.
17 git config set gc.reflogExpire never &&
18 git config set gc.reflogExpireUnreachable never &&
19
20 test_commit A &&
21 test_commit B &&
22 test_commit C &&
23 test_commit D &&
24 git checkout -t -b side
25'
26
27test_rebase_same_head () {
28 status_n="$1" &&
29 shift &&
30 what_n="$1" &&
31 shift &&
32 cmp_n="$1" &&
33 shift &&
34 status_f="$1" &&
35 shift &&
36 what_f="$1" &&
37 shift &&
38 cmp_f="$1" &&
39 shift &&
40 test_rebase_same_head_ $status_n $what_n $cmp_n 0 " --apply" "$*" &&
41 test_rebase_same_head_ $status_f $what_f $cmp_f 0 " --apply --no-ff" "$*"
42 test_rebase_same_head_ $status_n $what_n $cmp_n 0 " --merge" "$*" &&
43 test_rebase_same_head_ $status_f $what_f $cmp_f 0 " --merge --no-ff" "$*"
44 test_rebase_same_head_ $status_n $what_n $cmp_n 1 " --merge" "$*" &&
45 test_rebase_same_head_ $status_f $what_f $cmp_f 1 " --merge --no-ff" "$*"
46}
47
48test_rebase_same_head_ () {
49 status="$1" &&
50 shift &&
51 what="$1" &&
52 shift &&
53 cmp="$1" &&
54 shift &&
55 abbreviate="$1" &&
56 shift &&
57 flag="$1"
58 shift &&
59 if test $abbreviate -eq 1
60 then
61 msg="git rebase$flag $* (rebase.abbreviateCommands = true) with $changes is $what with $cmp HEAD"
62 else
63 msg="git rebase$flag $* with $changes is $what with $cmp HEAD"
64 fi &&
65 test_expect_$status "$msg" "
66 if test $abbreviate -eq 1
67 then
68 test_config rebase.abbreviateCommands true
69 fi &&
70 oldhead=\$(git rev-parse HEAD) &&
71 test_when_finished 'git reset --hard \$oldhead' &&
72 git reflog HEAD >expect &&
73 git rebase$flag $* >stdout &&
74 git reflog HEAD >actual &&
75 if test $what = work
76 then
77 old=\$(wc -l <expect) &&
78 test_line_count '-gt' \$old actual
79 elif test $what = noop
80 then
81 test_cmp expect actual
82 fi &&
83 newhead=\$(git rev-parse HEAD) &&
84 if test $cmp = same
85 then
86 test_cmp_rev \$oldhead \$newhead
87 elif test $cmp = diff
88 then
89 test_cmp_rev ! \$oldhead \$newhead
90 fi
91 "
92}
93
94changes='no changes'
95test_rebase_same_head success noop same success work same
96test_rebase_same_head success noop same success work same main
97test_rebase_same_head success noop same success work diff --onto B B
98test_rebase_same_head success noop same success work diff --onto B... B
99test_rebase_same_head success noop same success work same --onto main... main
100test_rebase_same_head success noop same success work same --keep-base main
101test_rebase_same_head success noop same success work same --keep-base
102test_rebase_same_head success noop same success work same --no-fork-point
103test_rebase_same_head success noop same success work same --keep-base --no-fork-point
104test_rebase_same_head success noop same success work same --fork-point main
105test_rebase_same_head success noop same success work diff --fork-point --onto B B
106test_rebase_same_head success noop same success work diff --fork-point --onto B... B
107test_rebase_same_head success noop same success work same --fork-point --onto main... main
108test_rebase_same_head success noop same success work same --keep-base --keep-base main
109
110test_expect_success 'add work same to side' '
111 test_commit E
112'
113
114changes='our changes'
115test_rebase_same_head success noop same success work same
116test_rebase_same_head success noop same success work same main
117test_rebase_same_head success noop same success work diff --onto B B
118test_rebase_same_head success noop same success work diff --onto B... B
119test_rebase_same_head success noop same success work same --onto main... main
120test_rebase_same_head success noop same success work same --keep-base main
121test_rebase_same_head success noop same success work same --keep-base
122test_rebase_same_head success noop same success work same --no-fork-point
123test_rebase_same_head success noop same success work same --keep-base --no-fork-point
124test_rebase_same_head success noop same success work same --fork-point main
125test_rebase_same_head success noop same success work diff --fork-point --onto B B
126test_rebase_same_head success noop same success work diff --fork-point --onto B... B
127test_rebase_same_head success noop same success work same --fork-point --onto main... main
128test_rebase_same_head success noop same success work same --fork-point --keep-base main
129
130test_expect_success 'add work same to upstream' '
131 git checkout main &&
132 test_commit F &&
133 git checkout side
134'
135
136changes='our and their changes'
137test_rebase_same_head success noop same success work diff --onto B B
138test_rebase_same_head success noop same success work diff --onto B... B
139test_rebase_same_head success noop same success work diff --onto main... main
140test_rebase_same_head success noop same success work diff --keep-base main
141test_rebase_same_head success noop same success work diff --keep-base
142test_rebase_same_head failure work same success work diff --fork-point --onto B B
143test_rebase_same_head failure work same success work diff --fork-point --onto B... B
144test_rebase_same_head success noop same success work diff --fork-point --onto main... main
145test_rebase_same_head success noop same success work diff --fork-point --keep-base main
146
147test_done