Skip to content

Commit

Permalink
commit_tree(): add a new author parameter
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
Miklos Vajna authored and gitster committed Sep 10, 2008
1 parent da06a80 commit ee20a12
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
9 changes: 6 additions & 3 deletions builtin-commit-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions builtin-merge.c
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ static int merge_trivial(void)
parent->next = xmalloc(sizeof(struct commit_list *));
parent->next->item = remoteheads->item;
parent->next->next = NULL;
commit_tree(merge_msg.buf, result_tree, parent, result_commit);
commit_tree(merge_msg.buf, result_tree, parent, result_commit, NULL);
finish(result_commit, "In-index merge");
drop_save();
return 0;
Expand Down Expand Up @@ -720,7 +720,7 @@ static int finish_automerge(struct commit_list *common,
}
free_commit_list(remoteheads);
strbuf_addch(&merge_msg, '\n');
commit_tree(merge_msg.buf, result_tree, parents, result_commit);
commit_tree(merge_msg.buf, result_tree, parents, result_commit, NULL);
strbuf_addf(&buf, "Merge made by %s.", wt_strategy);
finish(result_commit, buf.buf);
strbuf_release(&buf);
Expand Down
3 changes: 2 additions & 1 deletion builtin.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ extern int read_line_with_nul(char *buf, int size, FILE *file);
extern int fmt_merge_msg(int merge_summary, struct strbuf *in,
struct strbuf *out);
extern 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);
extern int check_pager_config(const char *cmd);

extern int cmd_add(int argc, const char **argv, const char *prefix);
Expand Down

0 comments on commit ee20a12

Please sign in to comment.