git-write-tree should not crash if prefix does not exist
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Thu, 26 Jul 2007 03:14:54 +0000 (23:14 -0400)
committerJunio C Hamano <gitster@pobox.com>
Thu, 26 Jul 2007 04:35:17 +0000 (21:35 -0700)
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-write-tree.c

index 391de53972ebf77d2e08f1b405969e065bd8b371..88f34ba7d6e2426fae5169eb28b12e93e72082eb 100644 (file)
@@ -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