# [PATCH] remote.c - Make remote definition require a url

3 messages from 2014-10-11 to 2014-10-14. Participants: Mark Levedahl, Junio C Hamano.
Thread: https://gitlist.dev/t/37714

## Mark Levedahl, 2014-10-11 15:20

Subject: [PATCH] remote.c - Make remote definition require a url
Message-ID: <1413040849-20056-1-git-send-email-mlevedahl@gmail.com>
URL: https://gitlist.dev/e/1413040849-20056-1-git-send-email-mlevedahl%40gmail.com

```
Some options may be configured globally for a remote (e.g, tagopt).
The presence of such options in a global config should not cause
git remote or get fetch to believe that remote is configured
for every repository. Change to require definition of remote.<foo>.url
for the remote to be included in "git fetch --all" or "git remote
update."

Signed-off-by: Mark Levedahl <mlevedahl@gmail.com>
---
 remote.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/remote.c b/remote.c
index ce785f8..1b08924 100644
--- a/remote.c
+++ b/remote.c
@@ -761,7 +761,7 @@ int for_each_remote(each_remote_fn fn, void *priv)
 	read_config();
 	for (i = 0; i < remotes_nr && !result; i++) {
 		struct remote *r = remotes[i];
-		if (!r)
+		if (!r || !r->url)
 			continue;
 		if (!r->fetch)
 			r->fetch = parse_fetch_refspec(r->fetch_refspec_nr,
-- 
2.1.2.2.0.14

```

## Junio C Hamano, 2014-10-13 17:19

Subject: Re: [PATCH] remote.c - Make remote definition require a url
Message-ID: <xmqqppdv51lv.fsf@gitster.dls.corp.google.com>
URL: https://gitlist.dev/e/xmqqppdv51lv.fsf%40gitster.dls.corp.google.com
In-Reply-To: <1413040849-20056-1-git-send-email-mlevedahl@gmail.com>

```
Mark Levedahl <mlevedahl@gmail.com> writes:

> Some options may be configured globally for a remote (e.g, tagopt).

Or some remotes may have only pushurl and not url.  "git remote"
output for me has a few such remotes but wouldn't this patch break
it?

If a caller that walks the list of remotes misbehaves only because
it assumes that r->url always is always valid, isn't that assumption
what needs to be fixed?  for_each_remote() should be kept as a way
to enumerate all the [remote "foo"], I would think.

```

## Mark Levedahl, 2014-10-14 01:05

Subject: Re: [PATCH] remote.c - Make remote definition require a url
Message-ID: <543C76EB.1000103@gmail.com>
URL: https://gitlist.dev/e/543C76EB.1000103%40gmail.com
In-Reply-To: <xmqqppdv51lv.fsf@gitster.dls.corp.google.com>

```
On 10/13/2014 01:19 PM, Junio C Hamano wrote:
> Mark Levedahl <mlevedahl@gmail.com> writes:
>
>> Some options may be configured globally for a remote (e.g, tagopt).
> Or some remotes may have only pushurl and not url.  "git remote"
> output for me has a few such remotes but wouldn't this patch break
> it?
>
> If a caller that walks the list of remotes misbehaves only because
> it assumes that r->url always is always valid, isn't that assumption
> what needs to be fixed?  for_each_remote() should be kept as a way
> to enumerate all the [remote "foo"], I would think.
>
>
>
>
As long as the rule is that for_each_remote will enumerate every remote 
that has anything defined at all, even if only in the global config 
outside of a user's control, I'm not really sure how to tell whether the 
missing url / pushurl / whatever is intentional, or a misconfiguration, 
so having the code complain that it didn't find what it wanted (the 
current condition) is probably no worse than the alternatives. Patch 
withdrawn.

Mark

```
