Merge branch 'jv/maint-config-set' into maint
authorJunio C Hamano <gitster@pobox.com>
Wed, 28 Dec 2011 20:03:19 +0000 (12:03 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 28 Dec 2011 20:03:19 +0000 (12:03 -0800)
* jv/maint-config-set:
Fix an incorrect reference to --set-all.

1  2 
builtin/config.c
diff --combined builtin/config.c
index 0315ad76f881aab9a64084f8d2fdd2019907e4cb,b346f868dae65e066d56d75286e3cd885cd1aae1..d35c06ae51573eafbddd6309fda3f90ecef35d54
@@@ -99,7 -99,6 +99,7 @@@ static int show_config(const char *key_
        const char *vptr = value;
        int must_free_vptr = 0;
        int dup_error = 0;
 +      int must_print_delim = 0;
  
        if (!use_key_regexp && strcmp(key_, key))
                return 0;
                return 0;
  
        if (show_keys) {
 -              if (value_)
 -                      printf("%s%c", key_, key_delim);
 -              else
 -                      printf("%s", key_);
 +              printf("%s", key_);
 +              must_print_delim = 1;
        }
        if (seen && !do_all)
                dup_error = 1;
        } else if (types == TYPE_PATH) {
                git_config_pathname(&vptr, key_, value_);
                must_free_vptr = 1;
 +      } else if (value_) {
 +              vptr = value_;
 +      } else {
 +              /* Just show the key name */
 +              vptr = "";
 +              must_print_delim = 0;
        }
 -      else
 -              vptr = value_?value_:"";
        seen++;
        if (dup_error) {
                error("More than one value for the key %s: %s",
                                key_, vptr);
        }
 -      else
 +      else {
 +              if (must_print_delim)
 +                      printf("%c", key_delim);
                printf("%s%c", vptr, term);
 +      }
        if (must_free_vptr)
                /* If vptr must be freed, it's a pointer to a
                 * dynamically allocated buffer, it's safe to cast to
@@@ -309,18 -303,24 +309,18 @@@ static void get_color(const char *def_c
        fputs(parsed_color, stdout);
  }
  
 -static int stdout_is_tty;
  static int get_colorbool_found;
  static int get_diff_color_found;
 +static int get_color_ui_found;
  static int git_get_colorbool_config(const char *var, const char *value,
                void *cb)
  {
 -      if (!strcmp(var, get_colorbool_slot)) {
 -              get_colorbool_found =
 -                      git_config_colorbool(var, value, stdout_is_tty);
 -      }
 -      if (!strcmp(var, "diff.color")) {
 -              get_diff_color_found =
 -                      git_config_colorbool(var, value, stdout_is_tty);
 -      }
 -      if (!strcmp(var, "color.ui")) {
 -              git_use_color_default = git_config_colorbool(var, value, stdout_is_tty);
 -              return 0;
 -      }
 +      if (!strcmp(var, get_colorbool_slot))
 +              get_colorbool_found = git_config_colorbool(var, value);
 +      else if (!strcmp(var, "diff.color"))
 +              get_diff_color_found = git_config_colorbool(var, value);
 +      else if (!strcmp(var, "color.ui"))
 +              get_color_ui_found = git_config_colorbool(var, value);
        return 0;
  }
  
@@@ -334,11 -334,9 +334,11 @@@ static int get_colorbool(int print
                if (!strcmp(get_colorbool_slot, "color.diff"))
                        get_colorbool_found = get_diff_color_found;
                if (get_colorbool_found < 0)
 -                      get_colorbool_found = git_use_color_default;
 +                      get_colorbool_found = get_color_ui_found;
        }
  
 +      get_colorbool_found = want_color(get_colorbool_found);
 +
        if (print) {
                printf("%s\n", get_colorbool_found ? "true" : "false");
                return 0;
@@@ -444,7 -442,7 +444,7 @@@ int cmd_config(int argc, const char **a
                ret = git_config_set(argv[0], value);
                if (ret == CONFIG_NOTHING_SET)
                        error("cannot overwrite multiple values with a single value\n"
-                       "       Use a regexp, --add or --set-all to change %s.", argv[0]);
+                       "       Use a regexp, --add or --replace-all to change %s.", argv[0]);
                return ret;
        }
        else if (actions == ACTION_SET_ALL) {
        }
        else if (actions == ACTION_GET_COLORBOOL) {
                if (argc == 1)
 -                      stdout_is_tty = git_config_bool("command line", argv[0]);
 -              else if (argc == 0)
 -                      stdout_is_tty = isatty(1);
 +                      color_stdout_is_tty = git_config_bool("command line", argv[0]);
                return get_colorbool(argc != 0);
        }