Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
replace_object: convert struct replace_object to object_id
author
brian m. carlson
<sandals@crustytoothpaste.net>
Mon, 12 Mar 2018 02:27:33 +0000
(
02:27
+0000)
committer
Junio C Hamano
<gitster@pobox.com>
Wed, 14 Mar 2018 16:23:48 +0000
(09:23 -0700)
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>
replace_object.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
246d740
)
diff --git
a/replace_object.c
b/replace_object.c
index 3e49965d050829ad883e571d9b7c4596991aa974..232e8b855010da6cbeeec552557386c0ec006223 100644
(file)
--- a/
replace_object.c
+++ b/
replace_object.c
@@
-8,8
+8,8
@@
* sha1.
*/
static struct replace_object {
* 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;
} **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;
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)
}
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)
{
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)
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));
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 */
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))
/* Register new object */
if (register_replace_object(repl_obj, 1))
@@
-113,7
+113,7
@@
const unsigned char *do_lookup_replace_object(const unsigned char *sha1)
pos = replace_object_pos(cur);
if (0 <= pos)
pos = replace_object_pos(cur);
if (0 <= pos)
- cur = replace_object[pos]->replacement;
+ cur = replace_object[pos]->replacement
.hash
;
} while (0 <= pos);
return cur;
} while (0 <= pos);
return cur;