summaryrefslogtreecommitdiff
path: root/replace_object.c
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2018-04-10 08:25:45 +0900
committerLibravatar Junio C Hamano <gitster@pobox.com>2018-04-10 08:25:45 +0900
commita5bbc29994b22ab0b57c4dc9568a261d32476e94 (patch)
tree4cf0247ad3bac3f8130f83a2f9b40197a24fab0f /replace_object.c
parentMerge branch 'ma/shortlog-revparse' (diff)
parentconvert: convert to struct object_id (diff)
downloadtgif-a5bbc29994b22ab0b57c4dc9568a261d32476e94.tar.xz
Merge branch 'bc/object-id'
Conversion from uchar[20] to struct object_id continues. * bc/object-id: (36 commits) convert: convert to struct object_id sha1_file: introduce a constant for max header length Convert lookup_replace_object to struct object_id sha1_file: convert read_sha1_file to struct object_id sha1_file: convert read_object_with_reference to object_id tree-walk: convert tree entry functions to object_id streaming: convert istream internals to struct object_id tree-walk: convert get_tree_entry_follow_symlinks internals to object_id builtin/notes: convert static functions to object_id builtin/fmt-merge-msg: convert remaining code to object_id sha1_file: convert sha1_object_info* to object_id Convert remaining callers of sha1_object_info_extended to object_id packfile: convert unpack_entry to struct object_id sha1_file: convert retry_bad_packed_offset to struct object_id sha1_file: convert assert_sha1_type to object_id builtin/mktree: convert to struct object_id streaming: convert open_istream to use struct object_id sha1_file: convert check_sha1_signature to struct object_id sha1_file: convert read_loose_object to use struct object_id builtin/index-pack: convert struct ref_delta_entry to object_id ...
Diffstat (limited to 'replace_object.c')
-rw-r--r--replace_object.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/replace_object.c b/replace_object.c
index 3e49965d05..336357394d 100644
--- a/replace_object.c
+++ b/replace_object.c
@@ -8,8 +8,8 @@
* sha1.
*/
static struct replace_object {
- unsigned char original[20];
- unsigned char replacement[20];
+ struct object_id original;
+ struct object_id replacement;
} **replace_object;
static int replace_object_alloc, replace_object_nr;
@@ -17,7 +17,7 @@ static int replace_object_alloc, replace_object_nr;
static const unsigned char *replace_sha1_access(size_t index, void *table)
{
struct replace_object **replace = table;
- return replace[index]->original;
+ return replace[index]->original.hash;
}
static int replace_object_pos(const unsigned char *sha1)
@@ -29,7 +29,7 @@ static int replace_object_pos(const unsigned char *sha1)
static int register_replace_object(struct replace_object *replace,
int ignore_dups)
{
- int pos = replace_object_pos(replace->original);
+ int pos = replace_object_pos(replace->original.hash);
if (0 <= pos) {
if (ignore_dups)
@@ -59,14 +59,14 @@ static int register_replace_ref(const char *refname,
const char *hash = slash ? slash + 1 : refname;
struct replace_object *repl_obj = xmalloc(sizeof(*repl_obj));
- if (strlen(hash) != 40 || get_sha1_hex(hash, repl_obj->original)) {
+ if (get_oid_hex(hash, &repl_obj->original)) {
free(repl_obj);
warning("bad replace ref name: %s", refname);
return 0;
}
/* Copy sha1 from the read ref */
- hashcpy(repl_obj->replacement, oid->hash);
+ oidcpy(&repl_obj->replacement, oid);
/* Register new object */
if (register_replace_object(repl_obj, 1))
@@ -92,16 +92,16 @@ static void prepare_replace_object(void)
#define MAXREPLACEDEPTH 5
/*
- * If a replacement for object sha1 has been set up, return the
+ * If a replacement for object oid has been set up, return the
* replacement object's name (replaced recursively, if necessary).
- * The return value is either sha1 or a pointer to a
+ * The return value is either oid or a pointer to a
* permanently-allocated value. This function always respects replace
* references, regardless of the value of check_replace_refs.
*/
-const unsigned char *do_lookup_replace_object(const unsigned char *sha1)
+const struct object_id *do_lookup_replace_object(const struct object_id *oid)
{
int pos, depth = MAXREPLACEDEPTH;
- const unsigned char *cur = sha1;
+ const struct object_id *cur = oid;
prepare_replace_object();
@@ -109,11 +109,11 @@ const unsigned char *do_lookup_replace_object(const unsigned char *sha1)
do {
if (--depth < 0)
die("replace depth too high for object %s",
- sha1_to_hex(sha1));
+ oid_to_hex(oid));
- pos = replace_object_pos(cur);
+ pos = replace_object_pos(cur->hash);
if (0 <= pos)
- cur = replace_object[pos]->replacement;
+ cur = &replace_object[pos]->replacement;
} while (0 <= pos);
return cur;