Skip to content

Commit a0262c5

Browse files
peffgitster
authored andcommitted
ref-filter: use contains_result enum consistently
Commit cbc60b6 (git tag --contains: avoid stack overflow, 2014-04-24) adapted the -1/0/1 contains status into a tri-state enum. However, some of the code still used the numeric values, or assumed that no/yes correspond to C's boolean true/false. Let's switch to using the symbolic values everywhere, which will make it easier to change them. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 4d4bc41 commit a0262c5

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

ref-filter.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1513,20 +1513,20 @@ static enum contains_result contains_test(struct commit *candidate,
15131513
{
15141514
/* was it previously marked as containing a want commit? */
15151515
if (candidate->object.flags & TMP_MARK)
1516-
return 1;
1516+
return CONTAINS_YES;
15171517
/* or marked as not possibly containing a want commit? */
15181518
if (candidate->object.flags & UNINTERESTING)
1519-
return 0;
1519+
return CONTAINS_NO;
15201520
/* or are we it? */
15211521
if (in_commit_list(want, candidate)) {
15221522
candidate->object.flags |= TMP_MARK;
1523-
return 1;
1523+
return CONTAINS_YES;
15241524
}
15251525

15261526
if (parse_commit(candidate) < 0)
1527-
return 0;
1527+
return CONTAINS_NO;
15281528

1529-
return -1;
1529+
return CONTAINS_UNKNOWN;
15301530
}
15311531

15321532
static void push_to_contains_stack(struct commit *candidate, struct contains_stack *contains_stack)
@@ -1540,7 +1540,7 @@ static enum contains_result contains_tag_algo(struct commit *candidate,
15401540
const struct commit_list *want)
15411541
{
15421542
struct contains_stack contains_stack = { 0, 0, NULL };
1543-
int result = contains_test(candidate, want);
1543+
enum contains_result result = contains_test(candidate, want);
15441544

15451545
if (result != CONTAINS_UNKNOWN)
15461546
return result;
@@ -1557,7 +1557,7 @@ static enum contains_result contains_tag_algo(struct commit *candidate,
15571557
}
15581558
/*
15591559
* If we just popped the stack, parents->item has been marked,
1560-
* therefore contains_test will return a meaningful 0 or 1.
1560+
* therefore contains_test will return a meaningful yes/no.
15611561
*/
15621562
else switch (contains_test(parents->item, want)) {
15631563
case CONTAINS_YES:
@@ -1579,7 +1579,7 @@ static enum contains_result contains_tag_algo(struct commit *candidate,
15791579
static int commit_contains(struct ref_filter *filter, struct commit *commit)
15801580
{
15811581
if (filter->with_commit_tag_algo)
1582-
return contains_tag_algo(commit, filter->with_commit);
1582+
return contains_tag_algo(commit, filter->with_commit) == CONTAINS_YES;
15831583
return is_descendant_of(commit, filter->with_commit);
15841584
}
15851585

0 commit comments

Comments
 (0)