replace_object: convert struct replace_object to object_id
Convert the two members of this struct to be instances of struct object_id. Adjust the various functions in this file accordingly. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
brian m. carlson committed
Mar 12, 2018 at 02:27 UTC
1731a1e2393da0117dcd09f17ae430c51f860c54
1 file changed
+7
-7
replace_object.c
+7
-7
@@ -8,8 +8,8 @@
8
* sha1.
9
*/
10
static struct replace_object {
11
- unsigned char original[20];
12
- unsigned char replacement[20];
11
+ struct object_id original;
12
+ struct object_id replacement;
13
} **replace_object;
14
15
static int replace_object_alloc, replace_object_nr;
@@ -17,7 +17,7 @@ static int replace_object_alloc, replace_object_nr;
17
static const unsigned char *replace_sha1_access(size_t index, void *table)
18
{
19
struct replace_object **replace = table;
20
- return replace[index]->original;
20
+ return replace[index]->original.hash;
21
}
22
23
static int replace_object_pos(const unsigned char *sha1)
@@ -29,7 +29,7 @@ static int replace_object_pos(const unsigned char *sha1)
29
static int register_replace_object(struct replace_object *replace,
30
int ignore_dups)
31
{
32
- int pos = replace_object_pos(replace->original);
32
+ int pos = replace_object_pos(replace->original.hash);
33
34
if (0 <= pos) {
35
if (ignore_dups)
@@ -59,14 +59,14 @@ static int register_replace_ref(const char *refname,
59
const char *hash = slash ? slash + 1 : refname;
60
struct replace_object *repl_obj = xmalloc(sizeof(*repl_obj));
61
62
- if (strlen(hash) != 40 || get_sha1_hex(hash, repl_obj->original)) {
62
+ if (get_oid_hex(hash, &repl_obj->original)) {
63
free(repl_obj);
64
warning("bad replace ref name: %s", refname);
65
return 0;
66
}
67
68
/* Copy sha1 from the read ref */
69
- hashcpy(repl_obj->replacement, oid->hash);
69
+ oidcpy(&repl_obj->replacement, oid);
70
71
/* Register new object */
72
if (register_replace_object(repl_obj, 1))
@@ -113,7 +113,7 @@ const unsigned char *do_lookup_replace_object(const unsigned char *sha1)
113
114
pos = replace_object_pos(cur);
115
if (0 <= pos)
116
- cur = replace_object[pos]->replacement;
116
+ cur = replace_object[pos]->replacement.hash;
117
} while (0 <= pos);
118
119
return cur;