summaryrefslogtreecommitdiff
path: root/fsck.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2018-05-04 20:03:35 -0400
committerJeff King <peff@peff.net>2018-05-21 23:55:12 -0400
commitb7b1fca175f1ed7933f361028c631b9ac86d868d (patch)
tree5785e7c711441487c0511db6d1aaacc624fb8ca4 /fsck.c
parent73c3f0f704a91b6792e0199a3f3ab6e3a1971675 (diff)
downloadgit-b7b1fca175f1ed7933f361028c631b9ac86d868d.tar.gz
fsck: complain when .gitmodules is a symlink
We've recently forbidden .gitmodules to be a symlink in verify_path(). And it's an easy way to circumvent our fsck checks for .gitmodules content. So let's complain when we see it. Signed-off-by: Jeff King <peff@peff.net>
Diffstat (limited to 'fsck.c')
-rw-r--r--fsck.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/fsck.c b/fsck.c
index 2eddfc3f74..9339f31513 100644
--- a/fsck.c
+++ b/fsck.c
@@ -63,6 +63,7 @@ static struct oidset gitmodules_done = OIDSET_INIT;
FUNC(GITMODULES_BLOB, ERROR) \
FUNC(GITMODULES_PARSE, ERROR) \
FUNC(GITMODULES_NAME, ERROR) \
+ FUNC(GITMODULES_SYMLINK, ERROR) \
/* warnings */ \
FUNC(BAD_FILEMODE, WARN) \
FUNC(EMPTY_NAME, WARN) \
@@ -576,8 +577,14 @@ static int fsck_tree(struct tree *item, struct fsck_options *options)
has_dotgit |= is_hfs_dotgit(name) || is_ntfs_dotgit(name);
has_zero_pad |= *(char *)desc.buffer == '0';
- if (is_hfs_dotgitmodules(name) || is_ntfs_dotgitmodules(name))
- oidset_insert(&gitmodules_found, oid);
+ if (is_hfs_dotgitmodules(name) || is_ntfs_dotgitmodules(name)) {
+ if (!S_ISLNK(mode))
+ oidset_insert(&gitmodules_found, oid);
+ else
+ retval += report(options, &item->object,
+ FSCK_MSG_GITMODULES_SYMLINK,
+ ".gitmodules is a symbolic link");
+ }
if (update_tree_entry_gently(&desc)) {
retval += report(options, &item->object, FSCK_MSG_BAD_TREE, "cannot be parsed as a tree");