@@ -2573,28 +2573,32 @@ enum symlink_type {
25732573 SYMLINK_TYPE_DIRECTORY ,
25742574};
25752575
2576- static enum symlink_type check_symlink_attr (const char * link )
2576+ static enum symlink_type check_symlink_attr (struct index_state * index , const char * link )
25772577{
25782578 static struct attr_check * check ;
25792579 const char * value ;
25802580
2581+ if (!index )
2582+ return SYMLINK_TYPE_UNSPECIFIED ;
2583+
25812584 if (!check )
25822585 check = attr_check_initl ("symlink" , NULL );
25832586
2584- git_check_attr (the_repository -> index , link , check );
2587+ git_check_attr (index , link , check );
25852588
25862589 value = check -> items [0 ].value ;
2587- if (value == NULL )
2588- ;
2589- else if (!strcmp (value , "file" ))
2590+ if (ATTR_UNSET ( value ) )
2591+ return SYMLINK_TYPE_UNSPECIFIED ;
2592+ if (!strcmp (value , "file" ))
25902593 return SYMLINK_TYPE_FILE ;
2591- else if (!strcmp (value , "dir" ))
2594+ if (!strcmp (value , "dir" ) || ! strcmp ( value , "directory " ))
25922595 return SYMLINK_TYPE_DIRECTORY ;
25932596
2597+ warning (_ ("ignoring invalid symlink type '%s' for '%s'" ), value , link );
25942598 return SYMLINK_TYPE_UNSPECIFIED ;
25952599}
25962600
2597- int symlink ( const char * target , const char * link )
2601+ int mingw_create_symlink ( struct index_state * index , const char * target , const char * link )
25982602{
25992603 wchar_t wtarget [MAX_LONG_PATH ], wlink [MAX_LONG_PATH ];
26002604 int len ;
@@ -2614,7 +2618,7 @@ int symlink(const char *target, const char *link)
26142618 if (wtarget [len ] == '/' )
26152619 wtarget [len ] = '\\' ;
26162620
2617- switch (check_symlink_attr (link )) {
2621+ switch (check_symlink_attr (index , link )) {
26182622 case SYMLINK_TYPE_UNSPECIFIED :
26192623 /* Create a phantom symlink: it is initially created as a file
26202624 * symlink, but may change to a directory symlink later if/when
0 commit comments