Re: [PATCH 10/19] tree_entry_interesting(): factor out most matching logic
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Dec 13, 2010, 18:10 UTC
- Message-ID
- <7vfwu135og.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <1292233616-27692-11-git-send-email-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
Show 12 quoted lines
> diff --git a/tree-walk.c b/tree-walk.c
> index 01168ea..40a4657 100644
> --- a/tree-walk.c
> +++ b/tree-walk.c
> @@ -481,88 +566,21 @@ int tree_entry_interesting(const struct name_entry *entry,
> for (i = 0; i < ps->nr; i++) {
> const char *match = ps->raw[i];
> int matchlen = ps->items[i].len;
> - int m = -1; /* signals that we haven't called strncmp() */
>
> if (baselen >= matchlen) {
> - /* If it doesn't match, move along... */Why lose this comment? That is exactly what this simplified part is about. If match-dir-prefix says it doesn't match, we move along.
Keep this comment here, and drop the one you copied to the beginning of match-dir-prefix, which is not about "moving along" anymore. The function is about deciding if they match or not.
> - if (strncmp(base, match, matchlen)) > + if (!match_dir_prefix(base, baselen, match, matchlen)) > + /* Just a random prefix match */ > continue;
This comment no longer holds true, even though the same comment at the end of match-dir-prefix function is correct. This should probably say "does not match", but that is something you already said.
Other than that, this is a very nice refactoring.