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>
brian m. carlson committed
Sep 5, 2016 at 20:08 UTC
031cee5b73caa25c1e2e75ead641230927bb272d
1 file changed
+10
-10
builtin/commit-tree.c
+10
-10
@@ -40,8 +40,8 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
40
{
41
int i, got_tree = 0;
42
struct commit_list *parents = NULL;
43
- unsigned char tree_sha1[20];
44
- unsigned char commit_sha1[20];
43
+ struct object_id tree_oid;
44
+ struct object_id commit_oid;
45
struct strbuf buffer = STRBUF_INIT;
46
47
git_config(commit_tree_config, NULL);
@@ -52,13 +52,13 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
52
for (i = 1; i < argc; i++) {
53
const char *arg = argv[i];
54
if (!strcmp(arg, "-p")) {
55
- unsigned char sha1[20];
55
+ struct object_id oid;
56
if (argc <= ++i)
57
usage(commit_tree_usage);
58
- if (get_sha1_commit(argv[i], sha1))
58
+ if (get_sha1_commit(argv[i], oid.hash))
59
die("Not a valid object name %s", argv[i]);
60
- assert_sha1_type(sha1, OBJ_COMMIT);
61
- new_parent(lookup_commit(sha1), &parents);
60
+ assert_sha1_type(oid.hash, OBJ_COMMIT);
61
+ new_parent(lookup_commit(oid.hash), &parents);
62
continue;
63
}
64
@@ -105,7 +105,7 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
105
continue;
106
}
107
108
- if (get_sha1_tree(arg, tree_sha1))
108
+ if (get_sha1_tree(arg, tree_oid.hash))
109
die("Not a valid object name %s", arg);
110
if (got_tree)
111
die("Cannot give more than one trees");
@@ -117,13 +117,13 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
117
die_errno("git commit-tree: failed to read");
118
}
119
120
- if (commit_tree(buffer.buf, buffer.len, tree_sha1, parents,
121
- commit_sha1, NULL, sign_commit)) {
120
+ if (commit_tree(buffer.buf, buffer.len, tree_oid.hash, parents,
121
+ commit_oid.hash, NULL, sign_commit)) {
122
strbuf_release(&buffer);
123
return 1;
124
}
125
126
- printf("%s\n", sha1_to_hex(commit_sha1));
126
+ printf("%s\n", oid_to_hex(&commit_oid));
127
strbuf_release(&buffer);
128
return 0;
129
}