From: Junio C Hamano Date: Wed, 20 Jan 2010 22:42:04 +0000 (-0800) Subject: Merge branch 'ns/rebase-auto-squash' X-Git-Tag: v1.7.0-rc0~69 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=cea20f24738c558d56483402db1ddfebd0362ee4;p=git.git Merge branch 'ns/rebase-auto-squash' * ns/rebase-auto-squash: rebase -i --autosquash: auto-squash commits Conflicts: git-rebase--interactive.sh --- cea20f24738c558d56483402db1ddfebd0362ee4 diff --cc git-rebase--interactive.sh index d0b59c96c,935e9e1b1..2e56e64a1 --- a/git-rebase--interactive.sh +++ b/git-rebase--interactive.sh @@@ -519,25 -521,37 +521,56 @@@ get_saved_options () test -f "$DOTEST"/rebase-root && REBASE_ROOT=t } + # Rearrange the todo list that has both "pick sha1 msg" and + # "pick sha1 fixup!/squash! msg" appears in it so that the latter + # comes immediately after the former, and change "pick" to + # "fixup"/"squash". + rearrange_squash () { + sed -n -e 's/^pick \([0-9a-f]*\) \(squash\)! /\1 \2 /p' \ + -e 's/^pick \([0-9a-f]*\) \(fixup\)! /\1 \2 /p' \ + "$1" >"$1.sq" + test -s "$1.sq" || return + + used= + while read pick sha1 message + do + case " $used" in + *" $sha1 "*) continue ;; + esac + echo "$pick $sha1 $message" + while read squash action msg + do + case "$message" in + "$msg"*) + echo "$action $squash $action! $msg" + used="$used$squash " + ;; + esac + done <"$1.sq" + done >"$1.rearranged" <"$1" + cat "$1.rearranged" >"$1" + rm -f "$1.sq" "$1.rearranged" + } + +LF=' +' +parse_onto () { + case "$1" in + *...*) + if left=${1%...*} right=${1#*...} && + onto=$(git merge-base --all ${left:-HEAD} ${right:-HEAD}) + then + case "$onto" in + ?*"$LF"?* | '') + exit 1 ;; + esac + echo "$onto" + exit 0 + fi + esac + git rev-parse --verify "$1^0" +} + while test $# != 0 do case "$1" in @@@ -643,9 -657,12 +676,12 @@@ first and then run 'git rebase --contin --root) REBASE_ROOT=t ;; + --autosquash) + AUTOSQUASH=t + ;; --onto) shift - ONTO=$(git rev-parse --verify "$1") || + ONTO=$(parse_onto "$1") || die "Does not point to a valid commit: $1" ;; --)