rebase -i: fix squashing corner case
When squashing, rebase -i did not prevent fast forwards. This could happen when picking some other commit than the first one, and then squashing the first commit. So do not allow fast forwards when squashing. Noticed by Johannes Sixt. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
191131e538
commit
1d25c8cf82
@ -96,13 +96,14 @@ die_abort () {
|
||||
}
|
||||
|
||||
pick_one () {
|
||||
case "$1" in -n) sha1=$2 ;; *) sha1=$1 ;; esac
|
||||
no_ff=
|
||||
case "$1" in -n) sha1=$2; no_ff=t ;; *) sha1=$1 ;; esac
|
||||
output git rev-parse --verify $sha1 || die "Invalid commit name: $sha1"
|
||||
test -d "$REWRITTEN" &&
|
||||
pick_one_preserving_merges "$@" && return
|
||||
parent_sha1=$(git rev-parse --verify $sha1^ 2>/dev/null)
|
||||
current_sha1=$(git rev-parse --verify HEAD)
|
||||
if test $current_sha1 = $parent_sha1; then
|
||||
if test $no_ff$current_sha1 = $parent_sha1; then
|
||||
output git reset --hard $sha1
|
||||
test "a$1" = a-n && output git reset --soft $current_sha1
|
||||
sha1=$(git rev-parse --short $sha1)
|
||||
|
Reference in New Issue
Block a user