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