#!/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_n="$1" && shift && what_n="$1" && shift && cmp_n="$1" && shift && status_f="$1" && shift && what_f="$1" && shift && cmp_f="$1" && shift && test_rebase_same_head_ $status_n $what_n $cmp_n " --apply" "$*" && test_rebase_same_head_ $status_f $what_f $cmp_f " --apply --no-ff" "$*" test_rebase_same_head_ $status_n $what_n $cmp_n " --merge" "$*" && test_rebase_same_head_ $status_f $what_f $cmp_f " --merge --no-ff" "$*" } test_rebase_same_head_ () { status="$1" && shift && what="$1" && shift && cmp="$1" && shift && flag="$1" shift && test_expect_$status "git rebase$flag $* with $changes is $what with $cmp HEAD" " oldhead=\$(git rev-parse HEAD) && test_when_finished 'git reset --hard \$oldhead' && cp .git/logs/HEAD expect && git rebase$flag $* >stdout && if test $what = work then old=\$(wc -l