Skip to content

Commit bd21822

Browse files
committed
Merge branch 'rs/unpack-trees-tree-walk-conflict-field'
Code clean-up. * rs/unpack-trees-tree-walk-conflict-field: unpack-trees: don't shift conflicts left and right
2 parents bc918ac + 603d249 commit bd21822

File tree

2 files changed

+4
-16
lines changed

2 files changed

+4
-16
lines changed

tree-walk.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ struct traverse_info {
4646
int pathlen;
4747
struct pathspec *pathspec;
4848

49-
unsigned long conflicts;
49+
unsigned long df_conflicts;
5050
traverse_callback_t fn;
5151
void *data;
5252
int show_all_errors;

unpack-trees.c

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ static int traverse_trees_recursive(int n, unsigned long dirmask,
464464
newinfo.pathspec = info->pathspec;
465465
newinfo.name = *p;
466466
newinfo.pathlen += tree_entry_len(p) + 1;
467-
newinfo.conflicts |= df_conflicts;
467+
newinfo.df_conflicts |= df_conflicts;
468468

469469
for (i = 0; i < n; i++, dirmask >>= 1) {
470470
const unsigned char *sha1 = NULL;
@@ -565,17 +565,12 @@ static int unpack_nondirectories(int n, unsigned long mask,
565565
{
566566
int i;
567567
struct unpack_trees_options *o = info->data;
568-
unsigned long conflicts;
568+
unsigned long conflicts = info->df_conflicts | dirmask;
569569

570570
/* Do we have *only* directories? Nothing to do */
571571
if (mask == dirmask && !src[0])
572572
return 0;
573573

574-
conflicts = info->conflicts;
575-
if (o->merge)
576-
conflicts >>= 1;
577-
conflicts |= dirmask;
578-
579574
/*
580575
* Ok, we've filled in up to any potential index entry in src[0],
581576
* now do the rest.
@@ -807,13 +802,6 @@ static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str
807802

808803
/* Now handle any directories.. */
809804
if (dirmask) {
810-
unsigned long conflicts = mask & ~dirmask;
811-
if (o->merge) {
812-
conflicts <<= 1;
813-
if (src[0])
814-
conflicts |= 1;
815-
}
816-
817805
/* special case: "diff-index --cached" looking at a tree */
818806
if (o->diff_index_cached &&
819807
n == 1 && dirmask == 1 && S_ISDIR(names->mode)) {
@@ -832,7 +820,7 @@ static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str
832820
}
833821
}
834822

835-
if (traverse_trees_recursive(n, dirmask, conflicts,
823+
if (traverse_trees_recursive(n, dirmask, mask & ~dirmask,
836824
names, info) < 0)
837825
return -1;
838826
return mask;

0 commit comments

Comments
 (0)