Skip to content

Commit 603d249

Browse files
René Scharfegitster
authored andcommitted
unpack-trees: don't shift conflicts left and right
If o->merge is set, the struct traverse_info member conflicts is shifted left in unpack_callback, then passed through traverse_trees_recursive to unpack_nondirectories, where it is shifted right before use. Stop the shifting and just pass the conflict bit mask as is. Rename the member to df_conflicts to prove that it isn't used anywhere else. Signed-off-by: René Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent edca415 commit 603d249

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
@@ -454,7 +454,7 @@ static int traverse_trees_recursive(int n, unsigned long dirmask,
454454
newinfo.pathspec = info->pathspec;
455455
newinfo.name = *p;
456456
newinfo.pathlen += tree_entry_len(p) + 1;
457-
newinfo.conflicts |= df_conflicts;
457+
newinfo.df_conflicts |= df_conflicts;
458458

459459
for (i = 0; i < n; i++, dirmask >>= 1) {
460460
const unsigned char *sha1 = NULL;
@@ -555,17 +555,12 @@ static int unpack_nondirectories(int n, unsigned long mask,
555555
{
556556
int i;
557557
struct unpack_trees_options *o = info->data;
558-
unsigned long conflicts;
558+
unsigned long conflicts = info->df_conflicts | dirmask;
559559

560560
/* Do we have *only* directories? Nothing to do */
561561
if (mask == dirmask && !src[0])
562562
return 0;
563563

564-
conflicts = info->conflicts;
565-
if (o->merge)
566-
conflicts >>= 1;
567-
conflicts |= dirmask;
568-
569564
/*
570565
* Ok, we've filled in up to any potential index entry in src[0],
571566
* now do the rest.
@@ -789,13 +784,6 @@ static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str
789784

790785
/* Now handle any directories.. */
791786
if (dirmask) {
792-
unsigned long conflicts = mask & ~dirmask;
793-
if (o->merge) {
794-
conflicts <<= 1;
795-
if (src[0])
796-
conflicts |= 1;
797-
}
798-
799787
/* special case: "diff-index --cached" looking at a tree */
800788
if (o->diff_index_cached &&
801789
n == 1 && dirmask == 1 && S_ISDIR(names->mode)) {
@@ -814,7 +802,7 @@ static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str
814802
}
815803
}
816804

817-
if (traverse_trees_recursive(n, dirmask, conflicts,
805+
if (traverse_trees_recursive(n, dirmask, mask & ~dirmask,
818806
names, info) < 0)
819807
return -1;
820808
return mask;

0 commit comments

Comments
 (0)