From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: [PATCH 1/2] diff-lib: simplify do_diff_cache()
Date: Tue, 19 Jul 2011 11:13:05 -0700 [thread overview]
Message-ID: <1311099186-16482-2-git-send-email-gitster@pobox.com> (raw)
In-Reply-To: <1311099186-16482-1-git-send-email-gitster@pobox.com>
Since 34110cd (Make 'unpack_trees()' have a separate source and
destination index, 2008-03-06), we can run unpack_trees() without munging
the index at all, but do_diff_cache() tried ever so carefully to work
around the old behaviour of the function.
We can just tell unpack_trees() not to touch the original index and there
is no need to clean-up whatever the previous round has done.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
diff-lib.c | 26 +-------------------------
1 files changed, 1 insertions(+), 25 deletions(-)
diff --git a/diff-lib.c b/diff-lib.c
index fd61acb..b5bb58d 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -480,33 +480,9 @@ int do_diff_cache(const unsigned char *tree_sha1, struct diff_options *opt)
{
struct tree *tree;
struct rev_info revs;
- int i;
- struct cache_entry **dst;
- struct cache_entry *last = NULL;
struct unpack_trees_options opts;
struct tree_desc t;
- /*
- * This is used by git-blame to run diff-cache internally;
- * it potentially needs to repeatedly run this, so we will
- * start by removing the higher order entries the last round
- * left behind.
- */
- dst = active_cache;
- for (i = 0; i < active_nr; i++) {
- struct cache_entry *ce = active_cache[i];
- if (ce_stage(ce)) {
- if (last && !strcmp(ce->name, last->name))
- continue;
- cache_tree_invalidate_path(active_cache_tree,
- ce->name);
- last = ce;
- ce->ce_flags |= CE_REMOVE;
- }
- *dst++ = ce;
- }
- active_nr = dst - active_cache;
-
init_revisions(&revs, NULL);
init_pathspec(&revs.prune_data, opt->pathspec.raw);
tree = parse_tree_indirect(tree_sha1);
@@ -521,7 +497,7 @@ int do_diff_cache(const unsigned char *tree_sha1, struct diff_options *opt)
opts.fn = oneway_diff;
opts.unpack_data = &revs;
opts.src_index = &the_index;
- opts.dst_index = &the_index;
+ opts.dst_index = NULL;
init_tree_desc(&t, tree->buffer, tree->size);
if (unpack_trees(1, &t, &opts))
--
1.7.6.178.g55272
next prev parent reply other threads:[~2011-07-19 18:13 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-10 22:30 reproducible unexpected behavior for 'git reset' John Nowak
2011-07-11 21:54 ` Junio C Hamano
2011-07-11 22:41 ` Junio C Hamano
2011-07-14 6:01 ` Junio C Hamano
2011-07-19 18:13 ` [PATCH 0/2] refactoring diff-index Junio C Hamano
2011-07-19 18:13 ` Junio C Hamano [this message]
2011-07-19 20:14 ` [PATCH 1/2] diff-lib: simplify do_diff_cache() Jeff King
2011-07-19 21:28 ` Junio C Hamano
2011-07-19 18:13 ` [PATCH 2/2] diff-lib: refactor run_diff_index() and do_diff_cache() Junio C Hamano
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=1311099186-16482-2-git-send-email-gitster@pobox.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
/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).