1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-06-02 14:06:12 +02:00

builtin/commit-tree: convert to struct object_id

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
brian m. carlson 2016-09-05 20:08:10 +00:00 committed by Junio C Hamano
parent 8c88769ba4
commit 031cee5b73

View File

@ -40,8 +40,8 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
{
int i, got_tree = 0;
struct commit_list *parents = NULL;
unsigned char tree_sha1[20];
unsigned char commit_sha1[20];
struct object_id tree_oid;
struct object_id commit_oid;
struct strbuf buffer = STRBUF_INIT;
git_config(commit_tree_config, NULL);
@ -52,13 +52,13 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
for (i = 1; i < argc; i++) {
const char *arg = argv[i];
if (!strcmp(arg, "-p")) {
unsigned char sha1[20];
struct object_id oid;
if (argc <= ++i)
usage(commit_tree_usage);
if (get_sha1_commit(argv[i], sha1))
if (get_sha1_commit(argv[i], oid.hash))
die("Not a valid object name %s", argv[i]);
assert_sha1_type(sha1, OBJ_COMMIT);
new_parent(lookup_commit(sha1), &parents);
assert_sha1_type(oid.hash, OBJ_COMMIT);
new_parent(lookup_commit(oid.hash), &parents);
continue;
}
@ -105,7 +105,7 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
continue;
}
if (get_sha1_tree(arg, tree_sha1))
if (get_sha1_tree(arg, tree_oid.hash))
die("Not a valid object name %s", arg);
if (got_tree)
die("Cannot give more than one trees");
@ -117,13 +117,13 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
die_errno("git commit-tree: failed to read");
}
if (commit_tree(buffer.buf, buffer.len, tree_sha1, parents,
commit_sha1, NULL, sign_commit)) {
if (commit_tree(buffer.buf, buffer.len, tree_oid.hash, parents,
commit_oid.hash, NULL, sign_commit)) {
strbuf_release(&buffer);
return 1;
}
printf("%s\n", sha1_to_hex(commit_sha1));
printf("%s\n", oid_to_hex(&commit_oid));
strbuf_release(&buffer);
return 0;
}