aboutsummaryrefslogtreecommitdiffstats
path: root/diff-lib.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-03-10 23:51:13 -0700
committerJunio C Hamano <gitster@pobox.com>2008-03-10 23:51:13 -0700
commit20a16eb33eee99fd3eab00c72f012b98d4eeee76 (patch)
tree6d02e3516df996f58f8f00b94ea9cf634f6701c8 /diff-lib.c
parent542c264b01ac551dca0697d6577ec71ad4c245ab (diff)
downloadgit-20a16eb33eee99fd3eab00c72f012b98d4eeee76.tar.gz
unpack_trees(): fix diff-index regression.
When skip_unmerged option is not given, unpack_trees() should not just skip unmerged cache entries but keep them in the result for the caller to sort them out. For callers other than diff-index, the incoming index should never be unmerged, but diff-index is a special case caller. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff-lib.c')
-rw-r--r--diff-lib.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/diff-lib.c b/diff-lib.c
index 9520773f3b..52dbac34a4 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -641,6 +641,21 @@ static void do_oneway_diff(struct unpack_trees_options *o,
show_modified(revs, tree, idx, 1, cached, match_missing);
}
+static inline void skip_same_name(struct cache_entry *ce, struct unpack_trees_options *o)
+{
+ int len = ce_namelen(ce);
+ const struct index_state *index = o->src_index;
+
+ while (o->pos < index->cache_nr) {
+ struct cache_entry *next = index->cache[o->pos];
+ if (len != ce_namelen(next))
+ break;
+ if (memcmp(ce->name, next->name, len))
+ break;
+ o->pos++;
+ }
+}
+
/*
* The unpack_trees() interface is designed for merging, so
* the different source entries are designed primarily for
@@ -662,6 +677,9 @@ static int oneway_diff(struct cache_entry **src, struct unpack_trees_options *o)
struct cache_entry *tree = src[1];
struct rev_info *revs = o->unpack_data;
+ if (idx && ce_stage(idx))
+ skip_same_name(idx, o);
+
/*
* Unpack-trees generates a DF/conflict entry if
* there was a directory in the index and a tree