diff options
author | Junio C Hamano <gitster@pobox.com> | 2014-07-16 11:33:09 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-07-16 11:33:09 -0700 |
commit | 1fc83452c76e65385b3da69ea94eb957e36e6c78 (patch) | |
tree | 6d6105b9a9fed643036df3d0fceabde1ab1479c7 /builtin | |
parent | Merge branch 'jk/skip-prefix' (diff) | |
parent | fsck: simplify fsck_commit_buffer() by using commit_list_count() (diff) | |
download | tgif-1fc83452c76e65385b3da69ea94eb957e36e6c78.tar.xz |
Merge branch 'rs/code-cleaning'
* rs/code-cleaning:
fsck: simplify fsck_commit_buffer() by using commit_list_count()
commit: use commit_list_append() instead of duplicating its code
merge: simplify merge_trivial() by using commit_list_append()
use strbuf_addch for adding single characters
use strbuf_addbuf for adding strbufs
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/log.c | 2 | ||||
-rw-r--r-- | builtin/merge.c | 10 |
2 files changed, 5 insertions, 7 deletions
diff --git a/builtin/log.c b/builtin/log.c index 27c1b65db4..4389722b4b 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -861,7 +861,7 @@ static void add_branch_description(struct strbuf *buf, const char *branch_name) read_branch_desc(&desc, branch_name); if (desc.len) { strbuf_addch(buf, '\n'); - strbuf_add(buf, desc.buf, desc.len); + strbuf_addbuf(buf, &desc); strbuf_addch(buf, '\n'); } } diff --git a/builtin/merge.c b/builtin/merge.c index 22491a1c2b..ce82eb297d 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -839,16 +839,14 @@ static void prepare_to_commit(struct commit_list *remoteheads) static int merge_trivial(struct commit *head, struct commit_list *remoteheads) { unsigned char result_tree[20], result_commit[20]; - struct commit_list *parent = xmalloc(sizeof(*parent)); + struct commit_list *parents, **pptr = &parents; write_tree_trivial(result_tree); printf(_("Wonderful.\n")); - parent->item = head; - parent->next = xmalloc(sizeof(*parent->next)); - parent->next->item = remoteheads->item; - parent->next->next = NULL; + pptr = commit_list_append(head, pptr); + pptr = commit_list_append(remoteheads->item, pptr); prepare_to_commit(remoteheads); - if (commit_tree(merge_msg.buf, merge_msg.len, result_tree, parent, + if (commit_tree(merge_msg.buf, merge_msg.len, result_tree, parents, result_commit, NULL, sign_commit)) die(_("failed to write commit object")); finish(head, remoteheads, result_commit, "In-index merge"); |