Skip to content

Commit b4ca5d0

Browse files
committed
Merge branch 'nd/clean-preserve-errno-in-warning'
Some warning() messages from "git clean" were updated to show the errno from failed system calls. * nd/clean-preserve-errno-in-warning: clean: use warning_errno() when appropriate
2 parents 74a7727 + cccf97d commit b4ca5d0

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

builtin/clean.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,10 @@ static int remove_dirs(struct strbuf *path, const char *prefix, int force_flag,
174174
/* an empty dir could be removed even if it is unreadble */
175175
res = dry_run ? 0 : rmdir(path->buf);
176176
if (res) {
177+
int saved_errno = errno;
177178
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);
179181
*dir_gone = 0;
180182
}
181183
return res;
@@ -208,8 +210,10 @@ static int remove_dirs(struct strbuf *path, const char *prefix, int force_flag,
208210
quote_path_relative(path->buf, prefix, &quoted);
209211
string_list_append(&dels, quoted.buf);
210212
} else {
213+
int saved_errno = errno;
211214
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);
213217
*dir_gone = 0;
214218
ret = 1;
215219
}
@@ -230,8 +234,10 @@ static int remove_dirs(struct strbuf *path, const char *prefix, int force_flag,
230234
if (!res)
231235
*dir_gone = 1;
232236
else {
237+
int saved_errno = errno;
233238
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);
235241
*dir_gone = 0;
236242
ret = 1;
237243
}
@@ -981,8 +987,10 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
981987
} else {
982988
res = dry_run ? 0 : unlink(abs_path.buf);
983989
if (res) {
990+
int saved_errno = errno;
984991
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);
986994
errors++;
987995
} else if (!quiet) {
988996
qname = quote_path_relative(item->string, NULL, &buf);

0 commit comments

Comments
 (0)