|
| 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