rebase: better rearranging of fixup!/squash! lines with --autosquash

The current behvaior of --autosquash can duplicate fixup!/squash! lines
if they match multiple commits, and it can also apply them to commits
that come after them in the todo list. Even more oddly, a commit that
looks like "fixup! fixup!" will match itself and be duplicated in the
todo list.

Change the todo list rearranging to mark all commits as used as soon
as they are emitted, and to avoid emitting a fixup/squash commit if the
commit has already been marked as used.

Signed-off-by: Kevin Ballard <kevin@sb.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Kevin Ballard
2010-11-04 15:36:31 -07:00
committed by Junio C Hamano
parent af77aee9ca
commit d3d7a421b1
2 changed files with 47 additions and 0 deletions

View File

@ -687,8 +687,12 @@ rearrange_squash () {
*" $sha1 "*) continue ;;
esac
printf '%s\n' "$pick $sha1 $message"
used="$used$sha1 "
while read -r squash action msg
do
case " $used" in
*" $squash "*) continue ;;
esac
case "$message" in
"$msg"*)
printf '%s\n' "$action $squash $action! $msg"