git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] describe: fall back to 'HEAD' if no appropriate tag exists

From
Junio C Hamano <junkio@cox.net>
Date
Sep 20, 2006, 22:46 UTC
Message-ID
<7v8xkef97b.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<Pine.LNX.4.63.0609202324210.19042@wbgn013.biozentrum.uni-wuerzburg.de>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 19 quoted lines
> Now, if no tag exists to say something like '<tag>-gfffffff', say
> 'HEAD-gfffffff' instead of erroring out.
>
> Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
> ---
>  describe.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/describe.c b/describe.c
> index ab192f8..8b08a3f 100644
> --- a/describe.c
> +++ b/describe.c
> @@ -136,7 +136,7 @@ static void describe(const char *arg, in
>  			return;
>  		}
>  	}
> -	die("cannot describe '%s'", sha1_to_hex(cmit->object.sha1));
> +	printf("HEAD-g%s\n", find_unique_abbrev(cmit->object.sha1, abbrev));
>  }
Hmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm.

At least with tags, the user can assume NAME-gREV means commit whose abbrev is REV that is descendant of NAME. HEAD is not necessarily so.

Having said that, in order to avoid barfing, we have to have something there, and HEAD is already special in many aspects anyway (e.g. by only saying HEAD you cannot tell which branch's tip you are talking about), it might be good enough.

I am just wondering if there is some other obvious substitute that is better than HEAD. "GIT-g%s" is not it ("g" already stands for GIT).

Another possibility is just to do
        puts(sha1_to_hex(cmit->object.sha1))

in this case. I tend to like that better somehow; it makes things more explicit.

Previous: Johannes SchindelinNext: Johannes Schindelin
Message 2 of 4 in “describe: fall back to 'HEAD' if no appropriate tag exists”
  1. describe: fall back to 'HEAD' if no appropriate tag existsJohannes Schindelin, Sep 20, 2006
  2. Junio C HamanoSep 20, 2006
  3. Johannes SchindelinSep 20, 2006
  4. Andy WhitcroftSep 21, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.