Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: Uwe Zeisberger <zeisberg@informatik.uni-freiburg.de>
Cc: git@vger.kernel.org
Subject: Re: git describe fails without tags
Date: Thu, 26 Jan 2006 01:02:44 -0800	[thread overview]
Message-ID: <7vr76vgy4r.fsf@assigned-by-dhcp.cox.net> (raw)
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

      reply	other threads:[~2006-01-26  9:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-25  7:47 git describe fails without tags Uwe Zeisberger
2006-01-25  9:52 ` Junio C Hamano
2006-01-26  7:44   ` Uwe Zeisberger
2006-01-26  8:07     ` Junio C Hamano
2006-01-26  8:45       ` Uwe Zeisberger
2006-01-26  8:41   ` Uwe Zeisberger
2006-01-26  9:02     ` Junio C Hamano [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vr76vgy4r.fsf@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=git@vger.kernel.org \
    --cc=zeisberg@informatik.uni-freiburg.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox