summaryrefslogtreecommitdiff
path: root/object-file-convert.c
diff options
context:
space:
mode:
Diffstat (limited to 'object-file-convert.c')
-rw-r--r--object-file-convert.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/object-file-convert.c b/object-file-convert.c
index eba71955cf..7ab875afe6 100644
--- a/object-file-convert.c
+++ b/object-file-convert.c
@@ -1,4 +1,3 @@
-#define USE_THE_REPOSITORY_VARIABLE
#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
@@ -63,7 +62,8 @@ static int decode_tree_entry_raw(struct object_id *oid, const char **path,
return 0;
}
-static int convert_tree_object(struct strbuf *out,
+static int convert_tree_object(struct repository *repo,
+ struct strbuf *out,
const struct git_hash_algo *from,
const struct git_hash_algo *to,
const char *buffer, size_t size)
@@ -78,7 +78,7 @@ static int convert_tree_object(struct strbuf *out,
if (decode_tree_entry_raw(&entry_oid, &path, &pathlen, from, p,
end - p))
return error(_("failed to decode tree entry"));
- if (repo_oid_to_algop(the_repository, &entry_oid, to, &mapped_oid))
+ if (repo_oid_to_algop(repo, &entry_oid, to, &mapped_oid))
return error(_("failed to map tree entry for %s"), oid_to_hex(&entry_oid));
strbuf_add(out, p, path - p);
strbuf_add(out, path, pathlen);
@@ -88,7 +88,8 @@ static int convert_tree_object(struct strbuf *out,
return 0;
}
-static int convert_tag_object(struct strbuf *out,
+static int convert_tag_object(struct repository *repo,
+ struct strbuf *out,
const struct git_hash_algo *from,
const struct git_hash_algo *to,
const char *buffer, size_t size)
@@ -105,7 +106,7 @@ static int convert_tag_object(struct strbuf *out,
return error("bogus tag object");
if (parse_oid_hex_algop(buffer + 7, &oid, &p, from) < 0)
return error("bad tag object ID");
- if (repo_oid_to_algop(the_repository, &oid, to, &mapped_oid))
+ if (repo_oid_to_algop(repo, &oid, to, &mapped_oid))
return error("unable to map tree %s in tag object",
oid_to_hex(&oid));
size -= ((p + 1) - buffer);
@@ -139,7 +140,8 @@ static int convert_tag_object(struct strbuf *out,
return 0;
}
-static int convert_commit_object(struct strbuf *out,
+static int convert_commit_object(struct repository *repo,
+ struct strbuf *out,
const struct git_hash_algo *from,
const struct git_hash_algo *to,
const char *buffer, size_t size)
@@ -165,7 +167,7 @@ static int convert_commit_object(struct strbuf *out,
(p != eol))
return error(_("bad %s in commit"), "tree");
- if (repo_oid_to_algop(the_repository, &oid, to, &mapped_oid))
+ if (repo_oid_to_algop(repo, &oid, to, &mapped_oid))
return error(_("unable to map %s %s in commit object"),
"tree", oid_to_hex(&oid));
strbuf_addf(out, "tree %s\n", oid_to_hex(&mapped_oid));
@@ -177,7 +179,7 @@ static int convert_commit_object(struct strbuf *out,
(p != eol))
return error(_("bad %s in commit"), "parent");
- if (repo_oid_to_algop(the_repository, &oid, to, &mapped_oid))
+ if (repo_oid_to_algop(repo, &oid, to, &mapped_oid))
return error(_("unable to map %s %s in commit object"),
"parent", oid_to_hex(&oid));
@@ -202,7 +204,7 @@ static int convert_commit_object(struct strbuf *out,
}
/* Compute the new tag object */
- if (convert_tag_object(&new_tag, from, to, tag.buf, tag.len)) {
+ if (convert_tag_object(repo, &new_tag, from, to, tag.buf, tag.len)) {
strbuf_release(&tag);
strbuf_release(&new_tag);
return -1;
@@ -241,7 +243,8 @@ static int convert_commit_object(struct strbuf *out,
return 0;
}
-int convert_object_file(struct strbuf *outbuf,
+int convert_object_file(struct repository *repo,
+ struct strbuf *outbuf,
const struct git_hash_algo *from,
const struct git_hash_algo *to,
const void *buf, size_t len,
@@ -256,13 +259,13 @@ int convert_object_file(struct strbuf *outbuf,
switch (type) {
case OBJ_COMMIT:
- ret = convert_commit_object(outbuf, from, to, buf, len);
+ ret = convert_commit_object(repo, outbuf, from, to, buf, len);
break;
case OBJ_TREE:
- ret = convert_tree_object(outbuf, from, to, buf, len);
+ ret = convert_tree_object(repo, outbuf, from, to, buf, len);
break;
case OBJ_TAG:
- ret = convert_tag_object(outbuf, from, to, buf, len);
+ ret = convert_tag_object(repo, outbuf, from, to, buf, len);
break;
default:
/* Not implemented yet, so fail. */