Convert both the argument and the return value to be pointers to struct
object_id. Update the callers and their internals to deal with the new
type. Remove several temporaries which are no longer needed.
Signed-off-by: brian m. carlson
---
builtin/mktag.c | 7 ++-
cache.h | 8
object.c | 14 --
replace_object.c | 14 +++---
sha1_file.c | 44
streaming.c | 16 +---
6 files changed, 42 insertions(+), 61 deletions(-)
diff --git a/builtin/mktag.c b/builtin/mktag.c
index cfb777b3c8..9f5a50a8fd 100644
--- a/builtin/mktag.c
+++ b/builtin/mktag.c
@@ -24,14 +24,11 @@ static int verify_object(const struct object_id *oid, const
char *expected_type)
enum object_type type;
unsigned long size;
void *buffer = read_object_file(oid, &type, &size);
- const unsigned char *repl = lookup_replace_object(oid->hash);
+ const struct object_id *repl = lookup_replace_object(oid);
if (buffer) {
- struct object_id reploid;
- hashcpy(reploid.hash, repl);
-
if (type == type_from_string(expected_type))
- ret = check_object_signature(&reploid, buffer, size,
expected_type);
+ ret = check_object_signature(repl, buffer, size,
expected_type);
free(buffer);
}
return ret;
diff --git a/cache.h b/cache.h
index 970d6edd04..a70c52b22f 100644
--- a/cache.h
+++ b/cache.h
@@ -1197,7 +1197,7 @@ static inline void *read_object_file(const struct
object_id *oid, enum object_ty
* This internal function is only declared here for the benefit of
* lookup_replace_object(). Please do not call it directly.
*/
-extern const unsigned char *do_lookup_replace_object(const unsigned char
*sha1);
+extern const struct object_id *do_lookup_replace_object(const struct object_id
*oid);
/*
* If object sha1 should be replaced, return the replacement object's
@@ -1205,11 +1205,11 @@ extern const unsigned char
*do_lookup_replace_object(const unsigned char *sha1);
* either sha1 or a pointer to a permanently-allocated value. When
* object replacement is suppressed, always return sha1.
*/
-static inline const unsigned char *lookup_replace_object(const unsigned char
*sha1)
+static inline const struct object_id *lookup_replace_object(const struct
object_id *oid)
{
if (!check_replace_refs)
- return sha1;
- return do_lookup_replace_object(sha1);
+ return oid;
+ return do_lookup_replace_object(oid);
}
/* Read and unpack an object file into memory, write memory to an object file
*/
diff --git a/object.c b/object.c
index ea1a6f18e8..4e1c065d55 100644
--- a/object.c
+++ b/object.c
@@ -244,7 +244,7 @@ struct object *parse_object(const struct object_id *oid)
unsigned long size;
enum object_type type;
int eaten;
- const unsigned char *repl = lookup_replace_object(oid->hash);
+ const struct object_id *repl = lookup_replace_object(oid);
void *buffer;
struct object *obj;
@@ -255,10 +255,7 @@ struct object *parse_object(const struct object_id *oid)
if ((obj && obj->type == OBJ_BLOB && has_object_file(oid)) ||
(!obj && has_object_file(oid) &&
oid_object_info(oid, NULL) == OBJ_BLOB)) {
- struct object_id reploid;
- hashcpy(reploid.hash, repl);
-
- if (check_object_signature(&reploid, NULL, 0, NULL) < 0) {
+ if (check_object_signature(repl, NULL, 0, NULL) < 0) {
error("sha1 mismatch %s", oid_to_hex(oid));
return NULL;
}
@@ -268,12 +265,9 @@ struct object *parse_object(const struct object_id *oid)
buffer = read_object_file(oid, &type, &size);
if (buffer) {
- struct object_id reploid;
- hashcpy(reploid.hash, repl);
-
- if (check_object_signature(&reploid, buffer, size,
typename(type)) < 0) {
+ if (check_object_signature(repl, buffer, size, typename(type))
< 0) {
free(buffer);
- error("sha1 mismatch %s", sha1_to_hex(repl));
+ error("sha1 mismatch %s", oid_to_hex(repl));
return NULL;
}
diff --git a/replace_object.c b/replace_object.c
index 232e8b8550..336357394d 100644
--- a/replace_object.c
+++ b/replace_object.c
@@ -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 functi