@matheusbsbs / matheus-bagliano / commits / e249044c67
Fork 0

rebase-i-p: minimum fix to obvious issues

Jeff King noticed that this series uses non-portable ${var:0:7} syntax to splice a string, which is not even in POSIX, in the script. A quick look at around the offending part revealed a few issues, which this commit fixes: * 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. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Oct 20, 2008 at 16:36 UTC e249044c67d347dcffff247c72a503a9dd592294
1 file changed +4 -3
git-rebase--interactive.sh
+4 -3
@@ -635,8 +635,8 @@ first and then run 'git rebase --continue' again."
635 sed -n "s/^>//p" > "$DOTEST"/not-cherry-picks
636 # Now all commits and note which ones are missing in
637 # not-cherry-picks and hence being dropped
638 - git rev-list $UPSTREAM...$HEAD --left-right | \
639 - sed -n "s/^>//p" | while read rev
638 + git rev-list $UPSTREAM..$HEAD |
639 + while read rev
640 do
641 if test -f "$REWRITTEN"/$rev -a "$(grep "$rev" "$DOTEST"/not-cherry-picks)" = ""
642 then
@@ -645,7 +645,8 @@ first and then run 'git rebase --continue' again."
645 # just the history of its first-parent for others that will
646 # be rebasing on top of it
647 git rev-list --parents -1 $rev | cut -d' ' -f2 > "$DROPPED"/$rev
648 - cat "$TODO" | grep -v "${rev:0:7}" > "${TODO}2" ; mv "${TODO}2" "$TODO"
648 + short=$(git rev-list -1 --abbrev-commit --abbrev=7 $rev)
649 + grep -v "^[a-z][a-z]* $short" <"$TODO" > "${TODO}2" ; mv "${TODO}2" "$TODO"
650 rm "$REWRITTEN"/$rev
651 fi
652 done