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

[PATCH] git-write-tree should not crash if prefix does not exist

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Jul 26, 2007, 03:14 UTC
Message-ID
<20070726031454.GA2026@localhost.hsd1.ma.comcast.net>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 Resend as it seems git-send-email and vger.kernel.org don't like me
 much
 builtin-write-tree.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/builtin-write-tree.c b/builtin-write-tree.c
index 391de53..88f34ba 100644
--- a/builtin-write-tree.c
+++ b/builtin-write-tree.c
@@ -52,6 +52,8 @@ int write_tree(unsigned char *sha1, int missing_ok, const char *prefix)
 	if (prefix) {
 		struct cache_tree *subtree =
 			cache_tree_find(active_cache_tree, prefix);
+		if (!subtree)
+			die("git-write-tree: prefix %s not found", prefix);
 		hashcpy(sha1, subtree->sha1);
 	}
 	else
-- 
1.5.2
Message 1 of 1 in “git-write-tree should not crash if prefix does not exist”
  1. git-write-tree should not crash if prefix does not existNguyễn Thái Ngọc Duy, Jul 26, 2007

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.