git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* "git describe" documentation and behavior mismatch
@ 2017-11-30 18:47 Daniel Knittl-Frank
  2017-11-30 19:26 ` Daniel Knittl-Frank
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Knittl-Frank @ 2017-11-30 18:47 UTC (permalink / raw)
  To: git@vger.kernel.org

Hi Git list,

the help page/manpage of the git describe command has an example with
the --all flag which should prepend the ref namespace (tags/ or
heads/):

> With --all, the command can use branch heads as references, so the output shows the reference path as well:
>
>          [torvalds@g5 git]$ git describe --all --abbrev=4 v1.0.5^2
>          tags/v1.0.0-21-g975b
>
>          [torvalds@g5 git]$ git describe --all --abbrev=4 HEAD^
>          heads/lt/describe-7-g975b

Running the above commands in the git.git repository yields a different result:

>     $ git describe --all --abbrev=4 v1.0.5^2
>     v1.0.0-21-g975b3

No "reference path" to see. It is however shown, when the output is a
branch name:

>     $ git describe --all --abbrev=4 origin/next
>     heads/next

Is this expected behavior? IOW is the documentation outdated or is the
git describe command misbehaving?

Thanks,
Daniel

-- 
typed with http://neo-layout.org

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

* Re: "git describe" documentation and behavior mismatch
  2017-11-30 18:47 "git describe" documentation and behavior mismatch Daniel Knittl-Frank
@ 2017-11-30 19:26 ` Daniel Knittl-Frank
  2017-12-03  5:39   ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Knittl-Frank @ 2017-11-30 19:26 UTC (permalink / raw)
  To: git@vger.kernel.org

On Thu, Nov 30, 2017 at 7:47 PM, Daniel Knittl-Frank
<knittl89@googlemail.com> wrote:
> […]
>
> Running the above commands in the git.git repository yields a different result:
>
>>     $ git describe --all --abbrev=4 v1.0.5^2
>>     v1.0.0-21-g975b3
>
> No "reference path" to see. It is however shown, when the output is a
> branch name:
>
>>     $ git describe --all --abbrev=4 origin/next
>>     heads/next
>
> Is this expected behavior? IOW is the documentation outdated or is the
> git describe command misbehaving?

Bisecting history goes as far back as Feb 2008: commit
212945d4a85dfa172ea55ec73b1d830ef2d8582f

> Teach git-describe to verify annotated tag names before output

The warning mentioned in the commit message has since been gone. So I
guess the documentation is outdated? Nobody has complained for the
past 9 years, so we could call this a "feature" :)

An interesting fact (and intentional behavior?) is that describing a
commit with only a lightweight tag will properly display the tags/
prefix. I assume this is because the annotated tags only store the
tagname without any ref namespace, which is then picked up by git
describe and displayed.

I will try to come up with a patch for the man page.

Daniel

-- 
typed with http://neo-layout.org

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

* Re: "git describe" documentation and behavior mismatch
  2017-11-30 19:26 ` Daniel Knittl-Frank
@ 2017-12-03  5:39   ` Junio C Hamano
  2017-12-11 18:34     ` Daniel Knittl-Frank
  0 siblings, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2017-12-03  5:39 UTC (permalink / raw)
  To: Daniel Knittl-Frank; +Cc: git@vger.kernel.org

Daniel Knittl-Frank <knittl89@googlemail.com> writes:

> An interesting fact (and intentional behavior?) is that describing a
> commit with only a lightweight tag will properly display the tags/
> prefix. I assume this is because the annotated tags only store the
> tagname without any ref namespace, which is then picked up by git
> describe and displayed.

I suspect that "see if the name recorded in the tag object matches
the name of the ref that stores the tag after refs/tags/" code *is*
not just verifying what it claims to (which may be good) but also
unintentionally affecting the output (i.e. "--all" promises that the
prefix tags/ should be shown).  Perhaps the code needs to be fixed
if that is the case.



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

* Re: "git describe" documentation and behavior mismatch
  2017-12-03  5:39   ` Junio C Hamano
@ 2017-12-11 18:34     ` Daniel Knittl-Frank
  2017-12-11 18:37       ` Daniel Knittl-Frank
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Knittl-Frank @ 2017-12-11 18:34 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git@vger.kernel.org

On Sun, Dec 3, 2017 at 6:39 AM, Junio C Hamano <gitster@pobox.com> wrote:
> I suspect that "see if the name recorded in the tag object matches
> the name of the ref that stores the tag after refs/tags/" code *is*
> not just verifying what it claims to (which may be good) but also
> unintentionally affecting the output (i.e. "--all" promises that the
> prefix tags/ should be shown).  Perhaps the code needs to be fixed
> if that is the case.

What is the course of action then? I wrote up a really dumb 2-line
patch which simply checks if --all was specified and prepends the
output with "tags/".

Good enough? Should we instead update the documentation? Still not
sure, what the behavior _should_ be in the case of annotated tags with
embedded names.

-- >8 --

From 7243d700aad280b11e647e04ade027c412dde54c Mon Sep 17 00:00:00 2001
From: Daniel Knittl-Frank <knittl89+git@googlemail.com>
Date: Mon, 11 Dec 2017 19:24:54 +0100
Subject: [PATCH] Prepend "tags/" when describing tags with embedded name

Signed-off-by: Daniel Knittl-Frank <knittl89+git@googlemail.com>
---
 builtin/describe.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/builtin/describe.c b/builtin/describe.c
index e14e162ef6..54aaf30562 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -272,6 +272,8 @@ static void display_name(struct commit_name *n)
     }

     if (n->tag)
+        if (all)
+            printf("tags/");
         printf("%s", n->tag->tag);
     else
         printf("%s", n->path);
-- 
2.15.GIT



-- 
typed with http://neo-layout.org

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

* Re: "git describe" documentation and behavior mismatch
  2017-12-11 18:34     ` Daniel Knittl-Frank
@ 2017-12-11 18:37       ` Daniel Knittl-Frank
  2017-12-15 19:25         ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Knittl-Frank @ 2017-12-11 18:37 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git@vger.kernel.org

Forget the above patch. I should compile my code after refactoring ...

Here is the fixed version.

-- >8 --

From 8203bd0ad5baab7024ebff597c9f35a0250d09ff Mon Sep 17 00:00:00 2001
From: Daniel Knittl-Frank <knittl89+git@googlemail.com>
Date: Mon, 11 Dec 2017 19:24:54 +0100
Subject: [PATCH] Prepend "tags/" when describing tags with embedded name

Signed-off-by: Daniel Knittl-Frank <knittl89+git@googlemail.com>
---
 builtin/describe.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/builtin/describe.c b/builtin/describe.c
index e14e162ef6..9da6d85ea3 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -271,10 +271,13 @@ static void display_name(struct commit_name *n)
         n->name_checked = 1;
     }

-    if (n->tag)
+    if (n->tag) {
+        if (all)
+            printf("tags/");
         printf("%s", n->tag->tag);
-    else
+    } else {
         printf("%s", n->path);
+    }
 }

 static void show_suffix(int depth, const struct object_id *oid)
-- 
2.15.GIT

-- 
typed with http://neo-layout.org

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

* Re: "git describe" documentation and behavior mismatch
  2017-12-11 18:37       ` Daniel Knittl-Frank
@ 2017-12-15 19:25         ` Junio C Hamano
  0 siblings, 0 replies; 6+ messages in thread
From: Junio C Hamano @ 2017-12-15 19:25 UTC (permalink / raw)
  To: Daniel Knittl-Frank; +Cc: git@vger.kernel.org

Daniel Knittl-Frank <knittl89@googlemail.com> writes:

> Forget the above patch. I should compile my code after refactoring ...
>
> Here is the fixed version.
>
> -- >8 --
>
> From 8203bd0ad5baab7024ebff597c9f35a0250d09ff Mon Sep 17 00:00:00 2001
> From: Daniel Knittl-Frank <knittl89+git@googlemail.com>
> Date: Mon, 11 Dec 2017 19:24:54 +0100
> Subject: [PATCH] Prepend "tags/" when describing tags with embedded name
>
> Signed-off-by: Daniel Knittl-Frank <knittl89+git@googlemail.com>
> ---
>  builtin/describe.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)

I think the code makes sense, but it won't be understandable by
those who do not know what you discussed in the original thread.

A proper commit log message, with a new test or two in t6120, would
be an appropriate way to fix that.

Care to follow through, along the lines in
Documentation/SubmittingPatches?

Thanks.

> diff --git a/builtin/describe.c b/builtin/describe.c
> index e14e162ef6..9da6d85ea3 100644
> --- a/builtin/describe.c
> +++ b/builtin/describe.c
> @@ -271,10 +271,13 @@ static void display_name(struct commit_name *n)
>          n->name_checked = 1;
>      }
>
> -    if (n->tag)
> +    if (n->tag) {
> +        if (all)
> +            printf("tags/");
>          printf("%s", n->tag->tag);
> -    else
> +    } else {
>          printf("%s", n->path);
> +    }
>  }
>
>  static void show_suffix(int depth, const struct object_id *oid)
> -- 
> 2.15.GIT

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

end of thread, other threads:[~2017-12-15 19:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-30 18:47 "git describe" documentation and behavior mismatch Daniel Knittl-Frank
2017-11-30 19:26 ` Daniel Knittl-Frank
2017-12-03  5:39   ` Junio C Hamano
2017-12-11 18:34     ` Daniel Knittl-Frank
2017-12-11 18:37       ` Daniel Knittl-Frank
2017-12-15 19:25         ` Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).