Re: [PATCH v2] refs: use skip_prefix() in ref_is_hidden()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Jul 22, 2017 at 06:39:12AM +0200, Christian Couder wrote:

> @@ -1175,10 +1175,9 @@ int ref_is_hidden(const char *refname, const char *refname_full)
>  		}
>  
>  		/* refname can be NULL when namespaces are used. */
> -		if (!subject || !starts_with(subject, match))
> -			continue;
> -		len = strlen(match);
> -		if (!subject[len] || subject[len] == '/')
> +		if (subject &&
> +		    skip_prefix(subject, match, &p) &&
> +		    (!*p || *p == '/'))
>  			return !neg;

This looks good to me.

I seem to recall running across a similar pattern elsewhere, where a
caller wanted either an exact match, or a match ending with a particular
character. We could add one more helper like:

  if (subject && skip_prefix_with_sep(subject, match, '/', &p))
	return !neg;

But I don't offhand recall where that other place was, and it's not like
it's saving a huge amount of complexity in the caller. So I'll file it
away in the back of my mind and see if it comes up a third time. ;)

-Peff



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux