@matheusbsbs / matheus-bagliano / commits / 91e4f03604
Fork 0

Make 'traverse_trees()' traverse conflicting DF entries in parallel

This makes the traverse_trees() entry comparator routine use the more relaxed form of name comparison that considers files and directories with the same name identical. We pass in a separate mask for just the directory entries, so that the callback routine can decide (if it wants to) to only handle one or the other type, but generally most (all?) users are expected to really want to see the case of a name 'foo' showing up in one tree as a file and in another as a directory at the same time. In particular, moving 'unpack_trees()' over to use this tree traversal mechanism requires this. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Linus Torvalds committed Mar 5, 2008 at 20:06 UTC 91e4f03604bd089e09154e95294d5d08c805ea49
3 files changed +9 -4
merge-tree.c
+1 -1
@@ -287,7 +287,7 @@ static void unresolved(const struct traverse_info *info, struct name_entry n[3])
287 * The successful merge rules are the same as for the three-way merge
288 * in git-read-tree.
289 */
290 -static int threeway_callback(int n, unsigned long mask, struct name_entry *entry, struct traverse_info *info)
290 +static int threeway_callback(int n, unsigned long mask, unsigned long dirmask, struct name_entry *entry, struct traverse_info *info)
291 {
292 /* Same in both? */
293 if (same_entry(entry+1, entry+2)) {
tree-walk.c
+6 -2
@@ -62,7 +62,7 @@ void *fill_tree_descriptor(struct tree_desc *desc, const unsigned char *sha1)
62
63 static int entry_compare(struct name_entry *a, struct name_entry *b)
64 {
65 - return base_name_compare(
65 + return df_name_compare(
66 a->path, tree_entry_len(a->path, a->sha1), a->mode,
67 b->path, tree_entry_len(b->path, b->sha1), b->mode);
68 }
@@ -142,6 +142,7 @@ int traverse_trees(int n, struct tree_desc *t, struct traverse_info *info)
142
143 for (;;) {
144 unsigned long mask = 0;
145 + unsigned long dirmask = 0;
146 int i, last;
147
148 last = -1;
@@ -166,10 +167,13 @@ int traverse_trees(int n, struct tree_desc *t, struct traverse_info *info)
167 mask = 0;
168 }
169 mask |= 1ul << i;
170 + if (S_ISDIR(entry[i].mode))
171 + dirmask |= 1ul << i;
172 last = i;
173 }
174 if (!mask)
175 break;
176 + dirmask &= mask;
177
178 /*
179 * Clear all the unused name-entries.
@@ -179,7 +183,7 @@ int traverse_trees(int n, struct tree_desc *t, struct traverse_info *info)
183 continue;
184 entry_clear(entry + i);
185 }
182 - ret = info->fn(n, mask, entry, info);
186 + ret = info->fn(n, mask, dirmask, entry, info);
187 if (ret < 0)
188 break;
189 if (ret)
tree-walk.h
+2 -1
@@ -34,7 +34,7 @@ int tree_entry(struct tree_desc *, struct name_entry *);
34 void *fill_tree_descriptor(struct tree_desc *desc, const unsigned char *sha1);
35
36 struct traverse_info;
37 -typedef int (*traverse_callback_t)(int n, unsigned long mask, struct name_entry *entry, struct traverse_info *);
37 +typedef int (*traverse_callback_t)(int n, unsigned long mask, unsigned long dirmask, struct name_entry *entry, struct traverse_info *);
38 int traverse_trees(int n, struct tree_desc *t, struct traverse_info *info);
39
40 struct traverse_info {
@@ -42,6 +42,7 @@ struct traverse_info {
42 struct name_entry name;
43 int pathlen;
44
45 + unsigned long conflicts;
46 traverse_callback_t fn;
47 void *data;
48 };