Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
clean: use warning_errno() when appropriate
author
Nguyễn Thái Ngọc Duy
<pclouds@gmail.com>
Tue, 14 Feb 2017 09:54:49 +0000
(16:54 +0700)
committer
Junio C Hamano
<gitster@pobox.com>
Thu, 16 Feb 2017 21:40:10 +0000
(13:40 -0800)
All these warning() calls are preceded by a system call. Report the
actual error to help the user understand why we fail to remove
something.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/clean.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
3b9e3c2
)
diff --git
a/builtin/clean.c
b/builtin/clean.c
index 0371010afbad54283ceca9883f2a9fbe6da4686b..e1c074a5c0dc69a9b850edd6697884c21eba77c6 100644
(file)
--- a/
builtin/clean.c
+++ b/
builtin/clean.c
@@
-174,8
+174,10
@@
static int remove_dirs(struct strbuf *path, const char *prefix, int force_flag,
/* an empty dir could be removed even if it is unreadble */
res = dry_run ? 0 : rmdir(path->buf);
if (res) {
/* an empty dir could be removed even if it is unreadble */
res = dry_run ? 0 : rmdir(path->buf);
if (res) {
+ int saved_errno = errno;
quote_path_relative(path->buf, prefix, "ed);
quote_path_relative(path->buf, prefix, "ed);
- warning(_(msg_warn_remove_failed), quoted.buf);
+ errno = saved_errno;
+ warning_errno(_(msg_warn_remove_failed), quoted.buf);
*dir_gone = 0;
}
return res;
*dir_gone = 0;
}
return res;
@@
-208,8
+210,10
@@
static int remove_dirs(struct strbuf *path, const char *prefix, int force_flag,
quote_path_relative(path->buf, prefix, "ed);
string_list_append(&dels, quoted.buf);
} else {
quote_path_relative(path->buf, prefix, "ed);
string_list_append(&dels, quoted.buf);
} else {
+ int saved_errno = errno;
quote_path_relative(path->buf, prefix, "ed);
quote_path_relative(path->buf, prefix, "ed);
- warning(_(msg_warn_remove_failed), quoted.buf);
+ errno = saved_errno;
+ warning_errno(_(msg_warn_remove_failed), quoted.buf);
*dir_gone = 0;
ret = 1;
}
*dir_gone = 0;
ret = 1;
}
@@
-230,8
+234,10
@@
static int remove_dirs(struct strbuf *path, const char *prefix, int force_flag,
if (!res)
*dir_gone = 1;
else {
if (!res)
*dir_gone = 1;
else {
+ int saved_errno = errno;
quote_path_relative(path->buf, prefix, "ed);
quote_path_relative(path->buf, prefix, "ed);
- warning(_(msg_warn_remove_failed), quoted.buf);
+ errno = saved_errno;
+ warning_errno(_(msg_warn_remove_failed), quoted.buf);
*dir_gone = 0;
ret = 1;
}
*dir_gone = 0;
ret = 1;
}
@@
-981,8
+987,10
@@
int cmd_clean(int argc, const char **argv, const char *prefix)
} else {
res = dry_run ? 0 : unlink(abs_path.buf);
if (res) {
} else {
res = dry_run ? 0 : unlink(abs_path.buf);
if (res) {
+ int saved_errno = errno;
qname = quote_path_relative(item->string, NULL, &buf);
qname = quote_path_relative(item->string, NULL, &buf);
- warning(_(msg_warn_remove_failed), qname);
+ errno = saved_errno;
+ warning_errno(_(msg_warn_remove_failed), qname);
errors++;
} else if (!quiet) {
qname = quote_path_relative(item->string, NULL, &buf);
errors++;
} else if (!quiet) {
qname = quote_path_relative(item->string, NULL, &buf);