Thread (3 messages) 3 messages, 2 authors, 2016-06-15

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

flat view

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:49:23

Possibly related (same subject, not in this thread)

Brandon Casey [off-list ref] writes:
quoted hunk
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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help