diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2011-10-24 17:36:10 +1100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-10-27 11:38:24 -0700 |
commit | d688cf07b15b664a2164c3d92bcb5e8265400a2b (patch) | |
tree | e00f6633f9938ef2808bd2c25f71938b805f198a /builtin/grep.c | |
parent | 02cb67530e62e77d437cd68b4bb4307ab752b6a0 (diff) | |
download | git-d688cf07b15b664a2164c3d92bcb5e8265400a2b.tar.gz git-d688cf07b15b664a2164c3d92bcb5e8265400a2b.tar.xz |
tree_entry_interesting(): give meaningful names to return values
It is a basic code hygiene to avoid magic constants that are unnamed.
Besides, this helps extending the value later on for "interesting, but
cannot decide if the entry truely matches yet" (ie. prefix matches)
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/grep.c')
-rw-r--r-- | builtin/grep.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/builtin/grep.c b/builtin/grep.c index 2cd06126d..2fc51fa2d 100644 --- a/builtin/grep.c +++ b/builtin/grep.c @@ -542,18 +542,19 @@ static int grep_cache(struct grep_opt *opt, const struct pathspec *pathspec, int static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec, struct tree_desc *tree, struct strbuf *base, int tn_len) { - int hit = 0, match = 0; + int hit = 0; + enum interesting match = entry_not_interesting; struct name_entry entry; int old_baselen = base->len; while (tree_entry(tree, &entry)) { int te_len = tree_entry_len(&entry); - if (match != 2) { + if (match != all_entries_interesting) { match = tree_entry_interesting(&entry, base, tn_len, pathspec); - if (match < 0) + if (match == all_entries_not_interesting) break; - if (match == 0) + if (match == entry_not_interesting) continue; } |