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

Re: [PATCH] git-describe: Die early if there are no possible descriptions

From
Shawn O. Pearce <spearce@spearce.org>
Date
Aug 5, 2009, 15:34 UTC
Message-ID
<20090805153411.GG1033@spearce.org>
In-Reply-To
<20090805141740.GA16846@atjola.homenet>
Bj?rn Steinbrink <B.Steinbrink@gmx.de> wrote:
Show 16 quoted lines
> If we found no refs that may be used for git-describe with the current
> options, then die early instead of pointlessly walking the whole history.
> 
> Signed-off-by: Bj?rn Steinbrink <B.Steinbrink@gmx.de>
> ---
> In git.git with all the tags dropped, this makes "git describe" go down
> from 0.244 to 0.003 seconds for me. This is especially noticeable with
> "git submodule" which calls describe with increasing levels of allowed
> refs to be matched. Without tags, this means that it walks the whole
> history in the submodule twice (first annotated, then plain tags), just
> to find out that it can't describe the thing anyway.
> 
> I'm not particularly sure about found_names actually counting the found
> names, it was just out of the thought that maybe the walking code could
> make use of it, but I didn't actually check that and ran out of time, so
> I'm sending this version, hoping that it doesn't suck too much.

This seems reasonable to me. Really you don't need found_names to be a counter, but could just always set it to 1 every time the add_to_known_names function is called. All you care about is that add_to_known_names was invoked at least once.

Also, I really think that first paragraph after the --- should have been part of the commit message. The message above doesn't justify the change, even if it is fairly trivial, without that additional explanation.

Show 9 quoted lines
> @@ -39,6 +40,8 @@ static void add_to_known_names(const char *path,
>  			       const unsigned char *sha1)
>  {
>  	struct commit_name *e = commit->util;
> +	if (!e)
> +		found_names++;
>  	if (!e || e->prio < prio) {
>  		size_t len = strlen(path)+1;
>  		free(e);
-- 
Shawn.
Previous: Björn SteinbrinkNext: Björn Steinbrink
Message 2 of 4 in “git-describe: Die early if there are no possible descriptions”
  1. git-describe: Die early if there are no possible descriptionsBjörn Steinbrink, Aug 5, 2009
  2. Shawn O. PearceAug 5, 2009
  3. Björn SteinbrinkAug 5, 2009
  4. git-describe: Die early if there are no possible descriptionsBjörn Steinbrink, Aug 6, 2009

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.