mirror of
https://github.com/git/git.git
synced 2024-12-28 03:03:39 +08:00
73 lines
2.0 KiB
Bash
73 lines
2.0 KiB
Bash
|
#!/bin/sh
|
||
|
#
|
||
|
# Copyright (c) 2019 Denton Liu
|
||
|
#
|
||
|
|
||
|
test_description='ensure rebase fast-forwards commits when possible'
|
||
|
|
||
|
. ./test-lib.sh
|
||
|
|
||
|
test_expect_success setup '
|
||
|
test_commit A &&
|
||
|
test_commit B &&
|
||
|
test_commit C &&
|
||
|
test_commit D &&
|
||
|
git checkout -t -b side
|
||
|
'
|
||
|
|
||
|
test_rebase_same_head () {
|
||
|
status="$1" &&
|
||
|
shift &&
|
||
|
test_expect_$status "git rebase $* with $changes is no-op" "
|
||
|
oldhead=\$(git rev-parse HEAD) &&
|
||
|
test_when_finished 'git reset --hard \$oldhead' &&
|
||
|
git rebase $* &&
|
||
|
newhead=\$(git rev-parse HEAD) &&
|
||
|
test_cmp_rev \$oldhead \$newhead
|
||
|
"
|
||
|
}
|
||
|
|
||
|
changes='no changes'
|
||
|
test_rebase_same_head success
|
||
|
test_rebase_same_head success master
|
||
|
test_rebase_same_head success --onto B B
|
||
|
test_rebase_same_head success --onto B... B
|
||
|
test_rebase_same_head success --onto master... master
|
||
|
test_rebase_same_head success --no-fork-point
|
||
|
test_rebase_same_head success --fork-point master
|
||
|
test_rebase_same_head failure --fork-point --onto B B
|
||
|
test_rebase_same_head failure --fork-point --onto B... B
|
||
|
test_rebase_same_head success --fork-point --onto master... master
|
||
|
|
||
|
test_expect_success 'add work to side' '
|
||
|
test_commit E
|
||
|
'
|
||
|
|
||
|
changes='our changes'
|
||
|
test_rebase_same_head success
|
||
|
test_rebase_same_head success master
|
||
|
test_rebase_same_head success --onto B B
|
||
|
test_rebase_same_head success --onto B... B
|
||
|
test_rebase_same_head success --onto master... master
|
||
|
test_rebase_same_head success --no-fork-point
|
||
|
test_rebase_same_head success --fork-point master
|
||
|
test_rebase_same_head failure --fork-point --onto B B
|
||
|
test_rebase_same_head failure --fork-point --onto B... B
|
||
|
test_rebase_same_head success --fork-point --onto master... master
|
||
|
|
||
|
test_expect_success 'add work to upstream' '
|
||
|
git checkout master &&
|
||
|
test_commit F &&
|
||
|
git checkout side
|
||
|
'
|
||
|
|
||
|
changes='our and their changes'
|
||
|
test_rebase_same_head success --onto B B
|
||
|
test_rebase_same_head success --onto B... B
|
||
|
test_rebase_same_head failure --onto master... master
|
||
|
test_rebase_same_head failure --fork-point --onto B B
|
||
|
test_rebase_same_head failure --fork-point --onto B... B
|
||
|
test_rebase_same_head failure --fork-point --onto master... master
|
||
|
|
||
|
test_done
|