From: Thomas Rast <trast@student.ethz.ch>
To: <git@vger.kernel.org>
Cc: Jeff King <peff@peff.net>, Junio C Hamano <gitster@pobox.com>,
Laine Walker-Avina <lwalkera@pasco.com>
Subject: [PATCH] cherry_pick_list: quit early if one side is empty
Date: Sat, 20 Feb 2010 12:42:04 +0100 [thread overview]
Message-ID: <a39e9a6e6f043121568de106f41f5b01eb38a200.1266665083.git.trast@student.ethz.ch> (raw)
In-Reply-To: <20100220072728.GA12168@coredump.intra.peff.net>
The --cherry-pick logic starts by counting the commits on each side,
so that it can filter away commits on the bigger one. However, so
far it missed an opportunity for optimization: it doesn't need to do
any work if either side is empty.
This in particular helps the common use-case 'git rebase -i HEAD~$n':
it internally uses --cherry-pick, but since HEAD~$n is a direct
ancestor the left side is always empty.
Signed-off-by: Thomas Rast <trast@student.ethz.ch>
---
On Saturday 20 February 2010 08:27:28 Jeff King wrote:
>
> From my reading of the code, that is right, but this is the first time I
> ever looked at it, so who knows? :)
Junio agreed too, so here's a real patch. To keep the complexity of
git-rebase--interactive from exploding even further, you can drop the
earlier one.
> Does it really make sense to treat binary files as anything other than a
> blob for generating patch id? That is, should we simply turn it into:
>
> binary diff
> $from_sha1
> $to_sha1
>
> and hash that for the patch id?
I tend to agree, but I can't seem to find out what flags to flip :-(
revision.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/revision.c b/revision.c
index 438cc87..29721ec 100644
--- a/revision.c
+++ b/revision.c
@@ -547,6 +547,9 @@ static void cherry_pick_list(struct commit_list *list, struct rev_info *revs)
right_count++;
}
+ if (!left_count || !right_count)
+ return;
+
left_first = left_count < right_count;
init_patch_ids(&ids);
if (revs->diffopt.nr_paths) {
--
1.7.0.139.gd1a75.dirty
next prev parent reply other threads:[~2010-02-20 11:42 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 ` [PATCH] rebase -i: avoid --cherry-pick when rebasing to a direct ancestor Thomas Rast
2010-02-20 0:02 ` Thomas Rast
2010-02-20 7:27 ` Jeff King
2010-02-20 11:42 ` Thomas Rast [this message]
2010-02-21 6:50 ` [PATCH] cherry_pick_list: quit early if one side is empty 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=a39e9a6e6f043121568de106f41f5b01eb38a200.1266665083.git.trast@student.ethz.ch \
--to=trast@student.ethz.ch \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=lwalkera@pasco.com \
--cc=peff@peff.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.
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).