From: Junio C Hamano Date: Mon, 27 Feb 2017 21:57:16 +0000 (-0800) Subject: Merge branch 'nd/clean-preserve-errno-in-warning' X-Git-Tag: v2.13.0-rc0~160 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/b4ca5d05e7ad4ec67eddaadc9ade9a01581214b1?ds=inline;hp=-c 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 --- b4ca5d05e7ad4ec67eddaadc9ade9a01581214b1 diff --combined builtin/clean.c index d6bc3aaaea,e1c074a5c0..d861f836a2 --- a/builtin/clean.c +++ b/builtin/clean.c @@@ -174,8 -174,10 +174,10 @@@ static int remove_dirs(struct strbuf *p /* 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 +210,10 @@@ 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 +234,10 @@@ 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; } @@@ -287,11 -293,11 +293,11 @@@ static void pretty_print_menus(struct s static void prompt_help_cmd(int singleton) { clean_print_color(CLEAN_COLOR_HELP); - printf_ln(singleton ? + printf(singleton ? _("Prompt help:\n" "1 - select a numbered item\n" "foo - select item based on unique prefix\n" - " - (empty) select nothing") : + " - (empty) select nothing\n") : _("Prompt help:\n" "1 - select a single item\n" "3-5 - select a range of items\n" @@@ -299,7 -305,7 +305,7 @@@ "foo - select item based on unique prefix\n" "-... - unselect specified items\n" "* - choose all items\n" - " - (empty) finish selecting")); + " - (empty) finish selecting\n")); clean_print_color(CLEAN_COLOR_RESET); } @@@ -508,7 -514,7 +514,7 @@@ static int parse_choice(struct menu_stu if (top <= 0 || bottom <= 0 || top > menu_stuff->nr || bottom > top || (is_single && bottom != top)) { clean_print_color(CLEAN_COLOR_ERROR); - printf_ln(_("Huh (%s)?"), (*ptr)->buf); + printf(_("Huh (%s)?\n"), (*ptr)->buf); clean_print_color(CLEAN_COLOR_RESET); continue; } @@@ -774,7 -780,7 +780,7 @@@ static int ask_each_cmd(void static int quit_cmd(void) { string_list_clear(&del_list, 0); - printf_ln(_("Bye.")); + printf(_("Bye.\n")); return MENU_RETURN_NO_LOOP; } @@@ -981,8 -987,10 +987,10 @@@ int cmd_clean(int argc, const char **ar } 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);