X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=builtin-commit-tree.c;h=0453425c471f1d6793bc7f5f59d17e9d285ddfc6;hb=bfd59c493d2be76adbc281df15a20aae766128fc;hp=291c43cf70d7906b770911a7bcb2cdff9c6182e7;hpb=7e44c93558e7c0b12624d76cf07753d0480ed96a;p=git.git diff --git a/builtin-commit-tree.c b/builtin-commit-tree.c index 291c43cf7..0453425c4 100644 --- a/builtin-commit-tree.c +++ b/builtin-commit-tree.c @@ -24,7 +24,7 @@ static void check_valid(unsigned char *sha1, enum object_type expect) typename(expect)); } -static const char commit_tree_usage[] = "git-commit-tree [-p ]* < changelog"; +static const char commit_tree_usage[] = "git commit-tree [-p ]* < changelog"; static void new_parent(struct commit *parent, struct commit_list **parents_p) { @@ -46,8 +46,10 @@ static const char commit_utf8_warn[] = "variable i18n.commitencoding to the encoding your project uses.\n"; int commit_tree(const char *msg, unsigned char *tree, - struct commit_list *parents, unsigned char *ret) + struct commit_list *parents, unsigned char *ret, + const char *author) { + int result; int encoding_is_utf8; struct strbuf buffer; @@ -73,7 +75,9 @@ int commit_tree(const char *msg, unsigned char *tree, } /* Person/date information */ - strbuf_addf(&buffer, "author %s\n", git_author_info(IDENT_ERROR_ON_NO_NAME)); + if (!author) + author = git_author_info(IDENT_ERROR_ON_NO_NAME); + strbuf_addf(&buffer, "author %s\n", author); strbuf_addf(&buffer, "committer %s\n", git_committer_info(IDENT_ERROR_ON_NO_NAME)); if (!encoding_is_utf8) strbuf_addf(&buffer, "encoding %s\n", git_commit_encoding); @@ -86,7 +90,9 @@ int commit_tree(const char *msg, unsigned char *tree, if (encoding_is_utf8 && !is_utf8(buffer.buf)) fprintf(stderr, commit_utf8_warn); - return write_sha1_file(buffer.buf, buffer.len, commit_type, ret); + result = write_sha1_file(buffer.buf, buffer.len, commit_type, ret); + strbuf_release(&buffer); + return result; } int cmd_commit_tree(int argc, const char **argv, const char *prefix) @@ -120,7 +126,7 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix) if (strbuf_read(&buffer, 0, 0) < 0) die("git commit-tree: read returned %s", strerror(errno)); - if (!commit_tree(buffer.buf, tree_sha1, parents, commit_sha1)) { + if (!commit_tree(buffer.buf, tree_sha1, parents, commit_sha1, NULL)) { printf("%s\n", sha1_to_hex(commit_sha1)); return 0; }