Merge branch 'nd/clean-preserve-errno-in-warning'
authorJunio C Hamano <gitster@pobox.com>
Mon, 27 Feb 2017 21:57:16 +0000 (13:57 -0800)
committerJunio C Hamano <gitster@pobox.com>
Mon, 27 Feb 2017 21:57:16 +0000 (13:57 -0800)
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

1  2 
builtin/clean.c
diff --combined builtin/clean.c
index d6bc3aaaea0dfdbac2386d54f4ff2d25dbccf7e6,e1c074a5c0dc69a9b850edd6697884c21eba77c6..d861f836a29bf98d248f27632a8c47711a5da3a5
@@@ -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, &quoted);
-                       warning(_(msg_warn_remove_failed), quoted.buf);
+                       errno = saved_errno;
+                       warning_errno(_(msg_warn_remove_failed), quoted.buf);
                        *dir_gone = 0;
                }
                return res;
                                quote_path_relative(path->buf, prefix, &quoted);
                                string_list_append(&dels, quoted.buf);
                        } else {
+                               int saved_errno = errno;
                                quote_path_relative(path->buf, prefix, &quoted);
-                               warning(_(msg_warn_remove_failed), quoted.buf);
+                               errno = saved_errno;
+                               warning_errno(_(msg_warn_remove_failed), quoted.buf);
                                *dir_gone = 0;
                                ret = 1;
                        }
                if (!res)
                        *dir_gone = 1;
                else {
+                       int saved_errno = errno;
                        quote_path_relative(path->buf, prefix, &quoted);
-                       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"
                    "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);