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

Re: git describe fails without tags

From
Uwe Zeisberger <zeisberg@informatik.uni-freiburg.de>
Date
Jan 26, 2006, 07:44 UTC
Message-ID
<20060126074421.GA2941@informatik.uni-freiburg.de>
In-Reply-To
<7vek2wws61.fsf@assigned-by-dhcp.cox.net>
Hello Junio,
Junio C Hamano wrote:
Show 15 quoted lines
> Uwe Zeisberger <zeisberg@informatik.uni-freiburg.de> writes:
> 
> > I wonder if it would be sane to assume an implicit tag for the empty
> > repository, s.t. git describe results in 
> >
> > 	<empty>-62ac6c16
> >
> > (whatever name is choosen for <empty>).
> >
> > Any opinions?
>
> [...] If the reason you are doing "describe" is to find out an usable
> abbreviated name, you could feed the first few hexdigits to "git
> rev-parse --verify", lengthening the prefix longer by one until it
> says you have a unique prefix [*1*].
Yes, I wrote a script that automatically build git and install it to
${HOME}/usr/stow/git-`git describe HEAD` and then stow(8)s it.  Writing
a similar script for sparse cannot use git describe because there are no
tags ...
 
Show 16 quoted lines
> In other words, not particularly interested, although it is
> trivial to implement, like this:
> 
> diff --git a/describe.c b/describe.c
> index 4866510..aeaf0fb 100644
> --- a/describe.c
> +++ b/describe.c
> @@ -137,7 +137,7 @@ static void describe(char *arg, int last
>  			return;
>  		}
>  	}
> -	die("cannot describe '%s'", sha1_to_hex(cmit->object.sha1));
> +	printf("%s\n", find_unique_abbrev(cmit->object.sha1, abbrev));
>  }
>  
>  int main(int argc, char **argv)

It's a pity your not particularly interested, I like that patch's idea. git describe dies with an error here in a situation where there is the possibility to do something sensible.

BTW, for the sake of consistency, I'd suggest

- die("cannot describe '%s'", sha1_to_hex(cmit->object.sha1)); + printf("g%s\n", find_unique_abbrev(cmit->object.sha1, abbrev));

Best regards Uwe

-- 
Uwe Zeisberger

http://www.google.com/search?q=1+year+divided+by+3+in+seconds
Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 7 in “git describe fails without tags”
  1. Uwe ZeisbergerJan 25, 2006
  2. Junio C HamanoJan 25, 2006
  3. Uwe ZeisbergerJan 26, 2006
  4. Junio C HamanoJan 26, 2006
  5. Uwe ZeisbergerJan 26, 2006
  6. Uwe ZeisbergerJan 26, 2006
  7. Junio C HamanoJan 26, 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.