summaryrefslogtreecommitdiff
path: root/cache.h
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-03-17 20:50:24 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-03-17 20:50:25 (GMT)
commite1fae930193b3e8ff02cee936605625f63e1d1e4 (patch)
tree90ad9f3e50d1f1d6acd174ecb4dc0a8bbc28df27 /cache.h
parent0a4ae91d1cf72b1185a46e5f072ac6b25b92350b (diff)
parente86ab2c1cd60ec4b9214e5cd8450a474fa175f5c (diff)
downloadgit-e1fae930193b3e8ff02cee936605625f63e1d1e4.zip
git-e1fae930193b3e8ff02cee936605625f63e1d1e4.tar.gz
git-e1fae930193b3e8ff02cee936605625f63e1d1e4.tar.bz2
Merge branch 'bc/object-id'
"uchar [40]" to "struct object_id" conversion continues. * bc/object-id: wt-status: convert to struct object_id builtin/merge-base: convert to struct object_id Convert object iteration callbacks to struct object_id sha1_file: introduce an nth_packed_object_oid function refs: simplify parsing of reflog entries refs: convert each_reflog_ent_fn to struct object_id reflog-walk: convert struct reflog_info to struct object_id builtin/replace: convert to struct object_id Convert remaining callers of resolve_refdup to object_id builtin/merge: convert to struct object_id builtin/clone: convert to struct object_id builtin/branch: convert to struct object_id builtin/grep: convert to struct object_id builtin/fmt-merge-message: convert to struct object_id builtin/fast-export: convert to struct object_id builtin/describe: convert to struct object_id builtin/diff-tree: convert to struct object_id builtin/commit: convert to struct object_id hex: introduce parse_oid_hex
Diffstat (limited to 'cache.h')
-rw-r--r--cache.h19
1 files changed, 17 insertions, 2 deletions
diff --git a/cache.h b/cache.h
index d3265cc..dc261f4 100644
--- a/cache.h
+++ b/cache.h
@@ -1364,6 +1364,15 @@ extern char *sha1_to_hex(const unsigned char *sha1); /* static buffer result! */
extern char *oid_to_hex(const struct object_id *oid); /* same static buffer as sha1_to_hex */
/*
+ * Parse a 40-character hexadecimal object ID starting from hex, updating the
+ * pointer specified by end when parsing stops. The resulting object ID is
+ * stored in oid. Returns 0 on success. Parsing will stop on the first NUL or
+ * other invalid character. end is only updated on success; otherwise, it is
+ * unmodified.
+ */
+extern int parse_oid_hex(const char *hex, struct object_id *oid, const char **end);
+
+/*
* This reads short-hand syntax that not only evaluates to a commit
* object name, but also can act as if the end user spelled the name
* of the branch from the command line.
@@ -1673,6 +1682,12 @@ extern void check_pack_index_ptr(const struct packed_git *p, const void *ptr);
* error.
*/
extern const unsigned char *nth_packed_object_sha1(struct packed_git *, uint32_t n);
+/*
+ * Like nth_packed_object_sha1, but write the data into the object specified by
+ * the the first argument. Returns the first argument on success, and NULL on
+ * error.
+ */
+extern const struct object_id *nth_packed_object_oid(struct object_id *, struct packed_git *, uint32_t n);
/*
* Return the offset of the nth object within the specified packfile.
@@ -1714,7 +1729,7 @@ extern int unpack_object_header(struct packed_git *, struct pack_window **, off_
* scratch buffer, but restored to its original contents before
* the function returns.
*/
-typedef int each_loose_object_fn(const unsigned char *sha1,
+typedef int each_loose_object_fn(const struct object_id *oid,
const char *path,
void *data);
typedef int each_loose_cruft_fn(const char *basename,
@@ -1740,7 +1755,7 @@ int for_each_loose_file_in_objdir_buf(struct strbuf *path,
* LOCAL_ONLY flag is set).
*/
#define FOR_EACH_OBJECT_LOCAL_ONLY 0x1
-typedef int each_packed_object_fn(const unsigned char *sha1,
+typedef int each_packed_object_fn(const struct object_id *oid,
struct packed_git *pack,
uint32_t pos,
void *data);