Code

Fix multi-glob assertion in git-svn
[git.git] / cache-tree.c
index 4e1e7b25cf3e5cdbff99524f197c8341d26ac10a..5f8ee87bb1c446341b640c2f978a658d6bfcfcd0 100644 (file)
@@ -320,13 +320,13 @@ static int update_one(struct cache_tree *it,
                }
                else {
                        sha1 = ce->sha1;
-                       mode = ntohl(ce->ce_mode);
+                       mode = ce->ce_mode;
                        entlen = pathlen - baselen;
                }
                if (mode != S_IFGITLINK && !missing_ok && !has_sha1_file(sha1))
                        return error("invalid object %s", sha1_to_hex(sha1));
 
-               if (!ce->ce_mode)
+               if (ce->ce_flags & CE_REMOVE)
                        continue; /* entry being removed */
 
                strbuf_grow(&buffer, entlen + 100);
@@ -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
@@ -504,7 +507,7 @@ struct cache_tree *cache_tree_read(const char *buffer, unsigned long size)
        return read_one(&buffer, &size);
 }
 
-struct cache_tree *cache_tree_find(struct cache_tree *it, const char *path)
+static struct cache_tree *cache_tree_find(struct cache_tree *it, const char *path)
 {
        while (*path) {
                const char *slash;