git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] Teach git-describe to display distances from tags.
@ 2007-01-25 17:39 Shawn O. Pearce
  2007-01-25 21:26 ` Junio C Hamano
  2007-01-26 13:33 ` [PATCH 1/2] Teach git-describe to display distances from tags Jakub Narebski
  0 siblings, 2 replies; 15+ messages in thread
From: Shawn O. Pearce @ 2007-01-25 17:39 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Junio C Hamano <junkio@cox.net>:
> However, I suspect that we could do better with Shawn's new
> fangled describe implementation that actually counts the
> distance between what is described and the tag.  We could add
> "number of commits since the tag" somewhere, to describe:
>
>   v2.6.20-rc5-256-g419dd83
>   v2.6.20-rc5-217-gde14569
>
> to say that the first one has 256 commits accumulated since the
> given tag "v2.6.20-rc5" and the second one has only 217
> commits, to get the sense of how busy the development activity
> is.
>
> Is it useful?  That is something I am not sure.

Yes, its very useful.  If you get two different describes at different
times from a non-rewinding branch and they both come up with the same
tag name, you can tell which is the 'newer' one by distance.  This is
rather common in practice, so its incredibly useful.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 builtin-describe.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/builtin-describe.c b/builtin-describe.c
index e7b8f95..d8ff621 100644
--- a/builtin-describe.c
+++ b/builtin-describe.c
@@ -189,7 +189,8 @@ static void describe(const char *arg, int last_one)
 				sha1_to_hex(gave_up_on->object.sha1));
 		}
 	}
-	printf("%s-g%s\n", all_matches[0].name->path,
+	printf("%s-%i-g%s\n", all_matches[0].name->path,
+		   all_matches[0].depth,
 		   find_unique_abbrev(cmit->object.sha1, abbrev));
 
 	if (!last_one)
-- 
1.5.0.rc2.g18af

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

* Re: [PATCH 1/2] Teach git-describe to display distances from tags.
  2007-01-25 17:39 [PATCH 1/2] Teach git-describe to display distances from tags Shawn O. Pearce
@ 2007-01-25 21:26 ` Junio C Hamano
  2007-01-25 21:37   ` Shawn O. Pearce
  2007-01-25 21:42   ` Junio C Hamano
  2007-01-26 13:33 ` [PATCH 1/2] Teach git-describe to display distances from tags Jakub Narebski
  1 sibling, 2 replies; 15+ messages in thread
From: Junio C Hamano @ 2007-01-25 21:26 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: git

"Shawn O. Pearce" <spearce@spearce.org> writes:

> Yes, its very useful.  If you get two different describes at different
> times from a non-rewinding branch and they both come up with the same
> tag name, you can tell which is the 'newer' one by distance.  This is
> rather common in practice, so its incredibly useful.
>
> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
> ---
>  builtin-describe.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/builtin-describe.c b/builtin-describe.c
> index e7b8f95..d8ff621 100644
> --- a/builtin-describe.c
> +++ b/builtin-describe.c
> @@ -189,7 +189,8 @@ static void describe(const char *arg, int last_one)
>  				sha1_to_hex(gave_up_on->object.sha1));
>  		}
>  	}
> -	printf("%s-g%s\n", all_matches[0].name->path,
> +	printf("%s-%i-g%s\n", all_matches[0].name->path,
> +		   all_matches[0].depth,
>  		   find_unique_abbrev(cmit->object.sha1, abbrev));
>  
>  	if (!last_one)

Two comments.

 - This is purely style, but we seem to prefer %d instead of %i
   elsewhere in the code (three existing offenders are
   builtin-describe.c, receive-pack.c and sha1_file which we may
   want to clean up for consistency).

 - How much damage are we talking about with this patch to
   People's existing scripts?  I expect they all extract the
   hash from last -g (because they cannot rely on particular
   convention in tagnames), but I am also worried if people are
   expecting everything that comes before the last -g is the
   whole tag.

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

* Re: [PATCH 1/2] Teach git-describe to display distances from tags.
  2007-01-25 21:26 ` Junio C Hamano
@ 2007-01-25 21:37   ` Shawn O. Pearce
  2007-01-25 21:42   ` Junio C Hamano
  1 sibling, 0 replies; 15+ messages in thread
From: Shawn O. Pearce @ 2007-01-25 21:37 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Junio C Hamano <junkio@cox.net> wrote:
>  - This is purely style, but we seem to prefer %d instead of %i
>    elsewhere in the code (three existing offenders are
>    builtin-describe.c, receive-pack.c and sha1_file which we may
>    want to clean up for consistency).

I'll send a cleanup patch then for these locations.
 
>  - How much damage are we talking about with this patch to
>    People's existing scripts?  I expect they all extract the
>    hash from last -g (because they cannot rely on particular
>    convention in tagnames), but I am also worried if people are
>    expecting everything that comes before the last -g is the
>    whole tag.

No way to know for sure.  I almost put this as an option
(e.g. "--include-distance") but didn't want everyone to need to
update their existing git-describe callers to obtain this new data.
I would hope that people split on last -g to get at or remove the
commit SHA-1, but they probably are also assiming te tag name is
everything to the left.  Including the distance would certainly
violate that.

-- 
Shawn.

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

* Re: [PATCH 1/2] Teach git-describe to display distances from tags.
  2007-01-25 21:26 ` Junio C Hamano
  2007-01-25 21:37   ` Shawn O. Pearce
@ 2007-01-25 21:42   ` Junio C Hamano
  2007-01-25 21:49     ` Shawn O. Pearce
  1 sibling, 1 reply; 15+ messages in thread
From: Junio C Hamano @ 2007-01-25 21:42 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: git

Junio C Hamano <junkio@cox.net> writes:

>> ---
>>  builtin-describe.c |    3 ++-
>>  1 files changed, 2 insertions(+), 1 deletions(-)
>>
>> diff --git a/builtin-describe.c b/builtin-describe.c
>> index e7b8f95..d8ff621 100644
>> --- a/builtin-describe.c
>> +++ b/builtin-describe.c
>> @@ -189,7 +189,8 @@ static void describe(const char *arg, int last_one)
>>  				sha1_to_hex(gave_up_on->object.sha1));
>>  		}
>>  	}
>> -	printf("%s-g%s\n", all_matches[0].name->path,
>> +	printf("%s-%i-g%s\n", all_matches[0].name->path,
>> +		   all_matches[0].depth,
>>  		   find_unique_abbrev(cmit->object.sha1, abbrev));
>>  
>>  	if (!last_one)
>
> Two comments.
>
>  - This is purely style, but we seem to prefer %d instead of %i
>    elsewhere in the code (three existing offenders are
>    builtin-describe.c, receive-pack.c and sha1_file which we may
>    want to clean up for consistency).
>
>  - How much damage are we talking about with this patch to
>    People's existing scripts?  I expect they all extract the
>    hash from last -g (because they cannot rely on particular
>    convention in tagnames), but I am also worried if people are
>    expecting everything that comes before the last -g is the
>    whole tag.

Actually there is a third one and a half.

  - We need to update the documentation to say what this new
    number means.

It's some number close to the number of revs since the named
tag, but not exactly.

    $ git describe --debug 65ebe634 2>&1 | head -4
    searching to describe 65ebe634
     annotated        251 v2.6.20-rc5
     annotated        427 v2.6.20-rc4
     annotated        594 v2.6.20-rc3
    $ git rev-list v2.6.20-rc5..65ebe634 | wc -l
    254
    $ git rev-list v2.6.20-rc4..65ebe634 | wc -l
    430

And it does not seem to be always "minus 3" either.

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

* Re: [PATCH 1/2] Teach git-describe to display distances from tags.
  2007-01-25 21:42   ` Junio C Hamano
@ 2007-01-25 21:49     ` Shawn O. Pearce
  2007-01-25 23:32       ` Nicolas Pitre
  0 siblings, 1 reply; 15+ messages in thread
From: Shawn O. Pearce @ 2007-01-25 21:49 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Junio C Hamano <junkio@cox.net> wrote:
>   - We need to update the documentation to say what this new
>     number means.

Indeed; I apologize for forgetting to do that.  At this point
I'll wind up resending the patch to address everything so toss
what you have.
 
> It's some number close to the number of revs since the named
> tag, but not exactly.
> 
>     $ git describe --debug 65ebe634 2>&1 | head -4
>     searching to describe 65ebe634
>      annotated        251 v2.6.20-rc5
>      annotated        427 v2.6.20-rc4
>      annotated        594 v2.6.20-rc3
>     $ git rev-list v2.6.20-rc5..65ebe634 | wc -l
>     254
>     $ git rev-list v2.6.20-rc4..65ebe634 | wc -l
>     430
> 
> And it does not seem to be always "minus 3" either.

What you skipped in the --debug output above was that we hit
our internal possible tag limit (10 by default) and aborted
walking the revision chain.  That's why we missed 3 revs in
our counting.  :)

We probably should make an option to enable the count, and
if the count is enabled then we'll have to pickup counting
where we left off and finish it out for the chosen tag so
the count is correct.

-- 
Shawn.

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

* Re: [PATCH 1/2] Teach git-describe to display distances from tags.
  2007-01-25 21:49     ` Shawn O. Pearce
@ 2007-01-25 23:32       ` Nicolas Pitre
  2007-01-26  0:13         ` Junio C Hamano
  0 siblings, 1 reply; 15+ messages in thread
From: Nicolas Pitre @ 2007-01-25 23:32 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: Junio C Hamano, git

On Thu, 25 Jan 2007, Shawn O. Pearce wrote:

> We probably should make an option to enable the count, and
> if the count is enabled then we'll have to pickup counting
> where we left off and finish it out for the chosen tag so
> the count is correct.
Please don't make it an option.  This is too useful to require an 
additional switch all the time.


Nicolas

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

* Re: [PATCH 1/2] Teach git-describe to display distances from tags.
  2007-01-25 23:32       ` Nicolas Pitre
@ 2007-01-26  0:13         ` Junio C Hamano
  2007-01-26  8:52           ` Francis Moreau
  2007-01-26 10:36           ` Andy Parkins
  0 siblings, 2 replies; 15+ messages in thread
From: Junio C Hamano @ 2007-01-26  0:13 UTC (permalink / raw)
  To: Nicolas Pitre; +Cc: Shawn O. Pearce, git

Nicolas Pitre <nico@cam.org> writes:

> On Thu, 25 Jan 2007, Shawn O. Pearce wrote:
>
>> We probably should make an option to enable the count, and
>> if the count is enabled then we'll have to pickup counting
>> where we left off and finish it out for the chosen tag so
>> the count is correct.
>
> Please don't make it an option.  This is too useful to require an 
> additional switch all the time.

Hmph.  And an option --no-number to disable this is probably not
worth it, as it forces the existing scripts that wants the
tagname to be updated to pass that new option.  If the users
need to update their scripts anyway, they can sed/expr the
number out just as easily as passing the new option.

Another backward incompatibility to mention in the release
notes.  I guess it is not too big a deal but makes me feel
uneasy.

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

* Re: [PATCH 1/2] Teach git-describe to display distances from tags.
  2007-01-26  0:13         ` Junio C Hamano
@ 2007-01-26  8:52           ` Francis Moreau
  2007-01-26  9:00             ` Junio C Hamano
  2007-01-26 10:36           ` Andy Parkins
  1 sibling, 1 reply; 15+ messages in thread
From: Francis Moreau @ 2007-01-26  8:52 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Nicolas Pitre, Shawn O. Pearce, git

On 1/26/07, Junio C Hamano <junkio@cox.net> wrote:
> Another backward incompatibility to mention in the release
> notes.  I guess it is not too big a deal but makes me feel
> uneasy.
>

Sorry if I missed any discussions about that point but why not calling
the coming release 2.0 instead of 1.5 if this one implies some
backward incompabilities and a lot of change in the UI ?

thanks
-- 
Francis

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

* Re: [PATCH 1/2] Teach git-describe to display distances from tags.
  2007-01-26  8:52           ` Francis Moreau
@ 2007-01-26  9:00             ` Junio C Hamano
  2007-01-26  9:39               ` Francis Moreau
  0 siblings, 1 reply; 15+ messages in thread
From: Junio C Hamano @ 2007-01-26  9:00 UTC (permalink / raw)
  To: Francis Moreau; +Cc: git

"Francis Moreau" <francis.moro@gmail.com> writes:

> On 1/26/07, Junio C Hamano <junkio@cox.net> wrote:
>> Another backward incompatibility to mention in the release
>> notes.  I guess it is not too big a deal but makes me feel
>> uneasy.
>>
>
> Sorry if I missed any discussions about that point but why not calling
> the coming release 2.0 instead of 1.5 if this one implies some
> backward incompabilities and a lot of change in the UI ?

Because with the usual numbering the next normal feature release
would have been called 1.4.5, we said we would bump to 1.5 some
time ago.

There is no fundamental change between 1.4.4 series and the
upcoming 1.5.0 -- only superficial ones.  I do not think it
deserves a bump in the major version; well, at least I did not
think it would, when we first started talking about "the new
release whose main theme was usability enhancements".

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

* Re: [PATCH 1/2] Teach git-describe to display distances from tags.
  2007-01-26  9:00             ` Junio C Hamano
@ 2007-01-26  9:39               ` Francis Moreau
  2007-01-26  9:51                 ` Shawn O. Pearce
  0 siblings, 1 reply; 15+ messages in thread
From: Francis Moreau @ 2007-01-26  9:39 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On 1/26/07, Junio C Hamano <junkio@cox.net> wrote:
> There is no fundamental change between 1.4.4 series and the
> upcoming 1.5.0 -- only superficial ones.  I do not think it

But there are incompatibilities.

Another example, which may be a bad one since I unfortunately don't
have time to follow closely git's development: the internal of 'git
pull' has completely changed. If I clone a repo with git v1.4.x and I
pull in this repo with git v1.5.x, does it still works ?

thanks
-- 
Francis

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

* Re: [PATCH 1/2] Teach git-describe to display distances from tags.
  2007-01-26  9:39               ` Francis Moreau
@ 2007-01-26  9:51                 ` Shawn O. Pearce
  0 siblings, 0 replies; 15+ messages in thread
From: Shawn O. Pearce @ 2007-01-26  9:51 UTC (permalink / raw)
  To: Francis Moreau; +Cc: Junio C Hamano, git

Francis Moreau <francis.moro@gmail.com> wrote:
> But there are incompatibilities.

Nothing really *that* major.  Heck, that git-describe change is
probably one of the biggest, if not the biggest.
 
> Another example, which may be a bad one since I unfortunately don't
> have time to follow closely git's development: the internal of 'git
> pull' has completely changed. If I clone a repo with git v1.4.x and I
> pull in this repo with git v1.5.x, does it still works ?

Yes, of course.  Just like before too.

What's different is if you clone with 1.5.x, as we now default to the
seperate remotes layout.  This was an option in 1.4.x and earlier,
its now the only way its done in 1.5.x.

-- 
Shawn.

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

* Re: [PATCH 1/2] Teach git-describe to display distances from tags.
  2007-01-26  0:13         ` Junio C Hamano
  2007-01-26  8:52           ` Francis Moreau
@ 2007-01-26 10:36           ` Andy Parkins
  2007-01-26 14:28             ` [PATCH] If abbrev is set to zero in git-describe, don't add the unique suffix Andy Parkins
  1 sibling, 1 reply; 15+ messages in thread
From: Andy Parkins @ 2007-01-26 10:36 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Nicolas Pitre, Shawn O. Pearce

On Friday 2007 January 26 00:13, Junio C Hamano wrote:

> Hmph.  And an option --no-number to disable this is probably not
> worth it, as it forces the existing scripts that wants the
> tagname to be updated to pass that new option.  If the users
> need to update their scripts anyway, they can sed/expr the
> number out just as easily as passing the new option.

Actually, the more useful switch would be "--tag-only"; then

x=$(git-describe HEAD | sed 's/-g*//')

In scripts could become

x=$(git-describe --tag-only HEAD)

Then, the suffix can be anything we want, and can change in the future without 
affecting these scripts.


Andy
-- 
Dr Andy Parkins, M Eng (hons), MIEE
andyparkins@gmail.com

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

* Re: [PATCH 1/2] Teach git-describe to display distances from tags.
  2007-01-25 17:39 [PATCH 1/2] Teach git-describe to display distances from tags Shawn O. Pearce
  2007-01-25 21:26 ` Junio C Hamano
@ 2007-01-26 13:33 ` Jakub Narebski
  2007-01-26 19:37   ` Matthias Lederhofer
  1 sibling, 1 reply; 15+ messages in thread
From: Jakub Narebski @ 2007-01-26 13:33 UTC (permalink / raw)
  To: git

[Cc: git@vger.kernel.org]

Shawn O. Pearce wrote:

> +       printf("%s-%i-g%s\n", all_matches[0].name->path,

I'd rather use "%s+%i-g%s\n" here...
-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

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

* [PATCH] If abbrev is set to zero in git-describe, don't add the unique suffix
  2007-01-26 10:36           ` Andy Parkins
@ 2007-01-26 14:28             ` Andy Parkins
  0 siblings, 0 replies; 15+ messages in thread
From: Andy Parkins @ 2007-01-26 14:28 UTC (permalink / raw)
  To: git

When on a non-tag commit, git-describe normally outputs descriptions of
the form
  v1.0.0-g1234567890
Some scripts (for example the update hook script) might just want to
know the name of the nearest tag, so they then have to do
 x=$(git-describe HEAD | sed 's/-g*//')
This is costly, but more importantly is fragile as it is relying on the
output format of git-describe, which we would then have to maintain
forever.

This patch adds support for setting the --abbrev option to zero.  In
that case git-describe does as it always has, but outputs only the
nearest found tag instead of a completely unique name.  This means that
scripts would not have to parse the output format and won't need
changing if the git-describe suffix is ever changed.

Signed-off-by: Andy Parkins <andyparkins@gmail.com>
---
 builtin-describe.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/builtin-describe.c b/builtin-describe.c
index 4921eee..f3ac2d5 100644
--- a/builtin-describe.c
+++ b/builtin-describe.c
@@ -188,8 +188,11 @@ static void describe(const char *arg, int last_one)
 				sha1_to_hex(gave_up_on->object.sha1));
 		}
 	}
-	printf("%s-g%s\n", all_matches[0].name->path,
-		   find_unique_abbrev(cmit->object.sha1, abbrev));
+	if (abbrev == 0)
+		printf("%s\n", all_matches[0].name->path );
+	else
+		printf("%s-g%s\n", all_matches[0].name->path,
+			   find_unique_abbrev(cmit->object.sha1, abbrev));
 
 	if (!last_one)
 		clear_commit_marks(cmit, -1);
@@ -212,7 +215,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
 			tags = 1;
 		else if (!strncmp(arg, "--abbrev=", 9)) {
 			abbrev = strtoul(arg + 9, NULL, 10);
-			if (abbrev < MINIMUM_ABBREV || 40 < abbrev)
+			if (abbrev != 0 && (abbrev < MINIMUM_ABBREV || 40 < abbrev))
 				abbrev = DEFAULT_ABBREV;
 		}
 		else if (!strncmp(arg, "--candidates=", 13)) {
-- 
1.5.0.rc2.gc3537-dirty

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

* Re: [PATCH 1/2] Teach git-describe to display distances from tags.
  2007-01-26 13:33 ` [PATCH 1/2] Teach git-describe to display distances from tags Jakub Narebski
@ 2007-01-26 19:37   ` Matthias Lederhofer
  0 siblings, 0 replies; 15+ messages in thread
From: Matthias Lederhofer @ 2007-01-26 19:37 UTC (permalink / raw)
  To: Jakub Narebski; +Cc: git

Jakub Narebski <jnareb@gmail.com> wrote:
> I'd rather use "%s+%i-g%s\n" here...
Ack, this makes it much easier to recognise what this number is.

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

end of thread, other threads:[~2007-01-26 19:37 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-01-25 17:39 [PATCH 1/2] Teach git-describe to display distances from tags Shawn O. Pearce
2007-01-25 21:26 ` Junio C Hamano
2007-01-25 21:37   ` Shawn O. Pearce
2007-01-25 21:42   ` Junio C Hamano
2007-01-25 21:49     ` Shawn O. Pearce
2007-01-25 23:32       ` Nicolas Pitre
2007-01-26  0:13         ` Junio C Hamano
2007-01-26  8:52           ` Francis Moreau
2007-01-26  9:00             ` Junio C Hamano
2007-01-26  9:39               ` Francis Moreau
2007-01-26  9:51                 ` Shawn O. Pearce
2007-01-26 10:36           ` Andy Parkins
2007-01-26 14:28             ` [PATCH] If abbrev is set to zero in git-describe, don't add the unique suffix Andy Parkins
2007-01-26 13:33 ` [PATCH 1/2] Teach git-describe to display distances from tags Jakub Narebski
2007-01-26 19:37   ` Matthias Lederhofer

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).