From: Thomas Rast <trast@student.ethz.ch>
To: <git@vger.kernel.org>
Cc: Junio C Hamano <gitster@pobox.com>,
Laine Walker-Avina <lwalkera@pasco.com>
Subject: [PATCH] rebase -i: avoid --cherry-pick when rebasing to a direct ancestor
Date: Sat, 20 Feb 2010 00:30:52 +0100 [thread overview]
Message-ID: <d1a75633daa062b25527dfb0675673480974c940.1266620423.git.trast@student.ethz.ch> (raw)
In-Reply-To: <dfb660301002191324i7aeca7f5x990501bbca1475a9@mail.gmail.com>
Ordinary 'rebase -i' reads the commits to rebase with (roughly)
git rev-list --left-right --cherry-pick $upstream...
which gives it the feature of skipping commits that are already
present in $upstream. However, in the common use-case of rewriting a
few commits up to an ancestor, as in 'git rebase -i HEAD~3', the
--cherry-pick is useless since there are no commits to compare to.
Add a check if $upstream is a direct ancestor of HEAD, and leave away
the --cherry-pick if so. Since the --cherry-pick is already in
$MERGES_OPTION, we need to decide this before setting the latter.
For simplicity we skip --root mode. In theory we could do the same
optimization, but using --root --onto <ancestor> is probably even more
rare than having performance issues with --cherry-pick.
Signed-off-by: Thomas Rast <trast@student.ethz.ch>
---
The --cherry-pick mechanism itself could get a similar optimization,
but I don't know that code.
git-rebase--interactive.sh | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 1fda620..10b0ed8 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -870,7 +870,12 @@ first and then run 'git rebase --continue' again."
MERGES_OPTION=
first_after_upstream="$(git rev-list --reverse --first-parent $UPSTREAM..$HEAD | head -n 1)"
else
- MERGES_OPTION="--no-merges --cherry-pick"
+ if test -z "$REBASE_ROOT" &&
+ test $(git merge-base $UPSTREAM $HEAD) = $UPSTREAM; then
+ MERGES_OPTION="--no-merges"
+ else
+ MERGES_OPTION="--no-merges --cherry-pick"
+ fi
fi
SHORTHEAD=$(git rev-parse --short $HEAD)
--
1.7.0.139.gd1a75
next prev parent reply other threads:[~2010-02-19 23:31 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-19 21:24 Git has bad performance when traversing change-sets with large PPM files Laine Walker-Avina
2010-02-19 23:30 ` Thomas Rast [this message]
2010-02-20 0:02 ` [PATCH] rebase -i: avoid --cherry-pick when rebasing to a direct ancestor Thomas Rast
2010-02-20 7:27 ` Jeff King
2010-02-20 11:42 ` [PATCH] cherry_pick_list: quit early if one side is empty Thomas Rast
2010-02-21 6:50 ` Jeff King
2010-02-20 13:38 ` [PATCH] rebase -i: avoid --cherry-pick when rebasing to a direct ancestor Thomas Rast
2010-02-21 7:46 ` Jeff King
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d1a75633daa062b25527dfb0675673480974c940.1266620423.git.trast@student.ethz.ch \
--to=trast@student.ethz.ch \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=lwalkera@pasco.com \
/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.
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 NNTP newsgroup(s).