Skip to content

Commit

Permalink
traverse_trees(): clarify return value of the callback
Browse files Browse the repository at this point in the history
The variable name "ret" sounds like the variable to be returned, but
since e6c111b we return error, and it is misleading.

As this variable tells us which trees in t[] array were used in the
callback function, so that this caller can know the entries in which
of the trees need advancing, "trees_used" is a better name.

Also the assignment to 0 was removed at the start of the function as
well after the "if (interesting)" block.  Those are unneeded as that
variable is set to the callback return value any time we enter the
"if (interesting)" block, so we'd overwrite old values anyway.

Signed-off-by: Stefan Beller <stefanbeller@googlemail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Stefan Beller authored and Junio C Hamano committed Jul 19, 2013
1 parent edca415 commit a04f819
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions tree-walk.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,6 @@ static inline int prune_traversal(struct name_entry *e,

int traverse_trees(int n, struct tree_desc *t, struct traverse_info *info)
{
int ret = 0;
int error = 0;
struct name_entry *entry = xmalloc(n*sizeof(*entry));
int i;
Expand All @@ -341,6 +340,7 @@ int traverse_trees(int n, struct tree_desc *t, struct traverse_info *info)
strbuf_setlen(&base, info->pathlen);
}
for (;;) {
int trees_used;
unsigned long mask, dirmask;
const char *first = NULL;
int first_len = 0;
Expand Down Expand Up @@ -404,15 +404,14 @@ int traverse_trees(int n, struct tree_desc *t, struct traverse_info *info)
if (interesting < 0)
break;
if (interesting) {
ret = info->fn(n, mask, dirmask, entry, info);
if (ret < 0) {
error = ret;
trees_used = info->fn(n, mask, dirmask, entry, info);
if (trees_used < 0) {
error = trees_used;
if (!info->show_all_errors)
break;
}
mask &= ret;
mask &= trees_used;
}
ret = 0;
for (i = 0; i < n; i++)
if (mask & (1ul << i))
update_extended_entry(tx + i, entry + i);
Expand Down

0 comments on commit a04f819

Please sign in to comment.