Skip to content

Commit

Permalink
rebase -i: use new --ff cherry-pick option
Browse files Browse the repository at this point in the history
This simplifies rebase -i a little bit.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Christian Couder authored and Junio C Hamano committed Mar 20, 2010
1 parent ab7e63e commit 8e75abf
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions git-rebase--interactive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ do_with_author () {
}

pick_one () {
no_ff=
case "$1" in -n) sha1=$2; no_ff=t ;; *) sha1=$1 ;; esac
ff=--ff
case "$1" in -n) sha1=$2; ff= ;; *) sha1=$1 ;; esac
output git rev-parse --verify $sha1 || die "Invalid commit name: $sha1"
test -d "$REWRITTEN" &&
pick_one_preserving_merges "$@" && return
Expand All @@ -232,16 +232,7 @@ pick_one () {
output git cherry-pick "$@"
return
fi
parent_sha1=$(git rev-parse --verify $sha1^) ||
die "Could not get the parent of $sha1"
current_sha1=$(git rev-parse --verify HEAD)
if test -z "$no_ff" && test "$current_sha1" = "$parent_sha1"
then
output git reset --hard $sha1
output warn Fast-forward to $(git rev-parse --short $sha1)
else
output git cherry-pick "$@"
fi
output git cherry-pick $ff "$@"
}

pick_one_preserving_merges () {
Expand Down

0 comments on commit 8e75abf

Please sign in to comment.