diff options
author | Maxim Bublis <satori@yandex-team.ru> | 2014-08-29 15:53:37 +0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-08-29 10:31:14 -0700 |
commit | 2668d692eb1af63097628447f2e0c783b1a45e2e (patch) | |
tree | 941bfb5a89e5a0b21c797d560eb804272130434c /fast-import.c | |
parent | 8d30d8a89aa9bf8dfb477cb127af58448bbe9b96 (diff) | |
download | git-2668d692eb1af63097628447f2e0c783b1a45e2e.tar.gz |
fast-import: fix segfault in store_tree()mb/fast-import-delete-root
Branch tree is NULLified by filedelete command if we are trying
to delete root tree. Add sanity check and use load_tree() in that case.
Signed-off-by: Maxim Bublis <satori@yandex-team.ru>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'fast-import.c')
-rw-r--r-- | fast-import.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/fast-import.c b/fast-import.c index d73f58cbe3..e380804831 100644 --- a/fast-import.c +++ b/fast-import.c @@ -1419,7 +1419,7 @@ static void mktree(struct tree_content *t, int v, struct strbuf *b) static void store_tree(struct tree_entry *root) { - struct tree_content *t = root->tree; + struct tree_content *t; unsigned int i, j, del; struct last_object lo = { STRBUF_INIT, 0, 0, /* no_swap */ 1 }; struct object_entry *le = NULL; @@ -1427,6 +1427,10 @@ static void store_tree(struct tree_entry *root) if (!is_null_sha1(root->versions[1].sha1)) return; + if (!root->tree) + load_tree(root); + t = root->tree; + for (i = 0; i < t->entry_count; i++) { if (t->entries[i]->tree) store_tree(t->entries[i]); |