]> git.ipfire.org Git - thirdparty/git.git/blobdiff - fsck.c
is_ntfs_dotgit(): only verify the leading segment
[thirdparty/git.git] / fsck.c
diff --git a/fsck.c b/fsck.c
index b4204d772b39335c5feb5c85a11c517bcedcd562..d80a96f4bef050e37c0f224aa9bbf783012e6523 100644 (file)
--- a/fsck.c
+++ b/fsck.c
@@ -358,15 +358,15 @@ static int fsck_walk_tree(struct tree *tree, void *data, struct fsck_options *op
                        continue;
 
                if (S_ISDIR(entry.mode)) {
-                       obj = &lookup_tree(entry.oid)->object;
-                       if (name)
+                       obj = (struct object *)lookup_tree(entry.oid);
+                       if (name && obj)
                                put_object_name(options, obj, "%s%s/", name,
                                        entry.path);
                        result = options->walk(obj, OBJ_TREE, data, options);
                }
                else if (S_ISREG(entry.mode) || S_ISLNK(entry.mode)) {
-                       obj = &lookup_blob(entry.oid)->object;
-                       if (name)
+                       obj = (struct object *)lookup_blob(entry.oid);
+                       if (name && obj)
                                put_object_name(options, obj, "%s%s", name,
                                        entry.path);
                        result = options->walk(obj, OBJ_BLOB, data, options);
@@ -551,7 +551,7 @@ static int fsck_tree(struct tree *item, struct fsck_options *options)
 
        while (desc.size) {
                unsigned mode;
-               const char *name;
+               const char *name, *backslash;
                const struct object_id *oid;
 
                oid = tree_entry_extract(&desc, &name, &mode);
@@ -565,6 +565,15 @@ static int fsck_tree(struct tree *item, struct fsck_options *options)
                               is_hfs_dotgit(name) ||
                               is_ntfs_dotgit(name));
                has_zero_pad |= *(char *)desc.buffer == '0';
+
+               if ((backslash = strchr(name, '\\'))) {
+                       while (backslash) {
+                               backslash++;
+                               has_dotgit |= is_ntfs_dotgit(backslash);
+                               backslash = strchr(backslash, '\\');
+                       }
+               }
+
                if (update_tree_entry_gently(&desc)) {
                        retval += report(options, &item->object, FSCK_MSG_BAD_TREE, "cannot be parsed as a tree");
                        break;