Skip to content

Commit 031cee5

Browse files
bk2204gitster
authored andcommitted
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>
1 parent 8c88769 commit 031cee5

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

builtin/commit-tree.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
4040
{
4141
int i, got_tree = 0;
4242
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;
4545
struct strbuf buffer = STRBUF_INIT;
4646

4747
git_config(commit_tree_config, NULL);
@@ -52,13 +52,13 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
5252
for (i = 1; i < argc; i++) {
5353
const char *arg = argv[i];
5454
if (!strcmp(arg, "-p")) {
55-
unsigned char sha1[20];
55+
struct object_id oid;
5656
if (argc <= ++i)
5757
usage(commit_tree_usage);
58-
if (get_sha1_commit(argv[i], sha1))
58+
if (get_sha1_commit(argv[i], oid.hash))
5959
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);
6262
continue;
6363
}
6464

@@ -105,7 +105,7 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
105105
continue;
106106
}
107107

108-
if (get_sha1_tree(arg, tree_sha1))
108+
if (get_sha1_tree(arg, tree_oid.hash))
109109
die("Not a valid object name %s", arg);
110110
if (got_tree)
111111
die("Cannot give more than one trees");
@@ -117,13 +117,13 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
117117
die_errno("git commit-tree: failed to read");
118118
}
119119

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)) {
122122
strbuf_release(&buffer);
123123
return 1;
124124
}
125125

126-
printf("%s\n", sha1_to_hex(commit_sha1));
126+
printf("%s\n", oid_to_hex(&commit_oid));
127127
strbuf_release(&buffer);
128128
return 0;
129129
}

0 commit comments

Comments
 (0)