f49af274e06fd5e38ed1530bbb0d4fa849e1aa12
1#!/bin/sh
2#
3# Copyright (c) 2019 Denton Liu
4#
5
6test_description='ensure rebase fast-forwards commits when possible'
7
8. ./test-lib.sh
9
10test_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
18test_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
30changes='no changes'
31test_rebase_same_head success
32test_rebase_same_head success master
33test_rebase_same_head success --onto B B
34test_rebase_same_head success --onto B... B
35test_rebase_same_head success --onto master... master
36test_rebase_same_head success --no-fork-point
37test_rebase_same_head success --fork-point master
38test_rebase_same_head failure --fork-point --onto B B
39test_rebase_same_head failure --fork-point --onto B... B
40test_rebase_same_head success --fork-point --onto master... master
41
42test_expect_success 'add work to side' '
43 test_commit E
44'
45
46changes='our changes'
47test_rebase_same_head success
48test_rebase_same_head success master
49test_rebase_same_head success --onto B B
50test_rebase_same_head success --onto B... B
51test_rebase_same_head success --onto master... master
52test_rebase_same_head success --no-fork-point
53test_rebase_same_head success --fork-point master
54test_rebase_same_head failure --fork-point --onto B B
55test_rebase_same_head failure --fork-point --onto B... B
56test_rebase_same_head success --fork-point --onto master... master
57
58test_expect_success 'add work to upstream' '
59 git checkout master &&
60 test_commit F &&
61 git checkout side
62'
63
64changes='our and their changes'
65test_rebase_same_head success --onto B B
66test_rebase_same_head success --onto B... B
67test_rebase_same_head failure --onto master... master
68test_rebase_same_head failure --fork-point --onto B B
69test_rebase_same_head failure --fork-point --onto B... B
70test_rebase_same_head failure --fork-point --onto master... master
71
72test_done