On Thu, Sep 29, 2016 at 8:54 PM, Junio C Hamano <[email protected]> wrote:
>
> * The script uses "git rev-parse --short HEAD"; I suspect that it
> says "ah, default_abbrev is -1 and minimum_abbrev is 4, so let's
> try abbreviating to 4 hexdigits".
Ahh, right you are. The logic there is
abbrev = DEFAULT_ABBREV;
if (arg[7] == '=')
abbrev = strtoul(arg + 8, NULL, 10);
if (abbrev < MINIMUM_ABBREV)
abbrev = MINIMUM_ABBREV;
....
which now does something different than what it used to do because
DEFAULT_ABBREV is -1.
Putting the "sanity-check the abbrev range" tests inside the "if()"
statement that does strtoul() should fix it. Let me test...
[ short time passes ]
Yup. Incremental patch for that single issue attached. I made it do
an early "continue" instead of adding another level on indentation.
Linus
builtin/rev-parse.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index 4da1f1da2..cfb0f1510 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -671,8 +671,9 @@ int cmd_rev_parse(int argc, const char **argv, const char
*prefix)
filter &= ~(DO_FLAGS|DO_NOREV);
verify = 1;
abbrev = DEFAULT_ABBREV;
- if (arg[7] == '=')
- abbrev = strtoul(arg + 8, NULL, 10);
+ if (!arg[7])
+ continue;
+ abbrev = strtoul(arg + 8, NULL, 10);
if (abbrev < MINIMUM_ABBREV)
abbrev = MINIMUM_ABBREV;
else if (40 <= abbrev)