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 <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
René Scharfe committed
Jun 16, 2013 at 01:44 UTC
603d249853981d81d1f8cf561b18d77cb1b55923
2 files changed
+4
-16
tree-walk.h
+1
-1
@@ -46,7 +46,7 @@ struct traverse_info {
46
int pathlen;
47
struct pathspec *pathspec;
48
49
- unsigned long conflicts;
49
+ unsigned long df_conflicts;
50
traverse_callback_t fn;
51
void *data;
52
int show_all_errors;
unpack-trees.c
+3
-15
@@ -454,7 +454,7 @@ static int traverse_trees_recursive(int n, unsigned long dirmask,
454
newinfo.pathspec = info->pathspec;
455
newinfo.name = *p;
456
newinfo.pathlen += tree_entry_len(p) + 1;
457
- newinfo.conflicts |= df_conflicts;
457
+ newinfo.df_conflicts |= df_conflicts;
458
459
for (i = 0; i < n; i++, dirmask >>= 1) {
460
const unsigned char *sha1 = NULL;
@@ -555,17 +555,12 @@ static int unpack_nondirectories(int n, unsigned long mask,
555
{
556
int i;
557
struct unpack_trees_options *o = info->data;
558
- unsigned long conflicts;
558
+ unsigned long conflicts = info->df_conflicts | dirmask;
559
560
/* Do we have *only* directories? Nothing to do */
561
if (mask == dirmask && !src[0])
562
return 0;
563
564
- conflicts = info->conflicts;
565
- if (o->merge)
566
- conflicts >>= 1;
567
- conflicts |= dirmask;
568
-
564
/*
565
* Ok, we've filled in up to any potential index entry in src[0],
566
* now do the rest.
@@ -789,13 +784,6 @@ static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str
784
785
/* Now handle any directories.. */
786
if (dirmask) {
792
- unsigned long conflicts = mask & ~dirmask;
793
- if (o->merge) {
794
- conflicts <<= 1;
795
- if (src[0])
796
- conflicts |= 1;
797
- }
798
-
787
/* special case: "diff-index --cached" looking at a tree */
788
if (o->diff_index_cached &&
789
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
802
}
803
}
804
817
- if (traverse_trees_recursive(n, dirmask, conflicts,
805
+ if (traverse_trees_recursive(n, dirmask, mask & ~dirmask,
806
names, info) < 0)
807
return -1;
808
return mask;