]> git.ipfire.org Git - thirdparty/git.git/commitdiff
object-name: introduce `repo_get_oid_with_flags()`
authorPatrick Steinhardt <ps@pks.im>
Wed, 12 Mar 2025 15:56:07 +0000 (16:56 +0100)
committerJunio C Hamano <gitster@pobox.com>
Wed, 12 Mar 2025 18:31:16 +0000 (11:31 -0700)
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>
object-name.c
object-name.h

index 945d5bdef25217c43e9501eca5d0a25d820ddab1..233f3f861e36817b21001793d8fa7c9bc2e2f293 100644 (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.
index 8dba4a47a470119a2a8a7f278bdf22f0058d92b2..cda4934cd5f7fbdbc9e5b4a5e623f302d1245a12 100644 (file)
@@ -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);
 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, ...);