ref-filter: use contains_result enum consistently

Commit cbc60b672 (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>

Jeff King committed Mar 9, 2017 at 08:28 UTC a0262c51d0f36678a8c6143a9c73d2058fd6ad57
1 file changed +8 -8
ref-filter.c
+8 -8
@@ -1513,20 +1513,20 @@ static enum contains_result contains_test(struct commit *candidate,
1513 {
1514 /* was it previously marked as containing a want commit? */
1515 if (candidate->object.flags & TMP_MARK)
1516 - return 1;
1516 + return CONTAINS_YES;
1517 /* or marked as not possibly containing a want commit? */
1518 if (candidate->object.flags & UNINTERESTING)
1519 - return 0;
1519 + return CONTAINS_NO;
1520 /* or are we it? */
1521 if (in_commit_list(want, candidate)) {
1522 candidate->object.flags |= TMP_MARK;
1523 - return 1;
1523 + return CONTAINS_YES;
1524 }
1525
1526 if (parse_commit(candidate) < 0)
1527 - return 0;
1527 + return CONTAINS_NO;
1528
1529 - return -1;
1529 + return CONTAINS_UNKNOWN;
1530 }
1531
1532 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,
1540 const struct commit_list *want)
1541 {
1542 struct contains_stack contains_stack = { 0, 0, NULL };
1543 - int result = contains_test(candidate, want);
1543 + enum contains_result result = contains_test(candidate, want);
1544
1545 if (result != CONTAINS_UNKNOWN)
1546 return result;
@@ -1557,7 +1557,7 @@ static enum contains_result contains_tag_algo(struct commit *candidate,
1557 }
1558 /*
1559 * 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.
1561 */
1562 else switch (contains_test(parents->item, want)) {
1563 case CONTAINS_YES:
@@ -1579,7 +1579,7 @@ static enum contains_result contains_tag_algo(struct commit *candidate,
1579 static int commit_contains(struct ref_filter *filter, struct commit *commit)
1580 {
1581 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;
1583 return is_descendant_of(commit, filter->with_commit);
1584 }
1585