git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 25, 2010, 21:54 UTC
Message-ID
<7vtymipddv.fsf@alter.siamese.dyndns.org>
In-Reply-To
<O7UxM6KEqdDAhjJAF7ODSlo_kZavb8gBCJ6laH3QPOlG9a1q29koMQOkS7wDMj0BpyrLYfAcEh4@cipher.nrlssc.navy.mil>
Brandon Casey <casey@nrlssc.navy.mil> writes:
Show 11 quoted lines
> 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.
Previous: Brandon CaseyNext: Brandon Casey
Message 11 of 13 in “reducing object store size with remote alternates or shallow clone?”
  1. Kumar GalaAug 24, 2010
  2. Junio C HamanoAug 24, 2010
  3. Brandon CaseyAug 24, 2010
  4. Junio C HamanoAug 24, 2010
  5. Brandon CaseyAug 24, 2010
  6. 1/2 t/t5510: demonstrate failure to fetch when current branch has merge refBrandon Casey, Aug 25, 2010
  7. Junio C HamanoAug 25, 2010
  8. 2/2 builtin/fetch.c: ignore merge config when not fetching from branch's remoteBrandon Casey, Aug 25, 2010
  9. Jonathan NiederAug 25, 2010
  10. Brandon CaseyAug 25, 2010
  11. Junio C HamanoAug 25, 2010
  12. 1/2 builtin/fetch.c: comment that branch->remote_name is usable when has_mergeBrandon Casey, Sep 9, 2010
  13. 2/2 t/t5510-fetch.sh: improve testing with explicit URL and merge specBrandon Casey, Sep 9, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.