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>
maint
parent
4d4bc41411
commit
a0262c51d0
16
ref-filter.c
16
ref-filter.c
|
@ -1513,20 +1513,20 @@ static enum contains_result contains_test(struct commit *candidate,
|
||||||
{
|
{
|
||||||
/* was it previously marked as containing a want commit? */
|
/* was it previously marked as containing a want commit? */
|
||||||
if (candidate->object.flags & TMP_MARK)
|
if (candidate->object.flags & TMP_MARK)
|
||||||
return 1;
|
return CONTAINS_YES;
|
||||||
/* or marked as not possibly containing a want commit? */
|
/* or marked as not possibly containing a want commit? */
|
||||||
if (candidate->object.flags & UNINTERESTING)
|
if (candidate->object.flags & UNINTERESTING)
|
||||||
return 0;
|
return CONTAINS_NO;
|
||||||
/* or are we it? */
|
/* or are we it? */
|
||||||
if (in_commit_list(want, candidate)) {
|
if (in_commit_list(want, candidate)) {
|
||||||
candidate->object.flags |= TMP_MARK;
|
candidate->object.flags |= TMP_MARK;
|
||||||
return 1;
|
return CONTAINS_YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parse_commit(candidate) < 0)
|
if (parse_commit(candidate) < 0)
|
||||||
return 0;
|
return CONTAINS_NO;
|
||||||
|
|
||||||
return -1;
|
return CONTAINS_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void push_to_contains_stack(struct commit *candidate, struct contains_stack *contains_stack)
|
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,
|
||||||
const struct commit_list *want)
|
const struct commit_list *want)
|
||||||
{
|
{
|
||||||
struct contains_stack contains_stack = { 0, 0, NULL };
|
struct contains_stack contains_stack = { 0, 0, NULL };
|
||||||
int result = contains_test(candidate, want);
|
enum contains_result result = contains_test(candidate, want);
|
||||||
|
|
||||||
if (result != CONTAINS_UNKNOWN)
|
if (result != CONTAINS_UNKNOWN)
|
||||||
return result;
|
return result;
|
||||||
|
@ -1557,7 +1557,7 @@ static enum contains_result contains_tag_algo(struct commit *candidate,
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* If we just popped the stack, parents->item has been marked,
|
* If we just popped the stack, parents->item has been marked,
|
||||||
* therefore contains_test will return a meaningful 0 or 1.
|
* therefore contains_test will return a meaningful yes/no.
|
||||||
*/
|
*/
|
||||||
else switch (contains_test(parents->item, want)) {
|
else switch (contains_test(parents->item, want)) {
|
||||||
case CONTAINS_YES:
|
case CONTAINS_YES:
|
||||||
|
@ -1579,7 +1579,7 @@ static enum contains_result contains_tag_algo(struct commit *candidate,
|
||||||
static int commit_contains(struct ref_filter *filter, struct commit *commit)
|
static int commit_contains(struct ref_filter *filter, struct commit *commit)
|
||||||
{
|
{
|
||||||
if (filter->with_commit_tag_algo)
|
if (filter->with_commit_tag_algo)
|
||||||
return contains_tag_algo(commit, filter->with_commit);
|
return contains_tag_algo(commit, filter->with_commit) == CONTAINS_YES;
|
||||||
return is_descendant_of(commit, filter->with_commit);
|
return is_descendant_of(commit, filter->with_commit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue