Re: [PATCH 03/14] builtin/update-ref: skip ambiguity checks when parsing object IDs
- From
Karthik Nayak <karthik.188@gmail.com>
- Date
- Feb 18, 2025, 16:04 UTC
- Message-ID
- <CAOLa=ZRJLDKKu4R0TVn7z4LVZ6pirCN+5VpiehJ2grdfHGe7ew@mail.gmail.com>
- In-Reply-To
- <20250217-pks-update-ref-optimization-v1-3-a2b6d87a24af@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
[snip]
Show 24 quoted lines
> diff --git a/builtin/update-ref.c b/builtin/update-ref.c
> index 4d35bdc4b4b..ac330748244 100644
> --- a/builtin/update-ref.c
> +++ b/builtin/update-ref.c
> @@ -179,7 +179,8 @@ static int parse_next_oid(const char **next, const char *end,
> (*next)++;
> *next = parse_arg(*next, &arg);
> if (arg.len) {
> - if (repo_get_oid(the_repository, arg.buf, oid))
> + if (repo_get_oid_with_flags(the_repository, arg.buf, oid,
> + GET_OID_HASH_SKIP_AMBIGUITY_CHECK))
> goto invalid;
> } else {
> /* Without -z, an empty value means all zeros: */
> @@ -197,7 +198,8 @@ static int parse_next_oid(const char **next, const char *end,
> *next += arg.len;
>
> if (arg.len) {
> - if (repo_get_oid(the_repository, arg.buf, oid))
> + if (repo_get_oid_with_flags(the_repository, arg.buf, oid,
> + GET_OID_HASH_SKIP_AMBIGUITY_CHECK))
> goto invalid;
> } else if (flags & PARSE_SHA1_ALLOW_EMPTY) {
> /* With -z, treat an empty value as all zeros: */So the above two instances are used within the individual sub-commands for `--stdin` mode. The symref commands use `parse_refname()` for parsing refnames, so all good.
Show 20 quoted lines
> @@ -772,7 +774,8 @@ int cmd_update_ref(int argc,
> refname = argv[0];
> value = argv[1];
> oldval = argv[2];
> - if (repo_get_oid(the_repository, value, &oid))
> + if (repo_get_oid_with_flags(the_repository, value, &oid,
> + GET_OID_HASH_SKIP_AMBIGUITY_CHECK))
> die("%s: not a valid SHA1", value);
> }
>
> @@ -783,7 +786,8 @@ int cmd_update_ref(int argc,
> * must not already exist:
> */
> oidclr(&oldoid, the_repository->hash_algo);
> - else if (repo_get_oid(the_repository, oldval, &oldoid))
> + else if (repo_get_oid_with_flags(the_repository, oldval, &oldoid,
> + GET_OID_HASH_SKIP_AMBIGUITY_CHECK))
> die("%s: not a valid old SHA1", oldval);
> }
>This is when the user uses 'git update-ref' directly. Makes sense.
> > -- > 2.48.1.666.gff9fcf71b7.dirty