git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 1/3] merge: abort if fails to commit

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Dec 15, 2011, 13:47 UTC
Message-ID
<1323956843-5326-1-git-send-email-pclouds@gmail.com>
In-Reply-To
<1323871699-8839-2-git-send-email-pclouds@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 2011/12/15 Junio C Hamano <gitster@pobox.com>:
 >> -     commit_tree(merge_msg.buf, merge_msg.len, result_tree, parent, result_commit, NULL);
 >> +     if (commit_tree(merge_msg.buf, merge_msg.len,
 >> +                     result_tree, parent, result_commit, NULL))
 >> +             die(_("failed to write commit object"));
 >>       finish(head, result_commit, "In-index merge");
 >>       drop_save();
 >>       return 0;
 >
 > Should we die immediately, or should we do some clean-ups after ourselves
 > before doing so?
 I'm not sure. I had a quick look over the command and it seems we do
 not need to do any clean-ups. But I'm not familiar with the command
 anyway..
 > In any case, this is a good change that shouldn't be taken hostage to the
 > unrelated change in patch [1/3].
 Moved it up so it you can cherry-pick it independently.
 builtin/merge.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/builtin/merge.c b/builtin/merge.c
index 2870a6a..27576c0 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -913,7 +913,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.buf, result_tree, parent, result_commit, NULL))
+		die(_("failed to write commit object"));
 	finish(head, result_commit, "In-index merge");
 	drop_save();
 	return 0;
@@ -944,7 +945,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.buf, 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);
-- 
1.7.8.36.g69ee2
Previous: Junio C HamanoNext: Nguyễn Thái Ngọc Duy
Message 10 of 23 in “Do not create commits whose message contains NUL”
  1. Do not create commits whose message contains NULNguyễn Thái Ngọc Duy, Dec 13, 2011
  2. Jeff KingDec 13, 2011
  3. Miles BaderDec 14, 2011
  4. Jeff KingDec 14, 2011
  5. Drew NorthupJan 1, 2012
  6. Jeff KingJan 3, 2012
  7. 0/3 git-commit rejects messages with NULsNguyễn Thái Ngọc Duy, Dec 14, 2011
  8. 1/3 Make commit_tree() take message length in addition to the commit messageNguyễn Thái Ngọc Duy, Dec 14, 2011
  9. Junio C HamanoDec 14, 2011
  10. 1/3 merge: abort if fails to commitNguyễn Thái Ngọc Duy, Dec 15, 2011
  11. 2/3 Convert commit_tree() to take strbuf as messageNguyễn Thái Ngọc Duy, Dec 15, 2011
  12. 3/3 commit: refuse commit messages that contain NULsNguyễn Thái Ngọc Duy, Dec 15, 2011
  13. Junio C HamanoDec 15, 2011
  14. 2/3 merge: abort if fails to commitNguyễn Thái Ngọc Duy, Dec 14, 2011
  15. Junio C HamanoDec 14, 2011
  16. 3/3 Do not create commits whose message contains NULNguyễn Thái Ngọc Duy, Dec 14, 2011
  17. Junio C HamanoDec 14, 2011
  18. Jeff KingDec 14, 2011
  19. Junio C HamanoDec 15, 2011
  20. Junio C HamanoDec 15, 2011
  21. Miles BaderDec 15, 2011
  22. Jeff KingDec 15, 2011
  23. Junio C HamanoDec 15, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.