rebase --merge: fix for rebasing more than 7 commits.
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@cox.net>
Junio C Hamano committed
Jun 22, 2006 at 01:44 UTC
5887ac821f9df614cfcf3349960523e1c36f2de7
1 file changed
+10
-13
git-rebase.sh
+10
-13
@@ -67,16 +67,16 @@ continue_merge () {
67
prev_head=`git-rev-parse HEAD^0`
68
69
# save the resulting commit so we can read-tree on it later
70
- echo "$prev_head" > "$dotest/`printf %0${prec}d $msgnum`.result"
70
+ echo "$prev_head" > "$dotest/cmt.$msgnum.result"
71
echo "$prev_head" > "$dotest/prev_head"
72
73
# onto the next patch:
74
msgnum=$(($msgnum + 1))
75
- printf "%0${prec}d" "$msgnum" > "$dotest/msgnum"
75
+ echo "$msgnum" >"$dotest/msgnum"
76
}
77
78
call_merge () {
79
- cmt="$(cat $dotest/`printf %0${prec}d $1`)"
79
+ cmt="$(cat $dotest/cmt.$1)"
80
echo "$cmt" > "$dotest/current"
81
git-merge-$strategy "$cmt^" -- HEAD "$cmt"
82
rv=$?
@@ -108,15 +108,12 @@ finish_rb_merge () {
108
end="`cat $dotest/end`"
109
while test "$msgnum" -le "$end"
110
do
111
- msgnum=`printf "%0${prec}d" "$msgnum"`
112
- printf "%0${prec}d" "$msgnum" > "$dotest/msgnum"
113
-
114
- git-read-tree `cat "$dotest/$msgnum.result"`
111
+ git-read-tree `cat "$dotest/cmt.$msgnum.result"`
112
git-checkout-index -q -f -u -a
116
- git-commit -C "`cat $dotest/$msgnum`"
113
+ git-commit -C "`cat $dotest/cmt.$msgnum`"
114
118
- echo "Committed $msgnum"
119
- echo ' '`git-rev-list --pretty=oneline -1 HEAD | \
115
+ printf "Committed %0${prec}d" $msgnum
116
+ echo ' '`git-rev-list --pretty=oneline -1 HEAD | \
117
sed 's/^[a-f0-9]\+ //'`
118
msgnum=$(($msgnum + 1))
119
done
@@ -322,11 +319,11 @@ for cmt in `git-rev-list --no-merges "$upstream"..ORIG_HEAD \
319
| perl -e 'print reverse <>'`
320
do
321
msgnum=$(($msgnum + 1))
325
- echo "$cmt" > "$dotest/`printf "%0${prec}d" $msgnum`"
322
+ echo "$cmt" > "$dotest/cmt.$msgnum"
323
done
324
328
-printf "%0${prec}d" 1 > "$dotest/msgnum"
329
-printf "%0${prec}d" "$msgnum" > "$dotest/end"
325
+echo 1 >"$dotest/msgnum"
326
+echo $msgnum >"$dotest/end"
327
328
end=$msgnum
329
msgnum=1