]> git.ipfire.org Git - thirdparty/git.git/blobdiff - fsck.c
Sync with 2.16.6
[thirdparty/git.git] / fsck.c
diff --git a/fsck.c b/fsck.c
index 9339f315131786c50c9fa10dd702fe20562e167e..2fc6bbca163194716a80b0ef6b5995b2cabb6fbd 100644 (file)
--- a/fsck.c
+++ b/fsck.c
@@ -64,6 +64,8 @@ static struct oidset gitmodules_done = OIDSET_INIT;
        FUNC(GITMODULES_PARSE, ERROR) \
        FUNC(GITMODULES_NAME, ERROR) \
        FUNC(GITMODULES_SYMLINK, ERROR) \
+       FUNC(GITMODULES_URL, ERROR) \
+       FUNC(GITMODULES_PATH, ERROR) \
        /* warnings */ \
        FUNC(BAD_FILEMODE, WARN) \
        FUNC(EMPTY_NAME, WARN) \
@@ -564,7 +566,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);
@@ -586,6 +588,22 @@ static int fsck_tree(struct tree *item, struct fsck_options *options)
                                                 ".gitmodules is a symbolic link");
                }
 
+               if ((backslash = strchr(name, '\\'))) {
+                       while (backslash) {
+                               backslash++;
+                               has_dotgit |= is_ntfs_dotgit(backslash);
+                               if (is_ntfs_dotgitmodules(backslash)) {
+                                       if (!S_ISLNK(mode))
+                                               oidset_insert(&gitmodules_found, oid);
+                                       else
+                                               retval += report(options, &item->object,
+                                                                FSCK_MSG_GITMODULES_SYMLINK,
+                                                                ".gitmodules is a symbolic link");
+                               }
+                               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;
@@ -945,6 +963,18 @@ static int fsck_gitmodules_fn(const char *var, const char *value, void *vdata)
                                    FSCK_MSG_GITMODULES_NAME,
                                    "disallowed submodule name: %s",
                                    name);
+       if (!strcmp(key, "url") && value &&
+           looks_like_command_line_option(value))
+               data->ret |= report(data->options, data->obj,
+                                   FSCK_MSG_GITMODULES_URL,
+                                   "disallowed submodule url: %s",
+                                   value);
+       if (!strcmp(key, "path") && value &&
+           looks_like_command_line_option(value))
+               data->ret |= report(data->options, data->obj,
+                                   FSCK_MSG_GITMODULES_PATH,
+                                   "disallowed submodule path: %s",
+                                   value);
        free(name);
 
        return 0;