object-name: introduce repo_get_oid_with_flags()

Introduce a new function `repo_get_oid_with_flags()`. This function
behaves the same as `repo_get_oid()`, except that it takes an extra
`flags` parameter that it ends up passing to `get_oid_with_context()`.

This function will be used in a subsequent commit.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Patrick Steinhardt
2025-03-12 16:56:07 +01:00
committed by Junio C Hamano
parent 08bdfd4535
commit 37e7546b91
2 changed files with 14 additions and 6 deletions

View File

@@ -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)
{
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.