diff options
| author | Carlos Martín Nieto <carlosmn@github.com> | 2016-05-24 16:15:57 +0200 |
|---|---|---|
| committer | Carlos Martín Nieto <carlosmn@github.com> | 2016-05-24 16:15:57 +0200 |
| commit | c756448cefdf7369f30c45e9427ad5ba67e33483 (patch) | |
| tree | 35413be2e32565798a07568f1bdcc60e12b35560 /src/tree.c | |
| parent | c91a1dc1d975aa32c58cfafbf1625dcbb0be7c3c (diff) | |
| parent | a2cb47130ec7662811fe3447f69bae3f176e0362 (diff) | |
| download | libgit2-c756448cefdf7369f30c45e9427ad5ba67e33483.tar.gz | |
Merge pull request #3797 from libgit2/cmn/remove-single-entry
tree: handle removal of all entries in the updater
Diffstat (limited to 'src/tree.c')
| -rw-r--r-- | src/tree.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/tree.c b/src/tree.c index 4a9051cf8..43eefa50e 100644 --- a/src/tree.c +++ b/src/tree.c @@ -1093,6 +1093,15 @@ static int create_popped_tree(tree_stack_entry *current, tree_stack_entry *poppe git_oid new_tree; git_tree_free(popped->tree); + + /* If the tree would be empty, remove it from the one higher up */ + if (git_treebuilder_entrycount(popped->bld) == 0) { + git_treebuilder_free(popped->bld); + error = git_treebuilder_remove(current->bld, popped->name); + git__free(popped->name); + return error; + } + error = git_treebuilder_write(&new_tree, popped->bld); git_treebuilder_free(popped->bld); |
