path: root/
diff options
authorBrandon Casey <>2010-08-13 20:47:34 (GMT)
committerJunio C Hamano <>2010-08-13 21:19:12 (GMT)
commit2d6ca6ef55226185b6a093f7fac27f5fecd51fe6 (patch)
tree444e97b13471f14e7a4a5d690f5edfedc8700771 /
parent2caf20c52b7f646d0a7481c25415c48d687773b2 (diff)
git-2d6ca6ef55226185b6a093f7fac27f5fecd51fe6.tar.bz2 rework skip_unnecessary_picks
Commit cd035b1c introduced the exec command to interactive rebase. In doing so, it modified the way that skip_unnecessary_picks iterates through the list of rebase commands so that it avoided collapsing multiple spaces into a single space. This is necessary for example if the argument to the exec command contains a path with multiple spaces in it. The way it did this was by reading each line of rebase commands into a single variable, and then breaking the individual components out using echo, sed, and cut. It used the individual broken-out components for decision making, and was still able to write the original line to the output file from the variable it had saved it in. But, since we only really need to look at anything other than the first element of the line when a 'pick' command is encountered, and even that is only necessary when we are still searching for "unnecessary" picks, and since newer rebase commands like 'exec' may not even require a sha1 field, let's make our read statement parse its input into a "command" variable, and a "rest" variable, and then only break out the sha1 from $rest, and call git-rev-parse, when absolutely necessary. I think this future proofs this subroutine, avoids calling git-rev-parse unnecessarily, and possibly with bogus arguments, and still accomplishes the goal of not mangling the $rest of the rebase command. Signed-off-by: Brandon Casey <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to '')
1 files changed, 14 insertions, 9 deletions
diff --git a/ b/
index 6c8ff0c..3b10513 100755
--- a/
+++ b/
@@ -619,25 +619,30 @@ do_rest () {
# skip picking commits whose parents are unchanged
skip_unnecessary_picks () {
- while read -r line
+ while read -r command rest
- command=$(echo "$line" | sed 's/ */ /' | cut -d ' ' -f 1)
- sha1=$(echo "$line" | sed 's/ */ /' | cut -d ' ' -f 2)
- rest=$(echo "$line" | sed 's/ */ /' | cut -d ' ' -f 3-)
# fd=3 means we skip the command
- case "$fd,$command,$(git rev-parse --verify --quiet "$sha1"^)" in
- 3,pick,"$ONTO"*|3,p,"$ONTO"*)
+ case "$fd,$command" in
+ 3,pick|3,p)
# pick a commit whose parent is current $ONTO -> skip
- ONTO=$sha1
+ sha1=$(echo "$rest" | cut -d ' ' -f 1)
+ case "$(git rev-parse --verify --quiet "$sha1"^)" in
+ "$ONTO"*)
+ ONTO=$sha1
+ ;;
+ *)
+ fd=1
+ ;;
+ esac
- 3,#*|3,,*)
+ 3,#*|3,)
# copy comments
- echo "$line" >&$fd
+ echo "$command${rest:+ }$rest" >&$fd
done <"$TODO" >"$" 3>>"$DONE" &&
mv -f "$TODO".new "$TODO" &&
case "$(peek_next_command)" in