Re: [PATCH v2 01/16] object-name: introduce `repo_get_oid_with_flags()`
- From
Justin Tobler <jltobler@gmail.com>
- Date
- Feb 19, 2025, 17:02 UTC
- Message-ID
- <5qatn3wcp4ili3dyz6edzvp5ydsydh523cfz5syqz75afiuvbh@67ndxkvkbxnb>
- In-Reply-To
- <20250219-pks-update-ref-optimization-v2-1-e696e7220b22@pks.im>
On 25/02/19 02:23PM, Patrick Steinhardt wrote: [snip]
Show 15 quoted lines
> diff --git a/object-name.c b/object-name.c > index 945d5bdef25..bc0265ad2a1 100644 > --- a/object-name.c > +++ b/object-name.c > @@ -1794,18 +1794,20 @@ void object_context_release(struct object_context *ctx) > strbuf_release(&ctx->symlink_path); > } > > -/* > - * This is like "get_oid_basic()", except it allows "object ID expressions", > - * notably "xyz^" for "parent of xyz" > - */ > -int repo_get_oid(struct repository *r, const char *name, struct object_id *oid) > +int repo_get_oid_with_flags(struct repository *r, const char *name, struct object_id *oid, > + unsigned flags)
style: The function signature runs a bit long on the first line. Not a big deal, but we could reformat it.
Show 30 quoted lines
> {
> struct object_context unused;
> - int ret = get_oid_with_context(r, name, 0, oid, &unused);
> + int ret = get_oid_with_context(r, name, flags, oid, &unused);
> object_context_release(&unused);
> return ret;
> }
>
> +int repo_get_oid(struct repository *r, const char *name, struct object_id *oid)
> +{
> + return repo_get_oid_with_flags(r, name, oid, 0);
> +}
> +
> /*
> * This returns a non-zero value if the string (built using printf
> * format and the given arguments) is not a valid object.
> diff --git a/object-name.h b/object-name.h
> index 8dba4a47a47..fb5a97b2c8e 100644
> --- a/object-name.h
> +++ b/object-name.h
> @@ -51,6 +51,12 @@ void strbuf_repo_add_unique_abbrev(struct strbuf *sb, struct repository *repo,
> void strbuf_add_unique_abbrev(struct strbuf *sb, const struct object_id *oid,
> int abbrev_len);
>
> +/*
> + * This is like "get_oid_basic()", except it allows "object ID expressions",
> + * notably "xyz^" for "parent of xyz". Accepts GET_OID_* flags.
> + */
> +int repo_get_oid_with_flags(struct repository *r, const char *str, struct object_id *oid,
> + unsigned flags);Same here.
Show 8 quoted lines
> int repo_get_oid(struct repository *r, const char *str, struct object_id *oid); > __attribute__((format (printf, 2, 3))) > int get_oidf(struct object_id *oid, const char *fmt, ...); > > -- > 2.48.1.683.gf705b3209c.dirty > >