diff options
Diffstat (limited to 'builtin/clean.c')
-rw-r--r-- | builtin/clean.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/builtin/clean.c b/builtin/clean.c index 0371010afb..329b68c40b 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; } @@ -287,11 +293,11 @@ static void pretty_print_menus(struct string_list *menu_list) 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 @@ static void prompt_help_cmd(int singleton) "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 @@ static int parse_choice(struct menu_stuff *menu_stuff, 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; } @@ -677,7 +683,7 @@ static int filter_by_patterns_cmd(void) for_each_string_list_item(item, &del_list) { int dtype = DT_UNKNOWN; - if (is_excluded(&dir, item->string, &dtype)) { + if (is_excluded(&dir, &the_index, item->string, &dtype)) { *item->string = '\0'; changed++; } @@ -774,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; } @@ -924,7 +930,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix) PATHSPEC_PREFER_CWD, prefix, argv); - fill_directory(&dir, &pathspec); + fill_directory(&dir, &the_index, &pathspec); for (i = 0; i < dir.nr; i++) { struct dir_entry *ent = dir.entries[i]; @@ -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); |