Re: [PATCH v4 14/18] sha1_name.c: many short names can only be committish
Junio C Hamano <gitster@pobox.com> writes:
Show 9 quoted lines
> diff --git a/sha1_name.c b/sha1_name.c
> index 6f6c49c..35ad473 100644
> --- a/sha1_name.c
> +++ b/sha1_name.c
> @@ -519,6 +539,7 @@ static int peel_onion(const char *name, int len, unsigned char *sha1)
> unsigned char outer[20];
> const char *sp;
> unsigned int expected_type = 0;
> + unsigned lookup_flags;
This needs to be initialized to 0, i.e.
unsigned lookup_flags = 0;
for the following two hunks to make sense.
Show 21 quoted lines
> @@ -554,7 +575,10 @@ static int peel_onion(const char *name, int len, unsigned char *sha1)
> else
> return -1;
>
> - if (get_sha1_1(name, sp - name - 2, outer, 0))
> + if (expected_type == OBJ_COMMIT)
> + lookup_flags = GET_SHA1_COMMITTISH;
> +
> + if (get_sha1_1(name, sp - name - 2, outer, lookup_flags))
> return -1;
>
> o = parse_object(outer);
> @@ -666,7 +690,7 @@ static int get_sha1_1(const char *name, int len, unsigned char *sha1, unsigned l
> if (!ret)
> return 0;
>
> - return get_short_sha1(name, len, sha1, 0);
> + return get_short_sha1(name, len, sha1, lookup_flags);
> }
>
> /*