git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: Stephen Haberman <stephen@exigencecorp.com>,
	gitster@pobox.com, git@vger.kernel.org
Subject: Re: [PATCH] rebase-i-p: only list commits that require rewriting in todo
Date: Mon, 20 Oct 2008 16:36:38 -0700	[thread overview]
Message-ID: <7vej2a3kl5.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <20081020115003.GA11309@coredump.intra.peff.net> (Jeff King's message of "Mon, 20 Oct 2008 07:50:04 -0400")

Jeff King <peff@peff.net> writes:

> On Wed, Oct 15, 2008 at 02:44:38AM -0500, Stephen Haberman wrote:
>
>> +					cat "$TODO" | grep -v "${rev:0:7}" > "${TODO}2" ; mv "${TODO}2" "$TODO"
>
> Substring expansion (like ${rev:0:7}) is not portable. At least it
> doesn't work on FreeBSD /bin/sh, and "it's not even in POSIX", I
> believe.

True.

I do not remember the individual patches in the series, but I have to say
that the script at the tip of the topic is, eh, less than ideal.

Here is a small untested patch to fix a few issues I spotted while reading
it for two minutes.

 * Why filter output from "rev-list --left-right A...B" and look for the
   ones that begin with ">"?  Wouldn't "rev-list A..B" give that?

 * The abbreviated SHA-1 are made with "rev-list --abbrev=7" into $TODO in
   an earlier invocation, and it can be more than 7 letters to avoid
   ambiguity.  Not just that "${r:0:7} is not even in POSIX", but use of
   it here is actively wrong.

 * There is no point in catting a single file and piping it into grep.


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

diff --git i/git-rebase--interactive.sh w/git-rebase--interactive.sh
index 848fbe7..a563dea 100755
--- i/git-rebase--interactive.sh
+++ w/git-rebase--interactive.sh
@@ -635,8 +635,8 @@ first and then run 'git rebase --continue' again."
 				sed -n "s/^>//p" > "$DOTEST"/not-cherry-picks
 			# Now all commits and note which ones are missing in
 			# not-cherry-picks and hence being dropped
-			git rev-list $UPSTREAM...$HEAD --left-right | \
-				sed -n "s/^>//p" | while read rev
+			git rev-list $UPSTREAM..$HEAD |
+			while read rev
 			do
 				if test -f "$REWRITTEN"/$rev -a "$(grep "$rev" "$DOTEST"/not-cherry-picks)" = ""
 				then
@@ -645,7 +645,8 @@ first and then run 'git rebase --continue' again."
 					# just the history of its first-parent for others that will
 					# be rebasing on top of it
 					git rev-list --parents -1 $rev | cut -d' ' -f2 > "$DROPPED"/$rev
-					cat "$TODO" | grep -v "${rev:0:7}" > "${TODO}2" ; mv "${TODO}2" "$TODO"
+					short=$(git rev-list -1 --abbrev-commit --abbrev=7 $rev)
+					grep -v "^[a-z][a-z]* $short" <"$TODO" > "${TODO}2" ; mv "${TODO}2" "$TODO"
 					rm "$REWRITTEN"/$rev
 				fi
 			done

  reply	other threads:[~2008-10-20 23:38 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-15  7:44 [PATCH] rebase-i-p: squashing and limiting todo Stephen Haberman
2008-10-15  7:44 ` [PATCH] rebase-i-p: test to exclude commits from todo based on its parents Stephen Haberman
2008-10-15  7:44   ` [PATCH] rebase-i-p: use HEAD for updating the ref instead of mapping OLDHEAD Stephen Haberman
2008-10-15  7:44     ` [PATCH] rebase-i-p: delay saving current-commit to REWRITTEN if squashing Stephen Haberman
2008-10-15  7:44       ` [PATCH] rebase-i-p: fix 'no squashing merges' tripping up non-merges Stephen Haberman
2008-10-15  7:44         ` [PATCH] rebase-i-p: only list commits that require rewriting in todo Stephen Haberman
2008-10-15  7:44           ` [PATCH] rebase-i-p: do not include non-first-parent commits touching UPSTREAM Stephen Haberman
2008-10-15  7:44             ` [PATCH] rebase-i-p: if todo was reordered use HEAD as the rewritten parent Stephen Haberman
2008-10-20 11:50           ` [PATCH] rebase-i-p: only list commits that require rewriting in todo Jeff King
2008-10-20 23:36             ` Junio C Hamano [this message]
2008-10-21  0:39               ` Jeff King
2008-10-22  5:01               ` Stephen Haberman
2008-10-22  5:48                 ` Junio C Hamano
2008-10-22 12:51       ` [PATCH] rebase-i-p: delay saving current-commit to REWRITTEN if squashing Jeff King
2008-10-22 15:21         ` Johannes Schindelin
2008-10-22 15:50           ` Fredrik Skolmli
2008-10-22 19:10         ` Junio C Hamano
2008-10-22 19:15           ` Jeff King

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=7vej2a3kl5.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    --cc=stephen@exigencecorp.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).