diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-02-27 13:57:16 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-02-27 13:57:16 -0800 |
commit | b4ca5d05e7ad4ec67eddaadc9ade9a01581214b1 (patch) | |
tree | 0f8dc3945c8f631623413448a651018fe8a60980 /builtin/clean.c | |
parent | Merge branch 'jk/show-branch-lift-name-len-limit' (diff) | |
parent | clean: use warning_errno() when appropriate (diff) | |
download | tgif-b4ca5d05e7ad4ec67eddaadc9ade9a01581214b1.tar.xz |
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
Diffstat (limited to 'builtin/clean.c')
-rw-r--r-- | builtin/clean.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/builtin/clean.c b/builtin/clean.c index d6bc3aaaea..d861f836a2 100644 --- 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) { + int saved_errno = errno; 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; @@ -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 { + int saved_errno = errno; 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; } @@ -230,8 +234,10 @@ static int remove_dirs(struct strbuf *path, const char *prefix, int force_flag, if (!res) *dir_gone = 1; else { + int saved_errno = errno; 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; } @@ -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) { + int saved_errno = errno; 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); |