summaryrefslogtreecommitdiff
path: root/builtin-commit-tree.c
diff options
context:
space:
mode:
authorLibravatar Miklos Vajna <vmiklos@frugalware.org>2008-09-10 22:10:31 +0200
committerLibravatar Junio C Hamano <gitster@pobox.com>2008-09-10 15:25:46 -0700
commitee20a129de6f332da092e93feb2dd5f8330f9bc0 (patch)
tree471d0e4460a41eadf03eac6cb81cda6b8c6848dc /builtin-commit-tree.c
parentt9101: use "git hash-object" without dash (diff)
downloadtgif-ee20a129de6f332da092e93feb2dd5f8330f9bc0.tar.xz
commit_tree(): add a new author parameter
In case it's NULL, it is still determined automatically, but now you have the ability to specify one yourself. Signed-off-by: Miklos Vajna <vmiklos@frugalware.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-commit-tree.c')
-rw-r--r--builtin-commit-tree.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/builtin-commit-tree.c b/builtin-commit-tree.c
index f2684bb75e..0453425c47 100644
--- a/builtin-commit-tree.c
+++ b/builtin-commit-tree.c
@@ -46,7 +46,8 @@ 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;
@@ -74,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);
@@ -123,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;
}