Re: [PATCH 2/2] builtin/fetch.c: ignore merge config when not fetching from branch's remote

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

 



Brandon Casey <casey@xxxxxxxxxxxxxxx> writes:

> diff --git a/builtin/fetch.c b/builtin/fetch.c
> index ea14d5d..be6c27a 100644
> --- a/builtin/fetch.c
> +++ b/builtin/fetch.c
> @@ -146,7 +146,8 @@ static struct ref *get_ref_map(struct transport *transport,
>  		struct remote *remote = transport->remote;
>  		struct branch *branch = branch_get(NULL);
>  		int has_merge = branch_has_merge_config(branch);
> -		if (remote && (remote->fetch_refspec_nr || has_merge)) {
> +		if (remote && (remote->fetch_refspec_nr || (has_merge &&
> +				!strcmp(branch->remote_name, remote->name)))) {

Couldn't branch->remote_name or remote->name be NULL here?

I think remote->name would be the same as the URL given on the command
line (i.e. no risk of being NULL), and has_merge would be false even when
branch.<name>.merge is specified if branch.<name>.remote is missing
(i.e. no risk of running this strcmp() to begin with), but the latter
safety guarantee is a bit too subtle for my taste to go without a in-code
comment.

Thanks.




--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[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]