Skip to content

Commit 2baa638

Browse files
committed
fsck: complain when .gitignore and .gitattributes are symlinks
This case is already forbidden by verify_path(), so let's check it in fsck. It's easier to handle than .gitmodules, because we don't care about checking the blob content. This is really just about whether the name and mode for the tree entry are valid. Signed-off-by: Jeff King <[email protected]>
1 parent 425db06 commit 2baa638

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

fsck.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ static struct oidset gitmodules_done = OIDSET_INIT;
6464
FUNC(GITMODULES_PARSE, ERROR) \
6565
FUNC(GITMODULES_NAME, ERROR) \
6666
FUNC(GITMODULES_SYMLINK, ERROR) \
67+
FUNC(GITIGNORE_SYMLINK, ERROR) \
68+
FUNC(GITATTRIBUTES_SYMLINK, ERROR) \
6769
/* warnings */ \
6870
FUNC(BAD_FILEMODE, WARN) \
6971
FUNC(EMPTY_NAME, WARN) \
@@ -586,6 +588,19 @@ static int fsck_tree(struct tree *item, struct fsck_options *options)
586588
".gitmodules is a symbolic link");
587589
}
588590

591+
if (S_ISLNK(mode)) {
592+
if (is_hfs_dotgitignore(name) ||
593+
is_ntfs_dotgitignore(name))
594+
retval += report(options, &item->object,
595+
FSCK_MSG_GITIGNORE_SYMLINK,
596+
".gitignore is a symlink");
597+
if (is_hfs_dotgitattributes(name) ||
598+
is_ntfs_dotgitattributes(name))
599+
retval += report(options, &item->object,
600+
FSCK_MSG_GITATTRIBUTES_SYMLINK,
601+
".gitattributes is a symlink");
602+
}
603+
589604
if (update_tree_entry_gently(&desc)) {
590605
retval += report(options, &item->object, FSCK_MSG_BAD_TREE, "cannot be parsed as a tree");
591606
break;

0 commit comments

Comments
 (0)