All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fetch: Only call a new ref a "branch" if it's under refs/heads/.
@ 2012-04-11 14:29 marcnarc
  2012-04-12  5:52 ` Jeff King
  0 siblings, 1 reply; 8+ messages in thread
From: marcnarc @ 2012-04-11 14:29 UTC (permalink / raw)
  To: git; +Cc: Marc Branchaud

From: Marc Branchaud <marcnarc@xiplink.com>

Signed-off-by: Marc Branchaud <marcnarc@xiplink.com>
---

This has been a minor irritant in my life for a while now...  :)

 builtin/fetch.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/builtin/fetch.c b/builtin/fetch.c
index 65f5f9b..57be58a 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -298,8 +298,13 @@ static int update_local_ref(struct ref *ref,
 			what = _("[new tag]");
 		}
 		else {
-			msg = "storing head";
-			what = _("[new branch]");
+			if (!prefixcmp(ref->name, "refs/heads/")) {
+				msg = "storing head";
+				what = _("[new branch]");
+			} else {
+				msg = "storing ref";
+				what = _("[new ref]");
+			}
 			if ((recurse_submodules != RECURSE_SUBMODULES_OFF) &&
 			    (recurse_submodules != RECURSE_SUBMODULES_ON))
 				check_for_new_submodule_commits(ref->new_sha1);
-- 
1.7.10.1.g2bbc8

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

* Re: [PATCH] fetch: Only call a new ref a "branch" if it's under refs/heads/.
  2012-04-11 14:29 [PATCH] fetch: Only call a new ref a "branch" if it's under refs/heads/ marcnarc
@ 2012-04-12  5:52 ` Jeff King
  2012-04-12 20:15   ` Jens Lehmann
  0 siblings, 1 reply; 8+ messages in thread
From: Jeff King @ 2012-04-12  5:52 UTC (permalink / raw)
  To: marcnarc; +Cc: Jens Lehmann, git

On Wed, Apr 11, 2012 at 10:29:29AM -0400, marcnarc@xiplink.com wrote:

>  builtin/fetch.c |    9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/builtin/fetch.c b/builtin/fetch.c
> index 65f5f9b..57be58a 100644
> --- a/builtin/fetch.c
> +++ b/builtin/fetch.c
> @@ -298,8 +298,13 @@ static int update_local_ref(struct ref *ref,
>  			what = _("[new tag]");
>  		}
>  		else {
> -			msg = "storing head";
> -			what = _("[new branch]");
> +			if (!prefixcmp(ref->name, "refs/heads/")) {
> +				msg = "storing head";
> +				what = _("[new branch]");
> +			} else {
> +				msg = "storing ref";
> +				what = _("[new ref]");
> +			}
>  			if ((recurse_submodules != RECURSE_SUBMODULES_OFF) &&
>  			    (recurse_submodules != RECURSE_SUBMODULES_ON))
>  				check_for_new_submodule_commits(ref->new_sha1);

It looks like you kept the behavior the same with respect to
recurse_submodules, which will continue to run for everything except
tags. Which is probably a good choice, since your patch only wanted to
deal with the status message, but I am left to wonder: if submodules
were intended to be recursed for branches but not tags, what should
happen for other types of refs? Was it intentional that they fell into
the "branch" category here, or were they following the same failure to
distinguish that the message-writing code had?

This code block handles only new refs.  If you look at the code below,
updates of existing refs (forced or not) will happen for all refs,
including tags.

Jens, can you double-check the intended logic?

-Peff

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

* Re: [PATCH] fetch: Only call a new ref a "branch" if it's under refs/heads/.
  2012-04-12  5:52 ` Jeff King
@ 2012-04-12 20:15   ` Jens Lehmann
  2012-04-12 20:36     ` Marc Branchaud
  0 siblings, 1 reply; 8+ messages in thread
From: Jens Lehmann @ 2012-04-12 20:15 UTC (permalink / raw)
  To: Jeff King; +Cc: marcnarc, git

Am 12.04.2012 07:52, schrieb Jeff King:
> On Wed, Apr 11, 2012 at 10:29:29AM -0400, marcnarc@xiplink.com wrote:
> 
>>  builtin/fetch.c |    9 +++++++--
>>  1 file changed, 7 insertions(+), 2 deletions(-)
>>
>> diff --git a/builtin/fetch.c b/builtin/fetch.c
>> index 65f5f9b..57be58a 100644
>> --- a/builtin/fetch.c
>> +++ b/builtin/fetch.c
>> @@ -298,8 +298,13 @@ static int update_local_ref(struct ref *ref,
>>  			what = _("[new tag]");
>>  		}
>>  		else {
>> -			msg = "storing head";
>> -			what = _("[new branch]");
>> +			if (!prefixcmp(ref->name, "refs/heads/")) {
>> +				msg = "storing head";
>> +				what = _("[new branch]");
>> +			} else {
>> +				msg = "storing ref";
>> +				what = _("[new ref]");
>> +			}
>>  			if ((recurse_submodules != RECURSE_SUBMODULES_OFF) &&
>>  			    (recurse_submodules != RECURSE_SUBMODULES_ON))
>>  				check_for_new_submodule_commits(ref->new_sha1);
> 
> It looks like you kept the behavior the same with respect to
> recurse_submodules, which will continue to run for everything except
> tags. Which is probably a good choice, since your patch only wanted to
> deal with the status message, but I am left to wonder: if submodules
> were intended to be recursed for branches but not tags, what should
> happen for other types of refs? Was it intentional that they fell into
> the "branch" category here, or were they following the same failure to
> distinguish that the message-writing code had?
> 
> This code block handles only new refs.  If you look at the code below,
> updates of existing refs (forced or not) will happen for all refs,
> including tags.
> 
> Jens, can you double-check the intended logic?

Thanks for spotting this inconsistency. I think it makes sense to
check for new submodule commits no matter if we fetched a new tag,
branch or other ref. I can't remember a reason why I put that code
into the refs & branches part instead of doing that for every new
ref. Patch following ...

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

* Re: [PATCH] fetch: Only call a new ref a "branch" if it's under refs/heads/.
  2012-04-12 20:15   ` Jens Lehmann
@ 2012-04-12 20:36     ` Marc Branchaud
  2012-04-12 20:42       ` Jens Lehmann
  0 siblings, 1 reply; 8+ messages in thread
From: Marc Branchaud @ 2012-04-12 20:36 UTC (permalink / raw)
  To: Jens Lehmann; +Cc: Jeff King, git

On 12-04-12 04:15 PM, Jens Lehmann wrote:
> Am 12.04.2012 07:52, schrieb Jeff King:
>> On Wed, Apr 11, 2012 at 10:29:29AM -0400, marcnarc@xiplink.com wrote:
>>
>>>  builtin/fetch.c |    9 +++++++--
>>>  1 file changed, 7 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/builtin/fetch.c b/builtin/fetch.c
>>> index 65f5f9b..57be58a 100644
>>> --- a/builtin/fetch.c
>>> +++ b/builtin/fetch.c
>>> @@ -298,8 +298,13 @@ static int update_local_ref(struct ref *ref,
>>>  			what = _("[new tag]");
>>>  		}
>>>  		else {
>>> -			msg = "storing head";
>>> -			what = _("[new branch]");
>>> +			if (!prefixcmp(ref->name, "refs/heads/")) {
>>> +				msg = "storing head";
>>> +				what = _("[new branch]");
>>> +			} else {
>>> +				msg = "storing ref";
>>> +				what = _("[new ref]");
>>> +			}
>>>  			if ((recurse_submodules != RECURSE_SUBMODULES_OFF) &&
>>>  			    (recurse_submodules != RECURSE_SUBMODULES_ON))
>>>  				check_for_new_submodule_commits(ref->new_sha1);
>>
>> It looks like you kept the behavior the same with respect to
>> recurse_submodules, which will continue to run for everything except
>> tags. Which is probably a good choice, since your patch only wanted to
>> deal with the status message, but I am left to wonder: if submodules
>> were intended to be recursed for branches but not tags, what should
>> happen for other types of refs? Was it intentional that they fell into
>> the "branch" category here, or were they following the same failure to
>> distinguish that the message-writing code had?
>>
>> This code block handles only new refs.  If you look at the code below,
>> updates of existing refs (forced or not) will happen for all refs,
>> including tags.
>>
>> Jens, can you double-check the intended logic?
> 
> Thanks for spotting this inconsistency. I think it makes sense to
> check for new submodule commits no matter if we fetched a new tag,
> branch or other ref. I can't remember a reason why I put that code
> into the refs & branches part instead of doing that for every new
> ref. Patch following ...

I assumed it was an optimization of some sort -- that since tags are normally
only fetched when they're part of a requested branch's history (right?),
there was no point in doing submodule recursion on the fetched tags since
those tagged tree-ishes had already been submodule-recursed.

Or something like that.  :)

		M.

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

* Re: [PATCH] fetch: Only call a new ref a "branch" if it's under refs/heads/.
  2012-04-12 20:36     ` Marc Branchaud
@ 2012-04-12 20:42       ` Jens Lehmann
  2012-04-12 21:05         ` Jeff King
  0 siblings, 1 reply; 8+ messages in thread
From: Jens Lehmann @ 2012-04-12 20:42 UTC (permalink / raw)
  To: Marc Branchaud; +Cc: Jeff King, git

Am 12.04.2012 22:36, schrieb Marc Branchaud:
> I assumed it was an optimization of some sort -- that since tags are normally
> only fetched when they're part of a requested branch's history (right?),
> there was no point in doing submodule recursion on the fetched tags since
> those tagged tree-ishes had already been submodule-recursed.

If that is the case the patch I just sent is pointless, but adding a comment
there explaining that would be a good thing ;-)

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

* Re: [PATCH] fetch: Only call a new ref a "branch" if it's under refs/heads/.
  2012-04-12 20:42       ` Jens Lehmann
@ 2012-04-12 21:05         ` Jeff King
  2012-04-13  7:04           ` Jeff King
  0 siblings, 1 reply; 8+ messages in thread
From: Jeff King @ 2012-04-12 21:05 UTC (permalink / raw)
  To: Jens Lehmann; +Cc: Marc Branchaud, git

On Thu, Apr 12, 2012 at 10:42:20PM +0200, Jens Lehmann wrote:

> Am 12.04.2012 22:36, schrieb Marc Branchaud:
> > I assumed it was an optimization of some sort -- that since tags are normally
> > only fetched when they're part of a requested branch's history (right?),
> > there was no point in doing submodule recursion on the fetched tags since
> > those tagged tree-ishes had already been submodule-recursed.
> 
> If that is the case the patch I just sent is pointless, but adding a comment
> there explaining that would be a good thing ;-)

That is often the case, but not always (I might explicitly fetch a tag,
or have refs/tags/ in my refspec). So I think you want to handle both to
cover all cases. I haven't looked at the submodule recursion code, but I
would hope that it would eliminate duplicates (so if I get a branch and
a tag that is on the branch, we would look at the commit in question
only once).

-Peff

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

* Re: [PATCH] fetch: Only call a new ref a "branch" if it's under refs/heads/.
  2012-04-12 21:05         ` Jeff King
@ 2012-04-13  7:04           ` Jeff King
  2012-04-13 16:25             ` [PATCH] submodules: recursive fetch also checks new tags for submodule commits Jens Lehmann
  0 siblings, 1 reply; 8+ messages in thread
From: Jeff King @ 2012-04-13  7:04 UTC (permalink / raw)
  To: Jens Lehmann; +Cc: Marc Branchaud, git

On Thu, Apr 12, 2012 at 05:05:42PM -0400, Jeff King wrote:

> > Am 12.04.2012 22:36, schrieb Marc Branchaud:
> > > I assumed it was an optimization of some sort -- that since tags are normally
> > > only fetched when they're part of a requested branch's history (right?),
> > > there was no point in doing submodule recursion on the fetched tags since
> > > those tagged tree-ishes had already been submodule-recursed.
> > 
> > If that is the case the patch I just sent is pointless, but adding a comment
> > there explaining that would be a good thing ;-)
> 
> That is often the case, but not always (I might explicitly fetch a tag,
> or have refs/tags/ in my refspec). So I think you want to handle both to
> cover all cases. I haven't looked at the submodule recursion code, but I
> would hope that it would eliminate duplicates (so if I get a branch and
> a tag that is on the branch, we would look at the commit in question
> only once).

OK, I checked. Yes, we handle this just fine. After my 6859de4, we
collect the ref tips before and after the fetch and run only a single
rev-list. So processing the tags will result in just an extra
interesting commit, which was either:

  1. accessible by another fetched branch, in which case it was going to
     be processed as interesting anyway

  2. not accessible, in which case we have fixed a bug. :)

So I think we should check all incoming refs, including tags.

-Peff

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

* [PATCH] submodules: recursive fetch also checks new tags for submodule commits
  2012-04-13  7:04           ` Jeff King
@ 2012-04-13 16:25             ` Jens Lehmann
  0 siblings, 0 replies; 8+ messages in thread
From: Jens Lehmann @ 2012-04-13 16:25 UTC (permalink / raw)
  To: git; +Cc: Jeff King, Marc Branchaud, Junio C Hamano

Since 88a21979c (fetch/pull: recurse into submodules when necessary) all
fetched commits are examined if they contain submodule changes (unless
configuration or command line options inhibit that). If a newly recorded
submodule commit is not present in the submodule, a fetch is run inside
it to download that commit.

Checking new refs was done in an else branch where it wasn't executed for
tags. This normally isn't a problem because tags are only fetched with
the branches they live on, then checking the new commits in the fetched
branches for submodule commits will also process all tags. But when a
specific tag is fetched (or the refspec contains refs/tags/) commits only
reachable by tags won't be searched for submodule commits, which is a bug.

Fix that by moving the code outside the if/else construct to handle new
tags just like any other ref. The performance impact of adding tags that
most of the time lie on a branch which is checked anyway for new submodule
commit should be minimal, as since 6859de4 (fetch: avoid quadratic loop
checking for updated submodules) all ref-tips are collected first and then
fed to a single rev-list.

Spotted-by: Jeff King <peff@peff.net>
Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
---

Am 13.04.2012 09:04, schrieb Jeff King:
> OK, I checked. Yes, we handle this just fine. After my 6859de4, we
> collect the ref tips before and after the fetch and run only a single
> rev-list. So processing the tags will result in just an extra
> interesting commit, which was either:
> 
>   1. accessible by another fetched branch, in which case it was going to
>      be processed as interesting anyway
> 
>   2. not accessible, in which case we have fixed a bug. :)
> 
> So I think we should check all incoming refs, including tags.

Thanks for you analysis!


 builtin/fetch.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/builtin/fetch.c b/builtin/fetch.c
index 65f5f9b..cfb43df 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -300,11 +300,11 @@ static int update_local_ref(struct ref *ref,
 		else {
 			msg = "storing head";
 			what = _("[new branch]");
-			if ((recurse_submodules != RECURSE_SUBMODULES_OFF) &&
-			    (recurse_submodules != RECURSE_SUBMODULES_ON))
-				check_for_new_submodule_commits(ref->new_sha1);
 		}

+		if ((recurse_submodules != RECURSE_SUBMODULES_OFF) &&
+		    (recurse_submodules != RECURSE_SUBMODULES_ON))
+			check_for_new_submodule_commits(ref->new_sha1);
 		r = s_update_ref(msg, ref, 0);
 		strbuf_addf(display, "%c %-*s %-*s -> %s%s",
 			    r ? '!' : '*',
-- 
1.7.10.131.gd0e498

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

end of thread, other threads:[~2012-04-13 16:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-11 14:29 [PATCH] fetch: Only call a new ref a "branch" if it's under refs/heads/ marcnarc
2012-04-12  5:52 ` Jeff King
2012-04-12 20:15   ` Jens Lehmann
2012-04-12 20:36     ` Marc Branchaud
2012-04-12 20:42       ` Jens Lehmann
2012-04-12 21:05         ` Jeff King
2012-04-13  7:04           ` Jeff King
2012-04-13 16:25             ` [PATCH] submodules: recursive fetch also checks new tags for submodule commits Jens Lehmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.