merge-recursive: allow write_tree_from_memory() to error out
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Tue, 26 Jul 2016 16:06:17 +0000 (18:06 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 26 Jul 2016 18:13:44 +0000 (11:13 -0700)
It is possible that a tree cannot be written (think: disk full). We
will want to give the caller a chance to clean up instead of letting
the program die() in such a case.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
merge-recursive.c
index 2be1e17e080d8b789c1a634f5581dc85570f4697..1f86338ad3f16c233e9fe589a8c3210e0464c8b0 100644 (file)
@@ -1888,8 +1888,8 @@ int merge_trees(struct merge_options *o,
        else
                clean = 1;
 
-       if (o->call_depth)
-               *result = write_tree_from_memory(o);
+       if (o->call_depth && !(*result = write_tree_from_memory(o)))
+               return -1;
 
        return clean;
 }