diff-lib: simplify do_diff_cache()
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>
Junio C Hamano committed
Jul 13, 2011 at 18:42 UTC
fe549c21fc3d99b9ff66f03d192f955400c80191
1 file changed
+1
-25
diff-lib.c
+1
-25
@@ -480,33 +480,9 @@ int do_diff_cache(const unsigned char *tree_sha1, struct diff_options *opt)
480
{
481
struct tree *tree;
482
struct rev_info revs;
483
- int i;
484
- struct cache_entry **dst;
485
- struct cache_entry *last = NULL;
483
struct unpack_trees_options opts;
484
struct tree_desc t;
485
489
- /*
490
- * This is used by git-blame to run diff-cache internally;
491
- * it potentially needs to repeatedly run this, so we will
492
- * start by removing the higher order entries the last round
493
- * left behind.
494
- */
495
- dst = active_cache;
496
- for (i = 0; i < active_nr; i++) {
497
- struct cache_entry *ce = active_cache[i];
498
- if (ce_stage(ce)) {
499
- if (last && !strcmp(ce->name, last->name))
500
- continue;
501
- cache_tree_invalidate_path(active_cache_tree,
502
- ce->name);
503
- last = ce;
504
- ce->ce_flags |= CE_REMOVE;
505
- }
506
- *dst++ = ce;
507
- }
508
- active_nr = dst - active_cache;
509
-
486
init_revisions(&revs, NULL);
487
init_pathspec(&revs.prune_data, opt->pathspec.raw);
488
tree = parse_tree_indirect(tree_sha1);
@@ -521,7 +497,7 @@ int do_diff_cache(const unsigned char *tree_sha1, struct diff_options *opt)
497
opts.fn = oneway_diff;
498
opts.unpack_data = &revs;
499
opts.src_index = &the_index;
524
- opts.dst_index = &the_index;
500
+ opts.dst_index = NULL;
501
502
init_tree_desc(&t, tree->buffer, tree->size);
503
if (unpack_trees(1, &t, &opts))