@@ -909,6 +909,46 @@ TEST(discover_symlink_skipped) {
909909#endif
910910}
911911
912+ /* #1815: a symlink skip must be as visible as the other two skip paths in
913+ * the same walk (gitignore/cbmignore/skip-list files, excluded dirs): a
914+ * subtree dropped because it's a symlink must not look identical to a
915+ * complete index. */
916+ TEST (discover_symlink_skip_is_reported ) {
917+ #ifdef _WIN32
918+ SKIP_PLATFORM ("Windows: symlinks need admin / symlink() unavailable" );
919+ #else
920+ char * base = th_mktempdir ("cbm_disc_sym_rep" );
921+ ASSERT (base != NULL );
922+
923+ th_write_file (TH_PATH (base , "real.go" ), "package main\n" );
924+ char real_path [512 ], link_path [512 ];
925+ snprintf (real_path , sizeof (real_path ), "%s/real.go" , base );
926+ snprintf (link_path , sizeof (link_path ), "%s/link.go" , base );
927+ symlink (real_path , link_path );
928+
929+ cbm_discover_opts_t opts = {0 };
930+ cbm_file_info_t * files = NULL ;
931+ int count = 0 ;
932+ cbm_ignored_file_t * ignored = NULL ;
933+ int ignored_count = 0 ;
934+ int ignored_total = 0 ;
935+
936+ int rc = cbm_discover_ex2 (base , & opts , & files , & count , NULL , NULL , & ignored , & ignored_count ,
937+ & ignored_total );
938+ ASSERT_EQ (rc , 0 );
939+ ASSERT_EQ (count , 1 ); /* real.go only, same as discover_symlink_skipped */
940+ ASSERT_EQ (ignored_total , 1 );
941+ ASSERT_EQ (ignored_count , 1 );
942+ ASSERT_STR_EQ (ignored [0 ].rel_path , "link.go" );
943+ ASSERT_STR_EQ (ignored [0 ].reason , "symlink" );
944+
945+ cbm_discover_free (files , count );
946+ cbm_discover_free_ignored (ignored , ignored_count );
947+ th_cleanup (base );
948+ PASS ();
949+ #endif
950+ }
951+
912952TEST (discover_new_ignore_patterns ) {
913953 char * base = th_mktempdir ("cbm_disc_newign" );
914954 ASSERT (base != NULL );
@@ -1785,6 +1825,7 @@ SUITE(discover) {
17851825 RUN_TEST (discover_cbmignore );
17861826 RUN_TEST (discover_cbmignore_stacks );
17871827 RUN_TEST (discover_symlink_skipped );
1828+ RUN_TEST (discover_symlink_skip_is_reported );
17881829 RUN_TEST (discover_new_ignore_patterns );
17891830 RUN_TEST (discover_generic_dirs_full_mode );
17901831 RUN_TEST (discover_generic_dirs_fast_mode );
0 commit comments