Re: [PATCH] fetch: use skip_prefix() instead of starts_with()

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

 



On Tue, Nov 26, 2019 at 12:18:26PM +0100, René Scharfe wrote:

> diff --git a/builtin/fetch.c b/builtin/fetch.c
> index 863c858fde..02e8619618 100644
> --- a/builtin/fetch.c
> +++ b/builtin/fetch.c
> @@ -954,18 +954,12 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
>  				kind = "";
>  				what = "";
>  			}
> -			else if (starts_with(rm->name, "refs/heads/")) {
> +			else if (skip_prefix(rm->name, "refs/heads/", &what))
>  				kind = "branch";
> -				what = rm->name + 11;
> -			}
> -			else if (starts_with(rm->name, "refs/tags/")) {
> +			else if (skip_prefix(rm->name, "refs/tags/", &what))
>  				kind = "tag";
> -				what = rm->name + 10;
> -			}
> -			else if (starts_with(rm->name, "refs/remotes/")) {
> +			else if (skip_prefix(rm->name, "refs/remotes/", &what))
>  				kind = "remote-tracking branch";
> -				what = rm->name + 13;
> -			}
>  			else {

Yep, this one looks obviously correct. We were already mutating "what",
so this just does it inside skip_prefix(). Much nicer.

-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