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

Re: git describe fails without tags

From
Junio C Hamano <junkio@cox.net>
Date
Jan 26, 2006, 09:02 UTC
Message-ID
<7vr76vgy4r.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20060126084151.GB2941@informatik.uni-freiburg.de>
Uwe Zeisberger <zeisberg@informatik.uni-freiburg.de> writes:
> I see two things to fix in that patch:
>
>  1) define DEFAULT_ABBREV (e.g. by moving it to cache.h, where
>     find_unique_abbrev is defined.)

Sorry, the patch alone was not compilable since cleaning up the definition of symbolic constants *_ABBREV comes before the patch you quoted in the "pu" branch.

>  2) describe.c allows only abbrev >= 4.  (Allowing values less than 2
>     failes, because find_short_object_filename (and maybe others) assume
>     len to be at least 2.)  I think 4 is sensible.

Thanks. "rev-parse --abbrev=2" would have segfaulted without your fix. I suspect substituting with MINIMUM instead of DEFAULT in such a case would be more sensible, so...

-- >8 -- [PATCH] rev-parse --abbrev: do not try abbrev shorter than minimum.

We do not allow abbreviation shorter than 4 letters in other parts of the system so do not attempt to generate such.

Noticed by Uwe Zeisberger.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
 rev-parse.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
030d25d271adb2671f560b410d77585d8744acbf
diff --git a/rev-parse.c b/rev-parse.c
index 42969a6..8bf316e 100644
--- a/rev-parse.c
+++ b/rev-parse.c
@@ -206,8 +206,10 @@ int main(int argc, char **argv)
 				abbrev = DEFAULT_ABBREV;
 				if (arg[8] == '=')
 					abbrev = strtoul(arg + 9, NULL, 10);
-				if (abbrev < 0 || 40 <= abbrev)
-					abbrev = DEFAULT_ABBREV;
+				if (abbrev < MINIMUM_ABBREV)
+					abbrev = MINIMUM_ABBREV;
+				else if (40 <= abbrev)
+					abbrev = 40;
 				continue;
 			}
 			if (!strcmp(arg, "--sq")) {
-- 
1.1.4.g00a4
Previous: Uwe Zeisberger
Message 7 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.