git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Carlos Martín Nieto" <cmn@elego.de>
To: git@vger.kernel.org
Cc: Kevin Ballard <kevin@sb.org>, Pat Notz <patnotz@gmail.com>,
	Junio C Hamano <gitster@pobox.com>
Subject: [RFC PATCH] Chain squash!/fixup! commits on autosquash
Date: Mon, 11 Apr 2011 17:34:24 +0200	[thread overview]
Message-ID: <1302536064-3922-1-git-send-email-cmn@elego.de> (raw)

If one has the following commits

    5154127 fixup! fixup! one
    0d130d8 fixup! one
    0869d30 one

current code will only rearrange 0d130d8 because it thinks it has
already checked for commits that modify it.

Separate the idea of an 'used' and an 'applied' line. Applied lines
are the ones that have been moved to modify some commit whilst used
lines are the ones for which we have tried to find modifications.
---

This supports the case I originally mentioned. It however breaks quite
badly if one has two chains, such as

    0792561 fixup! squash! squash! six
    e72100f squash! squash! six
    90187b8 fixup! fixup! one
    6facd7d fixup! one
    4f48f55 one
    733844b squash! six
    e9de3cc six
    76990c9 five
    db0d525 one

because it will try to add 0792561 as a fixup to e72100f. However, as
it has moved, it is made into a fixup of 90187b8, which is definitely
bad (not that I think anybody would ever have such a chain in real
life).

This should be fixable by modifying the loop a bit so it doesn't read
the next line on each iteration so we can feed it the current
line. Would you be interested in such a patch?  For me this is a bit
more elegant than removing the "fixup!" on commit (though my shell
skills aren't that great).

 git-rebase--interactive.sh |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 5873ba4..a681f47 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -692,16 +692,22 @@ rearrange_squash () {
 	test -s "$1.sq" || return
 
 	used=
+	applied=
 	while read -r pick sha1 message
 	do
 		case " $used" in
 		*" $sha1 "*) continue ;;
 		esac
-		printf '%s\n' "$pick $sha1 $message"
+		# If it's been applied, we don't want to output the "pick" line
+		case " $applied" in
+			*" $sha1 "*) ;;
+			*) printf '%s\n' "$pick $sha1 $message";;
+		esac
 		used="$used$sha1 "
 		while read -r squash action msg
 		do
-			case " $used" in
+			# Ignore the commits we've already dealt with
+			case " $used $applied " in
 			*" $squash "*) continue ;;
 			esac
 			emit=0
@@ -716,7 +722,7 @@ rearrange_squash () {
 			esac
 			if test $emit = 1; then
 				printf '%s\n' "$action $squash $action! $msg"
-				used="$used$squash "
+				applied="$applied$squash "
 			fi
 		done <"$1.sq"
 	done >"$1.rearranged" <"$1"
-- 
1.7.4.1

                 reply	other threads:[~2011-04-11 15:34 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1302536064-3922-1-git-send-email-cmn@elego.de \
    --to=cmn@elego.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=kevin@sb.org \
    --cc=patnotz@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).