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

[PATCH 1/2] builtin/fetch.c: comment that branch->remote_name is usable when has_merge

From
Brandon Casey <casey@nrlssc.navy.mil>
Date
Sep 9, 2010, 18:56 UTC
Message-ID
<NYNWO-6R8khWRYvZHfeUgclo0qTrx32yM6iROg9eTvmBQn8zP_PDNNLiYY_Cx1TwXuGliHPxYzQ@cipher.nrlssc.navy.mil>
In-Reply-To
<7vtymipddv.fsf@alter.siamese.dyndns.org>
From: Brandon Casey <drafnel@gmail.com>

Save future readers the trouble of tracing code to determine that the two uses of branch->remote_name are safe when has_merge is set, by adding a comment explaining that it is so.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
---
 builtin/fetch.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/builtin/fetch.c b/builtin/fetch.c
index fccc9cb..6fc5047 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -148,6 +148,7 @@ static struct ref *get_ref_map(struct transport *transport,
 		int has_merge = branch_has_merge_config(branch);
 		if (remote &&
 		    (remote->fetch_refspec_nr ||
+		     /* Note: has_merge implies non-NULL branch->remote_name */
 		     (has_merge && !strcmp(branch->remote_name, remote->name)))) {
 			for (i = 0; i < remote->fetch_refspec_nr; i++) {
 				get_fetch_map(remote_refs, &remote->fetch[i], &tail, 0);
@@ -162,6 +163,8 @@ static struct ref *get_ref_map(struct transport *transport,
 			 * if the remote we're fetching from is the same
 			 * as given in branch.<name>.remote, we add the
 			 * ref given in branch.<name>.merge, too.
+			 *
+			 * Note: has_merge implies non-NULL branch->remote_name
 			 */
 			if (has_merge &&
 			    !strcmp(branch->remote_name, remote->name))
-- 
1.7.2.1
Previous: Junio C HamanoNext: Brandon Casey
Message 12 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.