diff options
author | Junio C Hamano <gitster@pobox.com> | 2011-12-22 11:27:26 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-12-22 11:27:26 -0800 |
commit | f35ccd9be2db9a55afd09ed1a9338c758fa63d82 (patch) | |
tree | c94f3c518cdadb2c478e066547f152d3c753fb36 /builtin | |
parent | Merge branch 'jk/maint-do-not-feed-stdin-to-tests' (diff) | |
parent | commit_tree(): refuse commit messages that contain NULs (diff) | |
download | tgif-f35ccd9be2db9a55afd09ed1a9338c758fa63d82.tar.xz |
Merge branch 'nd/war-on-nul-in-commit'
* nd/war-on-nul-in-commit:
commit_tree(): refuse commit messages that contain NULs
Convert commit_tree() to take strbuf as message
merge: abort if fails to commit
Conflicts:
builtin/commit.c
commit.c
commit.h
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/commit-tree.c | 2 | ||||
-rw-r--r-- | builtin/commit.c | 2 | ||||
-rw-r--r-- | builtin/merge.c | 6 | ||||
-rw-r--r-- | builtin/notes.c | 4 |
4 files changed, 8 insertions, 6 deletions
diff --git a/builtin/commit-tree.c b/builtin/commit-tree.c index b9c331225f..05353c30f2 100644 --- a/builtin/commit-tree.c +++ b/builtin/commit-tree.c @@ -98,7 +98,7 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix) die_errno("git commit-tree: failed to read"); } - if (commit_tree(buffer.buf, tree_sha1, parents, commit_sha1, NULL)) { + if (commit_tree(&buffer, tree_sha1, parents, commit_sha1, NULL)) { strbuf_release(&buffer); return 1; } diff --git a/builtin/commit.c b/builtin/commit.c index be1ab2e257..3069041b80 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -1492,7 +1492,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix) append_merge_tag_headers(parents, &tail); } - if (commit_tree_extended(sb.buf, active_cache_tree->sha1, parents, sha1, + if (commit_tree_extended(&sb, active_cache_tree->sha1, parents, sha1, author_ident.buf, extra)) { rollback_index_files(); die(_("failed to write commit object")); diff --git a/builtin/merge.c b/builtin/merge.c index 24579409c0..a896165790 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -910,7 +910,8 @@ static int merge_trivial(struct commit *head) parent->next->item = remoteheads->item; parent->next->next = NULL; prepare_to_commit(); - commit_tree(merge_msg.buf, result_tree, parent, result_commit, NULL); + if (commit_tree(&merge_msg, result_tree, parent, result_commit, NULL)) + die(_("failed to write commit object")); finish(head, result_commit, "In-index merge"); drop_save(); return 0; @@ -941,7 +942,8 @@ static int finish_automerge(struct commit *head, strbuf_addch(&merge_msg, '\n'); prepare_to_commit(); free_commit_list(remoteheads); - commit_tree(merge_msg.buf, result_tree, parents, result_commit, NULL); + if (commit_tree(&merge_msg, result_tree, parents, result_commit, NULL)) + die(_("failed to write commit object")); strbuf_addf(&buf, "Merge made by the '%s' strategy.", wt_strategy); finish(head, result_commit, buf.buf); strbuf_release(&buf); diff --git a/builtin/notes.c b/builtin/notes.c index 667e20a1e1..3644d140ec 100644 --- a/builtin/notes.c +++ b/builtin/notes.c @@ -301,12 +301,12 @@ void commit_notes(struct notes_tree *t, const char *msg) return; /* don't have to commit an unchanged tree */ /* Prepare commit message and reflog message */ - strbuf_addstr(&buf, "notes: "); /* commit message starts at index 7 */ strbuf_addstr(&buf, msg); if (buf.buf[buf.len - 1] != '\n') strbuf_addch(&buf, '\n'); /* Make sure msg ends with newline */ - create_notes_commit(t, NULL, buf.buf + 7, commit_sha1); + create_notes_commit(t, NULL, &buf, commit_sha1); + strbuf_insert(&buf, 0, "notes: ", 7); /* commit message starts at index 7 */ update_ref(buf.buf, t->ref, commit_sha1, NULL, 0, DIE_ON_ERR); strbuf_release(&buf); |