From: Junio C Hamano <junkio@cox.net>
To: Eric Wong <normalperson@yhbt.net>
Cc: git@vger.kernel.org
Subject: [PATCH] rebase --merge: fix for rebasing more than 7 commits.
Date: Thu, 22 Jun 2006 01:44:54 -0700 [thread overview]
Message-ID: <7vy7vptw8p.fsf@assigned-by-dhcp.cox.net> (raw)
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>
---
* 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
next reply other threads:[~2006-06-22 8:45 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-06-22 8:44 Junio C Hamano [this message]
2006-06-22 8:54 ` [PATCH] rebase --merge: fix for rebasing more than 7 commits Junio C Hamano
2006-06-22 11:09 ` Eric Wong
2006-06-24 7:09 ` Junio C Hamano
2006-06-25 1:29 ` [PATCH 0/3] rebase --merge improvements and fixes Eric Wong
2006-06-25 1:29 ` [PATCH 1/3] rebase: allow --merge option to handle patches merged upstream Eric Wong
2006-06-25 2:04 ` Johannes Schindelin
2006-06-25 4:59 ` Eric Wong
2006-06-25 1:29 ` [PATCH 2/3] rebase: cleanup rebasing with --merge Eric Wong
2006-06-25 1:29 ` [PATCH 3/3] rebase: allow --skip to work " Eric Wong
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7vy7vptw8p.fsf@assigned-by-dhcp.cox.net \
--to=junkio@cox.net \
--cc=git@vger.kernel.org \
--cc=normalperson@yhbt.net \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).