25
25
#include "pathspec.h"
26
26
#include "help.h"
27
27
#include "prompt.h"
28
+ #include "advice.h"
28
29
29
30
static int require_force = -1 ; /* unset */
30
31
static int interactive ;
@@ -220,6 +221,9 @@ static int remove_dirs(struct strbuf *path, const char *prefix, int force_flag,
220
221
quote_path (path -> buf , prefix , & quoted , 0 );
221
222
errno = saved_errno ;
222
223
warning_errno (_ (msg_warn_remove_failed ), quoted .buf );
224
+ if (saved_errno == ENAMETOOLONG ) {
225
+ advise_if_enabled (ADVICE_NAME_TOO_LONG , _ ("Setting `core.longPaths` may allow the deletion to succeed." ));
226
+ }
223
227
* dir_gone = 0 ;
224
228
}
225
229
ret = res ;
@@ -255,6 +259,9 @@ static int remove_dirs(struct strbuf *path, const char *prefix, int force_flag,
255
259
quote_path (path -> buf , prefix , & quoted , 0 );
256
260
errno = saved_errno ;
257
261
warning_errno (_ (msg_warn_remove_failed ), quoted .buf );
262
+ if (saved_errno == ENAMETOOLONG ) {
263
+ advise_if_enabled (ADVICE_NAME_TOO_LONG , _ ("Setting `core.longPaths` may allow the deletion to succeed." ));
264
+ }
258
265
* dir_gone = 0 ;
259
266
ret = 1 ;
260
267
}
@@ -298,6 +305,9 @@ static int remove_dirs(struct strbuf *path, const char *prefix, int force_flag,
298
305
quote_path (path -> buf , prefix , & quoted , 0 );
299
306
errno = saved_errno ;
300
307
warning_errno (_ (msg_warn_remove_failed ), quoted .buf );
308
+ if (saved_errno == ENAMETOOLONG ) {
309
+ advise_if_enabled (ADVICE_NAME_TOO_LONG , _ ("Setting `core.longPaths` may allow the deletion to succeed." ));
310
+ }
301
311
* dir_gone = 0 ;
302
312
ret = 1 ;
303
313
}
@@ -1043,6 +1053,7 @@ int cmd_clean(int argc,
1043
1053
1044
1054
if (repo_read_index (the_repository ) < 0 )
1045
1055
die (_ ("index file corrupt" ));
1056
+ enable_fscache (the_repository -> index -> cache_nr );
1046
1057
1047
1058
pl = add_pattern_list (& dir , EXC_CMDL , "--exclude option" );
1048
1059
for (i = 0 ; i < exclude_list .nr ; i ++ )
@@ -1109,6 +1120,9 @@ int cmd_clean(int argc,
1109
1120
qname = quote_path (item -> string , NULL , & buf , 0 );
1110
1121
errno = saved_errno ;
1111
1122
warning_errno (_ (msg_warn_remove_failed ), qname );
1123
+ if (saved_errno == ENAMETOOLONG ) {
1124
+ advise_if_enabled (ADVICE_NAME_TOO_LONG , _ ("Setting `core.longPaths` may allow the deletion to succeed." ));
1125
+ }
1112
1126
errors ++ ;
1113
1127
} else if (!quiet ) {
1114
1128
qname = quote_path (item -> string , NULL , & buf , 0 );
@@ -1117,6 +1131,7 @@ int cmd_clean(int argc,
1117
1131
}
1118
1132
}
1119
1133
1134
+ disable_fscache ();
1120
1135
strbuf_release (& abs_path );
1121
1136
strbuf_release (& buf );
1122
1137
string_list_clear (& del_list , 0 );
0 commit comments