-#define USE_THE_REPOSITORY_VARIABLE
#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
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)
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);
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)
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);
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)
(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));
(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));
}
/* 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;
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,
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. */
if (type == -1)
return -1;
if (type != OBJ_BLOB) {
- ret = convert_object_file(&outbuf,
+ ret = convert_object_file(the_repository, &outbuf,
the_hash_algo, input_algo,
content, size, type, !do_die);
free(content);
hash_object_file(compat, buf, len, type, &compat_oid);
else {
struct strbuf converted = STRBUF_INIT;
- convert_object_file(&converted, algo, compat,
+ convert_object_file(the_repository, &converted, algo, compat,
buf, len, type, 0);
hash_object_file(compat, converted.buf, converted.len,
type, &compat_oid);
&compat_oid);
else if (compat_type != -1) {
struct strbuf converted = STRBUF_INIT;
- convert_object_file(&converted, algo, compat,
+ convert_object_file(the_repository,
+ &converted, algo, compat,
buf, len, compat_type, 0);
hash_object_file(compat, converted.buf, converted.len,
compat_type, &compat_oid);