Skip to content

Commit 20a16eb

Browse files
torvaldsgitster
authored andcommitted
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>
1 parent 542c264 commit 20a16eb

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

diff-lib.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,21 @@ static void do_oneway_diff(struct unpack_trees_options *o,
641641
show_modified(revs, tree, idx, 1, cached, match_missing);
642642
}
643643

644+
static inline void skip_same_name(struct cache_entry *ce, struct unpack_trees_options *o)
645+
{
646+
int len = ce_namelen(ce);
647+
const struct index_state *index = o->src_index;
648+
649+
while (o->pos < index->cache_nr) {
650+
struct cache_entry *next = index->cache[o->pos];
651+
if (len != ce_namelen(next))
652+
break;
653+
if (memcmp(ce->name, next->name, len))
654+
break;
655+
o->pos++;
656+
}
657+
}
658+
644659
/*
645660
* The unpack_trees() interface is designed for merging, so
646661
* 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)
662677
struct cache_entry *tree = src[1];
663678
struct rev_info *revs = o->unpack_data;
664679

680+
if (idx && ce_stage(idx))
681+
skip_same_name(idx, o);
682+
665683
/*
666684
* Unpack-trees generates a DF/conflict entry if
667685
* there was a directory in the index and a tree

unpack-trees.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ static int unpack_index_entry(struct cache_entry *ce, struct unpack_trees_option
116116
add_entry(o, ce, 0, 0);
117117
return 0;
118118
}
119-
return 0;
120119
}
121120
return call_unpack_fn(src, o);
122121
}
@@ -286,7 +285,6 @@ static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str
286285
add_entry(o, ce, 0, 0);
287286
return mask;
288287
}
289-
continue;
290288
}
291289
src[0] = ce;
292290
}

0 commit comments

Comments
 (0)