@@ -174,8 +174,10 @@ static int remove_dirs(struct strbuf *path, const char *prefix, int force_flag,
174
174
/* an empty dir could be removed even if it is unreadble */
175
175
res = dry_run ? 0 : rmdir (path -> buf );
176
176
if (res ) {
177
+ int saved_errno = errno ;
177
178
quote_path_relative (path -> buf , prefix , & quoted );
178
- warning (_ (msg_warn_remove_failed ), quoted .buf );
179
+ errno = saved_errno ;
180
+ warning_errno (_ (msg_warn_remove_failed ), quoted .buf );
179
181
* dir_gone = 0 ;
180
182
}
181
183
return res ;
@@ -208,8 +210,10 @@ static int remove_dirs(struct strbuf *path, const char *prefix, int force_flag,
208
210
quote_path_relative (path -> buf , prefix , & quoted );
209
211
string_list_append (& dels , quoted .buf );
210
212
} else {
213
+ int saved_errno = errno ;
211
214
quote_path_relative (path -> buf , prefix , & quoted );
212
- warning (_ (msg_warn_remove_failed ), quoted .buf );
215
+ errno = saved_errno ;
216
+ warning_errno (_ (msg_warn_remove_failed ), quoted .buf );
213
217
* dir_gone = 0 ;
214
218
ret = 1 ;
215
219
}
@@ -230,8 +234,10 @@ static int remove_dirs(struct strbuf *path, const char *prefix, int force_flag,
230
234
if (!res )
231
235
* dir_gone = 1 ;
232
236
else {
237
+ int saved_errno = errno ;
233
238
quote_path_relative (path -> buf , prefix , & quoted );
234
- warning (_ (msg_warn_remove_failed ), quoted .buf );
239
+ errno = saved_errno ;
240
+ warning_errno (_ (msg_warn_remove_failed ), quoted .buf );
235
241
* dir_gone = 0 ;
236
242
ret = 1 ;
237
243
}
@@ -981,8 +987,10 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
981
987
} else {
982
988
res = dry_run ? 0 : unlink (abs_path .buf );
983
989
if (res ) {
990
+ int saved_errno = errno ;
984
991
qname = quote_path_relative (item -> string , NULL , & buf );
985
- warning (_ (msg_warn_remove_failed ), qname );
992
+ errno = saved_errno ;
993
+ warning_errno (_ (msg_warn_remove_failed ), qname );
986
994
errors ++ ;
987
995
} else if (!quiet ) {
988
996
qname = quote_path_relative (item -> string , NULL , & buf );
0 commit comments