git-bisect.sh: don't accidentally override existing branch "bisect"
[gitweb.git] / cache-tree.c
index 39da54d1e56b5905655eafed1aff0f51c2540a8e..73cb3407077275f82677839d2c9e794c12833c95 100644 (file)
@@ -341,8 +341,11 @@ static int update_one(struct cache_tree *it,
 
        if (dryrun)
                hash_sha1_file(buffer.buf, buffer.len, tree_type, it->sha1);
-       else
-               write_sha1_file(buffer.buf, buffer.len, tree_type, it->sha1);
+       else if (write_sha1_file(buffer.buf, buffer.len, tree_type, it->sha1)) {
+               strbuf_release(&buffer);
+               return -1;
+       }
+
        strbuf_release(&buffer);
        it->entry_count = i;
 #if DEBUG