[PATCH] rebase --merge: fix for rebasing more than 7 commits.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Instead of using 4-digit numbers to name commits being rebased,
just use "cmt.$msgnum" string, with $msgnum as a decimal number
without leading zero padding.  This makes it possible to rebase
more than 9999 commits, but of more practical importance is that
the earlier code used "printf" to format already formatted
$msgnum and barfed when it counted up to 0008.  In other words,
the old code was incapable of rebasing more than 7 commits, and
this fixes that problem.

Signed-off-by: Junio C Hamano <junkio@xxxxxxx>
---

 * I wanted to raise my confidence level in the new rebase --merge
   code, so I did a little exercise which resulted in finding this
   buglet.

   I did not have "read/write-tree --prefix" on the "master"
   branch, when I received the patch series that begins with
   "Make git-write-tree a builtin" from Lukas.  Now, my policy
   is to avoid starting a new topic based on "next" (because it
   would make later pulling in the topic into "master" without
   all the other uncooked stuff in "next" impossible), but the
   series was based on "next" (which was actually nice, since
   write-tree between "master" and "next" were somewhat diverged
   back then), and I couldn't easily rebase Lukas's patch series
   on top of "master" because we did not have "rebase --merge"
   option.  Now I can with the updated "rebase".

   So the exercise went like this:

   (1) Start from a clone of git.git, with "master" at 8c278ab
       (where the "master" was before "read/write-tree --prefix"
       was merged), and "ls/am" at ab195e1 (what applying
       Lukas's series on top of "next" would have produced).
       Use "reset --hard" as needed.

   (2) "git rebase --merge --onto master ls/am~9" (ls/am~8 being
       the first one of the series).  This fails with a merge
       conflict on builtin-write-tree.c (the "rebase --merge"
       code did the right thing with the renamed path).  Fix it
       up and also fix builtin.h (signature of write_tree()
       needs to be changed to drop prefix).

       It was very helpful to view:

           git diff :3:builtin-write-tree.c builtin-write-tree.c	

       during the hand resolution of the conflicts; it lets me
       see what Lukas did, so I can adjust the patch by removing
       parts that are specific to "next" and not applicable to
       "master".  

  (3) "git update-index builtin-write-tree.c builtin.h" and then
      "git rebase --continue".  The bug manifests itself during
      the finalization step, which this commit fixes.

  With this fix, the above works beautifully.  I am reasonably
  happy with this shiny new toy.  Good job, Eric! and thanks.

 git-rebase.sh |   23 ++++++++++-------------
 1 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/git-rebase.sh b/git-rebase.sh
index b9ce112..9159477 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -67,16 +67,16 @@ continue_merge () {
 	prev_head=`git-rev-parse HEAD^0`
 
 	# save the resulting commit so we can read-tree on it later
-	echo "$prev_head" > "$dotest/`printf %0${prec}d $msgnum`.result"
+	echo "$prev_head" > "$dotest/cmt.$msgnum.result"
 	echo "$prev_head" > "$dotest/prev_head"
 
 	# onto the next patch:
 	msgnum=$(($msgnum + 1))
-	printf "%0${prec}d" "$msgnum" > "$dotest/msgnum"
+	echo "$msgnum" >"$dotest/msgnum"
 }
 
 call_merge () {
-	cmt="$(cat $dotest/`printf %0${prec}d $1`)"
+	cmt="$(cat $dotest/cmt.$1)"
 	echo "$cmt" > "$dotest/current"
 	git-merge-$strategy "$cmt^" -- HEAD "$cmt"
 	rv=$?
@@ -108,15 +108,12 @@ finish_rb_merge () {
 	end="`cat $dotest/end`"
 	while test "$msgnum" -le "$end"
 	do
-		msgnum=`printf "%0${prec}d" "$msgnum"`
-		printf "%0${prec}d" "$msgnum" > "$dotest/msgnum"
-
-		git-read-tree `cat "$dotest/$msgnum.result"`
+		git-read-tree `cat "$dotest/cmt.$msgnum.result"`
 		git-checkout-index -q -f -u -a
-		git-commit -C "`cat $dotest/$msgnum`"
+		git-commit -C "`cat $dotest/cmt.$msgnum`"
 
-		echo "Committed $msgnum"
-		echo '    '`git-rev-list --pretty=oneline -1 HEAD | \
+		printf "Committed %0${prec}d" $msgnum
+		echo ' '`git-rev-list --pretty=oneline -1 HEAD | \
 					sed 's/^[a-f0-9]\+ //'`
 		msgnum=$(($msgnum + 1))
 	done
@@ -322,11 +319,11 @@ for cmt in `git-rev-list --no-merges "$u
 			| perl -e 'print reverse <>'`
 do
 	msgnum=$(($msgnum + 1))
-	echo "$cmt" > "$dotest/`printf "%0${prec}d" $msgnum`"
+	echo "$cmt" > "$dotest/cmt.$msgnum"
 done
 
-printf "%0${prec}d" 1 > "$dotest/msgnum"
-printf "%0${prec}d" "$msgnum" > "$dotest/end"
+echo 1 >"$dotest/msgnum"
+echo $msgnum >"$dotest/end"
 
 end=$msgnum
 msgnum=1
-- 
1.4.0.gfba6


-
: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]