Skip to content

Commit 37e7546

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 08bdfd4 commit 37e7546

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

object-name.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1794,18 +1794,20 @@ void object_context_release(struct object_context *ctx)
17941794
strbuf_release(&ctx->symlink_path);
17951795
}
17961796

1797-
/*
1798-
* This is like "get_oid_basic()", except it allows "object ID expressions",
1799-
* notably "xyz^" for "parent of xyz"
1800-
*/
1801-
int repo_get_oid(struct repository *r, const char *name, struct object_id *oid)
1797+
int repo_get_oid_with_flags(struct repository *r, const char *name,
1798+
struct object_id *oid, unsigned flags)
18021799
{
18031800
struct object_context unused;
1804-
int ret = get_oid_with_context(r, name, 0, oid, &unused);
1801+
int ret = get_oid_with_context(r, name, flags, oid, &unused);
18051802
object_context_release(&unused);
18061803
return ret;
18071804
}
18081805

1806+
int repo_get_oid(struct repository *r, const char *name, struct object_id *oid)
1807+
{
1808+
return repo_get_oid_with_flags(r, name, oid, 0);
1809+
}
1810+
18091811
/*
18101812
* This returns a non-zero value if the string (built using printf
18111813
* format and the given arguments) is not a valid object.

object-name.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ void strbuf_repo_add_unique_abbrev(struct strbuf *sb, struct repository *repo,
5151
void strbuf_add_unique_abbrev(struct strbuf *sb, const struct object_id *oid,
5252
int abbrev_len);
5353

54+
/*
55+
* This is like "get_oid_basic()", except it allows "object ID expressions",
56+
* notably "xyz^" for "parent of xyz". Accepts GET_OID_* flags.
57+
*/
58+
int repo_get_oid_with_flags(struct repository *r, const char *str,
59+
struct object_id *oid, unsigned flags);
5460
int repo_get_oid(struct repository *r, const char *str, struct object_id *oid);
5561
__attribute__((format (printf, 2, 3)))
5662
int get_oidf(struct object_id *oid, const char *fmt, ...);

0 commit comments

Comments
 (0)