Fix "git add -u" data corruption.
[gitweb.git] / fetch.c
diff --git a/fetch.c b/fetch.c
index f69be82f10d287d71f6184c4b9203bdab3ce81fc..6f1f420be26ac6dafec366b3dc0671fb7f4940dc 100644 (file)
--- a/fetch.c
+++ b/fetch.c
@@ -42,11 +42,13 @@ static int process_tree(struct tree *tree)
        if (parse_tree(tree))
                return -1;
 
-       desc.buf = tree->buffer;
-       desc.size = tree->size;
+       init_tree_desc(&desc, tree->buffer, tree->size);
        while (tree_entry(&desc, &entry)) {
                struct object *obj = NULL;
 
+               /* submodule commits are not stored in the superproject */
+               if (S_ISDIRLNK(entry.mode))
+                       continue;
                if (S_ISDIR(entry.mode)) {
                        struct tree *tree = lookup_tree(entry.sha1);
                        if (tree)