git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] Fix remote.<remote>.vcs
@ 2010-01-27 17:53 Ilari Liusvaara
  2010-01-27 18:09 ` Sverre Rabbelier
  2010-01-27 18:39 ` Daniel Barkalow
  0 siblings, 2 replies; 7+ messages in thread
From: Ilari Liusvaara @ 2010-01-27 17:53 UTC (permalink / raw)
  To: git; +Cc: Tor Arvid Lund, Daniel Barkalow

remote.<remote>.vcs causes remote->foreign_vcs to be set on entry to
transport_get(). Unfortunately, the code assumed that any such entry
is stale from previous round.

Fix this by making VCS set by URL to be volatile w.r.t. transport_get()
instead.

Signed-off-by: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
---
 transport.c |   11 +++++------
 1 files changed, 5 insertions(+), 6 deletions(-)

Differences from first round:

This makes VCS setting apply to all URLs that don't explicitly override,
instead of it applying to just the first one.

diff --git a/transport.c b/transport.c
index 7714fdb..87581b8 100644
--- a/transport.c
+++ b/transport.c
@@ -912,20 +912,19 @@ static int external_specification_len(const char *url)
 
 struct transport *transport_get(struct remote *remote, const char *url)
 {
+	const char *helper;
 	struct transport *ret = xcalloc(1, sizeof(*ret));
 
 	if (!remote)
 		die("No remote provided to transport_get()");
 
 	ret->remote = remote;
+	helper = remote->foreign_vcs;
 
 	if (!url && remote && remote->url)
 		url = remote->url[0];
 	ret->url = url;
 
-	/* In case previous URL had helper forced, reset it. */
-	remote->foreign_vcs = NULL;
-
 	/* maybe it is a foreign URL? */
 	if (url) {
 		const char *p = url;
@@ -933,11 +932,11 @@ struct transport *transport_get(struct remote *remote, const char *url)
 		while (isalnum(*p))
 			p++;
 		if (!prefixcmp(p, "::"))
-			remote->foreign_vcs = xstrndup(url, p - url);
+			helper = xstrndup(url, p - url);
 	}
 
-	if (remote && remote->foreign_vcs) {
-		transport_helper_init(ret, remote->foreign_vcs);
+	if (helper) {
+		transport_helper_init(ret, helper);
 	} else if (!prefixcmp(url, "rsync:")) {
 		ret->get_refs_list = get_refs_via_rsync;
 		ret->fetch = fetch_objs_via_rsync;
-- 
1.7.0.rc0.19.gb557e6

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] Fix remote.<remote>.vcs
  2010-01-27 17:53 [PATCH v2] Fix remote.<remote>.vcs Ilari Liusvaara
@ 2010-01-27 18:09 ` Sverre Rabbelier
  2010-01-27 18:39 ` Daniel Barkalow
  1 sibling, 0 replies; 7+ messages in thread
From: Sverre Rabbelier @ 2010-01-27 18:09 UTC (permalink / raw)
  To: Ilari Liusvaara; +Cc: git, Tor Arvid Lund, Daniel Barkalow

Heya,

On Wed, Jan 27, 2010 at 18:53, Ilari Liusvaara
<ilari.liusvaara@elisanet.fi> wrote:
> Fix this by making VCS set by URL to be volatile w.r.t. transport_get()
> instead.

Patch looks good (didn't test it though), but I had to read this line
twice; I'm afraid I don't have any suggestions on how to improve it
though.

-- 
Cheers,

Sverre Rabbelier

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] Fix remote.<remote>.vcs
  2010-01-27 17:53 [PATCH v2] Fix remote.<remote>.vcs Ilari Liusvaara
  2010-01-27 18:09 ` Sverre Rabbelier
@ 2010-01-27 18:39 ` Daniel Barkalow
  2010-01-27 18:59   ` Ilari Liusvaara
  2010-01-27 19:13   ` Junio C Hamano
  1 sibling, 2 replies; 7+ messages in thread
From: Daniel Barkalow @ 2010-01-27 18:39 UTC (permalink / raw)
  To: Ilari Liusvaara; +Cc: git, Tor Arvid Lund

On Wed, 27 Jan 2010, Ilari Liusvaara wrote:

> remote.<remote>.vcs causes remote->foreign_vcs to be set on entry to
> transport_get(). Unfortunately, the code assumed that any such entry
> is stale from previous round.
> 
> Fix this by making VCS set by URL to be volatile w.r.t. transport_get()
> instead.
> 
> Signed-off-by: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>

Except that you missed the "remote == NULL" case (noted below), this is 
what I was thinking of.

Acked-by: Daniel Barkalow <barkalow@iabervon.org>

> ---
>  transport.c |   11 +++++------
>  1 files changed, 5 insertions(+), 6 deletions(-)
> 
> Differences from first round:
> 
> This makes VCS setting apply to all URLs that don't explicitly override,
> instead of it applying to just the first one.
> 
> diff --git a/transport.c b/transport.c
> index 7714fdb..87581b8 100644
> --- a/transport.c
> +++ b/transport.c
> @@ -912,20 +912,19 @@ static int external_specification_len(const char *url)
>  
>  struct transport *transport_get(struct remote *remote, const char *url)
>  {
> +	const char *helper;
>  	struct transport *ret = xcalloc(1, sizeof(*ret));
>  
>  	if (!remote)
>  		die("No remote provided to transport_get()");
>  
>  	ret->remote = remote;
> +	helper = remote->foreign_vcs;

Needs to be "helper = remote ? remote->foreign_vcs : NULL", for the same 
reason that the test below had been "remote && remote->foreign_vcs".

>  
>  	if (!url && remote && remote->url)
>  		url = remote->url[0];
>  	ret->url = url;
>  
> -	/* In case previous URL had helper forced, reset it. */
> -	remote->foreign_vcs = NULL;
> -
>  	/* maybe it is a foreign URL? */
>  	if (url) {
>  		const char *p = url;
> @@ -933,11 +932,11 @@ struct transport *transport_get(struct remote *remote, const char *url)
>  		while (isalnum(*p))
>  			p++;
>  		if (!prefixcmp(p, "::"))
> -			remote->foreign_vcs = xstrndup(url, p - url);
> +			helper = xstrndup(url, p - url);
>  	}
>  
> -	if (remote && remote->foreign_vcs) {
> -		transport_helper_init(ret, remote->foreign_vcs);
> +	if (helper) {
> +		transport_helper_init(ret, helper);
>  	} else if (!prefixcmp(url, "rsync:")) {
>  		ret->get_refs_list = get_refs_via_rsync;
>  		ret->fetch = fetch_objs_via_rsync;
> -- 
> 1.7.0.rc0.19.gb557e6
> 
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] Fix remote.<remote>.vcs
  2010-01-27 18:39 ` Daniel Barkalow
@ 2010-01-27 18:59   ` Ilari Liusvaara
  2010-01-27 20:22     ` Junio C Hamano
  2010-01-27 19:13   ` Junio C Hamano
  1 sibling, 1 reply; 7+ messages in thread
From: Ilari Liusvaara @ 2010-01-27 18:59 UTC (permalink / raw)
  To: Daniel Barkalow; +Cc: git, Tor Arvid Lund

On Wed, Jan 27, 2010 at 01:39:00PM -0500, Daniel Barkalow wrote:
> On Wed, 27 Jan 2010, Ilari Liusvaara wrote:
> >  
> >  	if (!remote)
> >  		die("No remote provided to transport_get()");
> >  
> >  	ret->remote = remote;
> > +	helper = remote->foreign_vcs;
> 
> Needs to be "helper = remote ? remote->foreign_vcs : NULL", for the same 
> reason that the test below had been "remote && remote->foreign_vcs".

Few lines above that:

     if (!remote)
             die("No remote provided to transport_get()");


-Ilari

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] Fix remote.<remote>.vcs
  2010-01-27 18:39 ` Daniel Barkalow
  2010-01-27 18:59   ` Ilari Liusvaara
@ 2010-01-27 19:13   ` Junio C Hamano
  1 sibling, 0 replies; 7+ messages in thread
From: Junio C Hamano @ 2010-01-27 19:13 UTC (permalink / raw)
  To: Daniel Barkalow; +Cc: Ilari Liusvaara, git, Tor Arvid Lund

Daniel Barkalow <barkalow@iabervon.org> writes:

> Except that you missed the "remote == NULL" case (noted below), this is 
> what I was thinking of.
>
> Acked-by: Daniel Barkalow <barkalow@iabervon.org>


>>  	if (!remote)
>>  		die("No remote provided to transport_get()");
>>  
>>  	ret->remote = remote;
>> +	helper = remote->foreign_vcs;
>
> Needs to be "helper = remote ? remote->foreign_vcs : NULL", for the same 
> reason that the test below had been "remote && remote->foreign_vcs".

Even in the presense of "if remote is NULL then we die" in the context
above?

>>  
>>  	if (!url && remote && remote->url)
>>  		url = remote->url[0];
>>  	ret->url = url;
>>  
>> -	/* In case previous URL had helper forced, reset it. */
>> -	remote->foreign_vcs = NULL;
>> -
>>  	/* maybe it is a foreign URL? */
>>  	if (url) {
>>  		const char *p = url;
>> @@ -933,11 +932,11 @@ struct transport *transport_get(struct remote *remote, const char *url)
>>  		while (isalnum(*p))
>>  			p++;
>>  		if (!prefixcmp(p, "::"))
>> -			remote->foreign_vcs = xstrndup(url, p - url);
>> +			helper = xstrndup(url, p - url);
>>  	}
>>  
>> -	if (remote && remote->foreign_vcs) {
>> -		transport_helper_init(ret, remote->foreign_vcs);
>> +	if (helper) {
>> +		transport_helper_init(ret, helper);
>>  	} else if (!prefixcmp(url, "rsync:")) {
>>  		ret->get_refs_list = get_refs_via_rsync;
>>  		ret->fetch = fetch_objs_via_rsync;
>> -- 
>> 1.7.0.rc0.19.gb557e6
>> 
>> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] Fix remote.<remote>.vcs
  2010-01-27 18:59   ` Ilari Liusvaara
@ 2010-01-27 20:22     ` Junio C Hamano
  2010-01-27 23:54       ` Daniel Barkalow
  0 siblings, 1 reply; 7+ messages in thread
From: Junio C Hamano @ 2010-01-27 20:22 UTC (permalink / raw)
  To: Ilari Liusvaara; +Cc: Daniel Barkalow, git, Tor Arvid Lund

Ilari Liusvaara <ilari.liusvaara@elisanet.fi> writes:

> On Wed, Jan 27, 2010 at 01:39:00PM -0500, Daniel Barkalow wrote:
>> On Wed, 27 Jan 2010, Ilari Liusvaara wrote:
>> >  
>> >  	if (!remote)
>> >  		die("No remote provided to transport_get()");
>> >  
>> >  	ret->remote = remote;
>> > +	helper = remote->foreign_vcs;
>> 
>> Needs to be "helper = remote ? remote->foreign_vcs : NULL", for the same 
>> reason that the test below had been "remote && remote->foreign_vcs".
>
> Few lines above that:
>
>      if (!remote)
>              die("No remote provided to transport_get()");

Perhaps we would want this micro-clean-up on top then.

-- >8 --
Subject: transport_get(): drop unnecessary check for !remote

At the beginning of the function we make sure remote is not NULL, and
the remainder of the funciton already depends on it.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
diff --git a/transport.c b/transport.c
index 87581b8..3846aac 100644
--- a/transport.c
+++ b/transport.c
@@ -921,7 +921,7 @@ struct transport *transport_get(struct remote *remote, const char *url)
 	ret->remote = remote;
 	helper = remote->foreign_vcs;
 
-	if (!url && remote && remote->url)
+	if (!url && remote->url)
 		url = remote->url[0];
 	ret->url = url;
 

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] Fix remote.<remote>.vcs
  2010-01-27 20:22     ` Junio C Hamano
@ 2010-01-27 23:54       ` Daniel Barkalow
  0 siblings, 0 replies; 7+ messages in thread
From: Daniel Barkalow @ 2010-01-27 23:54 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Ilari Liusvaara, git, Tor Arvid Lund

On Wed, 27 Jan 2010, Junio C Hamano wrote:

> Ilari Liusvaara <ilari.liusvaara@elisanet.fi> writes:
> 
> > On Wed, Jan 27, 2010 at 01:39:00PM -0500, Daniel Barkalow wrote:
> >> On Wed, 27 Jan 2010, Ilari Liusvaara wrote:
> >> >  
> >> >  	if (!remote)
> >> >  		die("No remote provided to transport_get()");
> >> >  
> >> >  	ret->remote = remote;
> >> > +	helper = remote->foreign_vcs;
> >> 
> >> Needs to be "helper = remote ? remote->foreign_vcs : NULL", for the same 
> >> reason that the test below had been "remote && remote->foreign_vcs".
> >
> > Few lines above that:
> >
> >      if (!remote)
> >              die("No remote provided to transport_get()");
> 
> Perhaps we would want this micro-clean-up on top then.
> 
> -- >8 --
> Subject: transport_get(): drop unnecessary check for !remote
> 
> At the beginning of the function we make sure remote is not NULL, and
> the remainder of the funciton already depends on it.

I agree with both of these; there used to be code that used a NULL remote 
and just a URL, but that's gone now.

> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
> diff --git a/transport.c b/transport.c
> index 87581b8..3846aac 100644
> --- a/transport.c
> +++ b/transport.c
> @@ -921,7 +921,7 @@ struct transport *transport_get(struct remote *remote, const char *url)
>  	ret->remote = remote;
>  	helper = remote->foreign_vcs;
>  
> -	if (!url && remote && remote->url)
> +	if (!url && remote->url)
>  		url = remote->url[0];
>  	ret->url = url;
>  
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-01-27 23:54 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-27 17:53 [PATCH v2] Fix remote.<remote>.vcs Ilari Liusvaara
2010-01-27 18:09 ` Sverre Rabbelier
2010-01-27 18:39 ` Daniel Barkalow
2010-01-27 18:59   ` Ilari Liusvaara
2010-01-27 20:22     ` Junio C Hamano
2010-01-27 23:54       ` Daniel Barkalow
2010-01-27 19:13   ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).