Re: [PATCH] push: 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 04:18:28PM +0100, René Scharfe wrote:

> diff --git a/builtin/push.c b/builtin/push.c
> index 843f5b22a2..6dbf0f0bb7 100644
> --- a/builtin/push.c
> +++ b/builtin/push.c
> @@ -64,6 +64,7 @@ static struct string_list push_options_config = STRING_LIST_INIT_DUP;
>  static const char *map_refspec(const char *ref,
>  			       struct remote *remote, struct ref *local_refs)
>  {
> +	const char *branch_name;
>  	struct ref *matched = NULL;
> 
>  	/* Does "ref" uniquely name our ref? */
> @@ -84,8 +85,8 @@ static const char *map_refspec(const char *ref,
>  	}
> 
>  	if (push_default == PUSH_DEFAULT_UPSTREAM &&
> -	    starts_with(matched->name, "refs/heads/")) {
> -		struct branch *branch = branch_get(matched->name + 11);
> +	    skip_prefix(matched->name, "refs/heads/", &branch_name)) {
> +		struct branch *branch = branch_get(branch_name);

Yep, obviously correct because you introduce a new variable instead of
mutating an existing one. Looks good.

-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