@@ -558,7 +558,7 @@ static int verify_ordered(unsigned mode1, const char *name1,
558558 return c1 < c2 ? 0 : TREE_UNORDERED ;
559559}
560560
561- static int fsck_tree (const struct object_id * oid ,
561+ static int fsck_tree (const struct object_id * tree_oid ,
562562 const char * buffer , unsigned long size ,
563563 struct fsck_options * options )
564564{
@@ -579,7 +579,9 @@ static int fsck_tree(const struct object_id *oid,
579579 struct name_stack df_dup_candidates = { NULL };
580580
581581 if (init_tree_desc_gently (& desc , buffer , size )) {
582- retval += report (options , oid , OBJ_TREE , FSCK_MSG_BAD_TREE , "cannot be parsed as a tree" );
582+ retval += report (options , tree_oid , OBJ_TREE ,
583+ FSCK_MSG_BAD_TREE ,
584+ "cannot be parsed as a tree" );
583585 return retval ;
584586 }
585587
@@ -589,11 +591,11 @@ static int fsck_tree(const struct object_id *oid,
589591 while (desc .size ) {
590592 unsigned short mode ;
591593 const char * name , * backslash ;
592- const struct object_id * oid ;
594+ const struct object_id * entry_oid ;
593595
594- oid = tree_entry_extract (& desc , & name , & mode );
596+ entry_oid = tree_entry_extract (& desc , & name , & mode );
595597
596- has_null_sha1 |= is_null_oid (oid );
598+ has_null_sha1 |= is_null_oid (entry_oid );
597599 has_full_path |= !!strchr (name , '/' );
598600 has_empty_name |= !* name ;
599601 has_dot |= !strcmp (name , "." );
@@ -603,23 +605,43 @@ static int fsck_tree(const struct object_id *oid,
603605
604606 if (is_hfs_dotgitmodules (name ) || is_ntfs_dotgitmodules (name )) {
605607 if (!S_ISLNK (mode ))
606- oidset_insert (& options -> gitmodules_found , oid );
608+ oidset_insert (& options -> gitmodules_found ,
609+ entry_oid );
607610 else
608611 retval += report (options ,
609- oid , OBJ_TREE ,
612+ tree_oid , OBJ_TREE ,
610613 FSCK_MSG_GITMODULES_SYMLINK ,
611614 ".gitmodules is a symbolic link" );
612615 }
613616
617+ if (S_ISLNK (mode )) {
618+ if (is_hfs_dotgitignore (name ) ||
619+ is_ntfs_dotgitignore (name ))
620+ retval += report (options , tree_oid , OBJ_TREE ,
621+ FSCK_MSG_GITIGNORE_SYMLINK ,
622+ ".gitignore is a symlink" );
623+ if (is_hfs_dotgitattributes (name ) ||
624+ is_ntfs_dotgitattributes (name ))
625+ retval += report (options , tree_oid , OBJ_TREE ,
626+ FSCK_MSG_GITATTRIBUTES_SYMLINK ,
627+ ".gitattributes is a symlink" );
628+ if (is_hfs_dotmailmap (name ) ||
629+ is_ntfs_dotmailmap (name ))
630+ retval += report (options , tree_oid , OBJ_TREE ,
631+ FSCK_MSG_MAILMAP_SYMLINK ,
632+ ".mailmap is a symlink" );
633+ }
634+
614635 if ((backslash = strchr (name , '\\' ))) {
615636 while (backslash ) {
616637 backslash ++ ;
617638 has_dotgit |= is_ntfs_dotgit (backslash );
618639 if (is_ntfs_dotgitmodules (backslash )) {
619640 if (!S_ISLNK (mode ))
620- oidset_insert (& options -> gitmodules_found , oid );
641+ oidset_insert (& options -> gitmodules_found ,
642+ entry_oid );
621643 else
622- retval += report (options , oid , OBJ_TREE ,
644+ retval += report (options , tree_oid , OBJ_TREE ,
623645 FSCK_MSG_GITMODULES_SYMLINK ,
624646 ".gitmodules is a symbolic link" );
625647 }
@@ -628,7 +650,9 @@ static int fsck_tree(const struct object_id *oid,
628650 }
629651
630652 if (update_tree_entry_gently (& desc )) {
631- retval += report (options , oid , OBJ_TREE , FSCK_MSG_BAD_TREE , "cannot be parsed as a tree" );
653+ retval += report (options , tree_oid , OBJ_TREE ,
654+ FSCK_MSG_BAD_TREE ,
655+ "cannot be parsed as a tree" );
632656 break ;
633657 }
634658
@@ -676,25 +700,45 @@ static int fsck_tree(const struct object_id *oid,
676700 name_stack_clear (& df_dup_candidates );
677701
678702 if (has_null_sha1 )
679- retval += report (options , oid , OBJ_TREE , FSCK_MSG_NULL_SHA1 , "contains entries pointing to null sha1" );
703+ retval += report (options , tree_oid , OBJ_TREE ,
704+ FSCK_MSG_NULL_SHA1 ,
705+ "contains entries pointing to null sha1" );
680706 if (has_full_path )
681- retval += report (options , oid , OBJ_TREE , FSCK_MSG_FULL_PATHNAME , "contains full pathnames" );
707+ retval += report (options , tree_oid , OBJ_TREE ,
708+ FSCK_MSG_FULL_PATHNAME ,
709+ "contains full pathnames" );
682710 if (has_empty_name )
683- retval += report (options , oid , OBJ_TREE , FSCK_MSG_EMPTY_NAME , "contains empty pathname" );
711+ retval += report (options , tree_oid , OBJ_TREE ,
712+ FSCK_MSG_EMPTY_NAME ,
713+ "contains empty pathname" );
684714 if (has_dot )
685- retval += report (options , oid , OBJ_TREE , FSCK_MSG_HAS_DOT , "contains '.'" );
715+ retval += report (options , tree_oid , OBJ_TREE ,
716+ FSCK_MSG_HAS_DOT ,
717+ "contains '.'" );
686718 if (has_dotdot )
687- retval += report (options , oid , OBJ_TREE , FSCK_MSG_HAS_DOTDOT , "contains '..'" );
719+ retval += report (options , tree_oid , OBJ_TREE ,
720+ FSCK_MSG_HAS_DOTDOT ,
721+ "contains '..'" );
688722 if (has_dotgit )
689- retval += report (options , oid , OBJ_TREE , FSCK_MSG_HAS_DOTGIT , "contains '.git'" );
723+ retval += report (options , tree_oid , OBJ_TREE ,
724+ FSCK_MSG_HAS_DOTGIT ,
725+ "contains '.git'" );
690726 if (has_zero_pad )
691- retval += report (options , oid , OBJ_TREE , FSCK_MSG_ZERO_PADDED_FILEMODE , "contains zero-padded file modes" );
727+ retval += report (options , tree_oid , OBJ_TREE ,
728+ FSCK_MSG_ZERO_PADDED_FILEMODE ,
729+ "contains zero-padded file modes" );
692730 if (has_bad_modes )
693- retval += report (options , oid , OBJ_TREE , FSCK_MSG_BAD_FILEMODE , "contains bad file modes" );
731+ retval += report (options , tree_oid , OBJ_TREE ,
732+ FSCK_MSG_BAD_FILEMODE ,
733+ "contains bad file modes" );
694734 if (has_dup_entries )
695- retval += report (options , oid , OBJ_TREE , FSCK_MSG_DUPLICATE_ENTRIES , "contains duplicate file entries" );
735+ retval += report (options , tree_oid , OBJ_TREE ,
736+ FSCK_MSG_DUPLICATE_ENTRIES ,
737+ "contains duplicate file entries" );
696738 if (not_properly_sorted )
697- retval += report (options , oid , OBJ_TREE , FSCK_MSG_TREE_NOT_SORTED , "not properly sorted" );
739+ retval += report (options , tree_oid , OBJ_TREE ,
740+ FSCK_MSG_TREE_NOT_SORTED ,
741+ "not properly sorted" );
698742 return retval ;
699743}
700744
0 commit comments