@@ -2573,28 +2573,32 @@ enum symlink_type {
2573
2573
SYMLINK_TYPE_DIRECTORY ,
2574
2574
};
2575
2575
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 )
2577
2577
{
2578
2578
static struct attr_check * check ;
2579
2579
const char * value ;
2580
2580
2581
+ if (!index )
2582
+ return SYMLINK_TYPE_UNSPECIFIED ;
2583
+
2581
2584
if (!check )
2582
2585
check = attr_check_initl ("symlink" , NULL );
2583
2586
2584
- git_check_attr (the_repository -> index , link , check );
2587
+ git_check_attr (index , link , check );
2585
2588
2586
2589
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" ))
2590
2593
return SYMLINK_TYPE_FILE ;
2591
- else if (!strcmp (value , "dir" ))
2594
+ if (!strcmp (value , "dir" ) || ! strcmp ( value , "directory " ))
2592
2595
return SYMLINK_TYPE_DIRECTORY ;
2593
2596
2597
+ warning (_ ("ignoring invalid symlink type '%s' for '%s'" ), value , link );
2594
2598
return SYMLINK_TYPE_UNSPECIFIED ;
2595
2599
}
2596
2600
2597
- int symlink ( const char * target , const char * link )
2601
+ int mingw_create_symlink ( struct index_state * index , const char * target , const char * link )
2598
2602
{
2599
2603
wchar_t wtarget [MAX_LONG_PATH ], wlink [MAX_LONG_PATH ];
2600
2604
int len ;
@@ -2614,7 +2618,7 @@ int symlink(const char *target, const char *link)
2614
2618
if (wtarget [len ] == '/' )
2615
2619
wtarget [len ] = '\\' ;
2616
2620
2617
- switch (check_symlink_attr (link )) {
2621
+ switch (check_symlink_attr (index , link )) {
2618
2622
case SYMLINK_TYPE_UNSPECIFIED :
2619
2623
/* Create a phantom symlink: it is initially created as a file
2620
2624
* symlink, but may change to a directory symlink later if/when
0 commit comments