Skip to content

Commit 2764fd9

Browse files
bk2204gitster
authored andcommitted
sha1-name: introduce a get_oid() function
The get_oid() function is equivalent to the get_sha1() function, but uses a struct object_id instead. Signed-off-by: brian m. carlson <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 90f7b16 commit 2764fd9

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

cache.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,6 +1124,8 @@ extern int get_sha1_blob(const char *str, unsigned char *sha1);
11241124
extern void maybe_die_on_misspelt_object_name(const char *name, const char *prefix);
11251125
extern int get_sha1_with_context(const char *str, unsigned flags, unsigned char *sha1, struct object_context *orc);
11261126

1127+
extern int get_oid(const char *str, struct object_id *oid);
1128+
11271129
typedef int each_abbrev_fn(const unsigned char *sha1, void *);
11281130
extern int for_each_abbrev(const char *prefix, each_abbrev_fn, void *);
11291131

sha1_name.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,6 +1214,15 @@ int get_sha1(const char *name, unsigned char *sha1)
12141214
return get_sha1_with_context(name, 0, sha1, &unused);
12151215
}
12161216

1217+
/*
1218+
* This is like "get_sha1()", but for struct object_id.
1219+
*/
1220+
int get_oid(const char *name, struct object_id *oid)
1221+
{
1222+
return get_sha1(name, oid->hash);
1223+
}
1224+
1225+
12171226
/*
12181227
* Many callers know that the user meant to name a commit-ish by
12191228
* syntactical positions where the object name appears. Calling this

0 commit comments

Comments
 (0)