Merge branch 'tb/core-eol-fix' into maint
authorJunio C Hamano <gitster@pobox.com>
Mon, 6 Jun 2016 21:27:36 +0000 (14:27 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 6 Jun 2016 21:27:36 +0000 (14:27 -0700)
A couple of bugs around core.autocrlf have been fixed.

* tb/core-eol-fix:
convert.c: ident + core.autocrlf didn't work
t0027: test cases for combined attributes
convert: allow core.autocrlf=input and core.eol=crlf
t0027: make commit_chk_wrnNNO() reliable

1  2 
Documentation/config.txt
config.c
diff --combined Documentation/config.txt
index b945d67bc00d9b6fea7ae805c7d0a9e1f5962b1a,4a27ad41cb93da45ffa693d30843c5dafb0d65f8..02696208c9d8f014ad148eca4874b06f9db2fcfb
@@@ -81,16 -81,13 +81,16 @@@ Include
  
  You can include one config file from another by setting the special
  `include.path` variable to the name of the file to be included. The
 +variable takes a pathname as its value, and is subject to tilde
 +expansion.
 +
 +The
  included file is expanded immediately, as if its contents had been
  found at the location of the include directive. If the value of the
  `include.path` variable is a relative path, the path is considered to be
  relative to the configuration file in which the include directive was
 -found. The value of `include.path` is subject to tilde expansion: `~/`
 -is expanded to the value of `$HOME`, and `~user/` to the specified
 -user's home directory. See below for examples.
 +found.  See below for examples.
 +
  
  Example
  ~~~~~~~
        [include]
                path = /path/to/foo.inc ; include by absolute path
                path = foo ; expand "foo" relative to the current file
 -              path = ~/foo ; expand "foo" in your $HOME directory
 +              path = ~/foo ; expand "foo" in your `$HOME` directory
  
  
  Values
@@@ -172,13 -169,6 +172,13 @@@ thing on the same output line (e.g. ope
  list of branch names in `log --decorate` output) is set to be
  painted with `bold` or some other attribute.
  
 +pathname::
 +      A variable that takes a pathname value can be given a
 +      string that begins with "`~/`" or "`~user/`", and the usual
 +      tilde expansion happens to such a string: `~/`
 +      is expanded to the value of `$HOME`, and `~user/` to the
 +      specified user's home directory.
 +
  
  Variables
  ~~~~~~~~~
@@@ -279,12 -269,6 +279,12 @@@ See linkgit:git-update-index[1]
  +
  The default is true (when core.filemode is not specified in the config file).
  
 +core.hideDotFiles::
 +      (Windows-only) If true, mark newly-created directories and files whose
 +      name starts with a dot as hidden.  If 'dotGitOnly', only the `.git/`
 +      directory is hidden, but no other files starting with a dot.  The
 +      default mode is 'dotGitOnly'.
 +
  core.ignoreCase::
        If true, this option enables various workarounds to enable
        Git to work better on filesystems that are not case sensitive,
@@@ -353,9 -337,9 +353,9 @@@ core.quotePath:
  
  core.eol::
        Sets the line ending type to use in the working directory for
-       files that have the `text` property set.  Alternatives are
-       'lf', 'crlf' and 'native', which uses the platform's native
-       line ending.  The default value is `native`.  See
+       files that have the `text` property set when core.autocrlf is false.
+       Alternatives are 'lf', 'crlf' and 'native', which uses the platform's
+       native line ending.  The default value is `native`.  See
        linkgit:gitattributes[5] for more information on end-of-line
        conversion.
  
@@@ -502,10 -486,10 +502,10 @@@ repository's usual working tree)
  
  core.logAllRefUpdates::
        Enable the reflog. Updates to a ref <ref> is logged to the file
 -      "$GIT_DIR/logs/<ref>", by appending the new and old
 +      "`$GIT_DIR/logs/<ref>`", by appending the new and old
        SHA-1, the date/time and the reason of the update, but
        only when the file exists.  If this configuration
 -      variable is set to true, missing "$GIT_DIR/logs/<ref>"
 +      variable is set to true, missing "`$GIT_DIR/logs/<ref>`"
        file is automatically created for branch heads (i.e. under
        refs/heads/), remote refs (i.e. under refs/remotes/),
        note refs (i.e. under refs/notes/), and the symbolic ref HEAD.
@@@ -609,11 -593,12 +609,11 @@@ be delta compressed, but larger binary 
  Common unit suffixes of 'k', 'm', or 'g' are supported.
  
  core.excludesFile::
 -      In addition to '.gitignore' (per-directory) and
 -      '.git/info/exclude', Git looks into this file for patterns
 -      of files which are not meant to be tracked.  "`~/`" is expanded
 -      to the value of `$HOME` and "`~user/`" to the specified user's
 -      home directory. Its default value is $XDG_CONFIG_HOME/git/ignore.
 -      If $XDG_CONFIG_HOME is either not set or empty, $HOME/.config/git/ignore
 +      Specifies the pathname to the file that contains patterns to
 +      describe paths that are not meant to be tracked, in addition
 +      to '.gitignore' (per-directory) and '.git/info/exclude'.
 +      Defaults to `$XDG_CONFIG_HOME/git/ignore`.
 +      If `$XDG_CONFIG_HOME` is either not set or empty, `$HOME/.config/git/ignore`
        is used instead. See linkgit:gitignore[5].
  
  core.askPass::
@@@ -630,8 -615,8 +630,8 @@@ core.attributesFile:
        '.git/info/attributes', Git looks into this file for attributes
        (see linkgit:gitattributes[5]). Path expansions are made the same
        way as for `core.excludesFile`. Its default value is
 -      $XDG_CONFIG_HOME/git/attributes. If $XDG_CONFIG_HOME is either not
 -      set or empty, $HOME/.config/git/attributes is used instead.
 +      `$XDG_CONFIG_HOME/git/attributes`. If `$XDG_CONFIG_HOME` is either not
 +      set or empty, `$HOME/.config/git/attributes` is used instead.
  
  core.editor::
        Commands such as `commit` and `tag` that lets you edit
@@@ -1121,8 -1106,9 +1121,8 @@@ commit.status:
        message.  Defaults to true.
  
  commit.template::
 -      Specify a file to use as the template for new commit messages.
 -      "`~/`" is expanded to the value of `$HOME` and "`~user/`" to the
 -      specified user's home directory.
 +      Specify the pathname of a file to use as the template for
 +      new commit messages.
  
  credential.helper::
        Specify an external helper to be called when a username or
@@@ -1348,7 -1334,7 +1348,7 @@@ gc.worktreePruneExpire:
        'git worktree prune --expire 3.months.ago'.
        This config variable can be used to set a different grace
        period. The value "now" may be used to disable the grace
 -      period and prune $GIT_DIR/worktrees immediately, or "never"
 +      period and prune `$GIT_DIR/worktrees` immediately, or "never"
        may be used to suppress pruning.
  
  gc.reflogExpire::
@@@ -1488,13 -1474,13 +1488,13 @@@ grep.fallbackToNoIndex:
        is executed outside of a git repository.  Defaults to false.
  
  gpg.program::
 -      Use this custom program instead of "gpg" found on $PATH when
 +      Use this custom program instead of "`gpg`" found on `$PATH` when
        making or verifying a PGP signature. The program must support the
        same command-line interface as GPG, namely, to verify a detached
 -      signature, "gpg --verify $file - <$signature" is run, and the
 +      signature, "`gpg --verify $file - <$signature`" is run, and the
        program is expected to signal a good signature by exiting with
        code 0, and to generate an ASCII-armored detached signature, the
 -      standard input of "gpg -bsau $key" is fed with the contents to be
 +      standard input of "`gpg -bsau $key`" is fed with the contents to be
        signed, and the program is expected to send the result to its
        standard output.
  
@@@ -1507,7 -1493,7 +1507,7 @@@ gui.diffContext:
        made by the linkgit:git-gui[1]. The default is "5".
  
  gui.displayUntracked::
 -      Determines if linkgit::git-gui[1] shows untracked files
 +      Determines if linkgit:git-gui[1] shows untracked files
        in the file list. The default is "true".
  
  gui.encoding::
@@@ -1669,12 -1655,11 +1669,12 @@@ http.emptyAuth:
        authentication.
  
  http.cookieFile::
 -      File containing previously stored cookie lines which should be used
 +      The pathname of a file containing previously stored cookie lines,
 +      which should be used
        in the Git http session, if they match the server. The file format
        of the file to read cookies from should be plain HTTP headers or
 -      the Netscape/Mozilla cookie file format (see linkgit:curl[1]).
 -      NOTE that the file specified with http.cookieFile is only used as
 +      the Netscape/Mozilla cookie file format (see `curl(1)`).
 +      NOTE that the file specified with http.cookieFile is used only as
        input unless http.saveCookies is set.
  
  http.saveCookies::
@@@ -2162,11 -2147,8 +2162,11 @@@ pack.packSizeLimit:
        The maximum size of a pack.  This setting only affects
        packing to a file when repacking, i.e. the git:// protocol
        is unaffected.  It can be overridden by the `--max-pack-size`
 -      option of linkgit:git-repack[1]. The minimum size allowed is
 -      limited to 1 MiB. The default is unlimited.
 +      option of linkgit:git-repack[1].  Reaching this limit results
 +      in the creation of multiple packfiles; which in turn prevents
 +      bitmaps from being created.
 +      The minimum size allowed is limited to 1 MiB.
 +      The default is unlimited.
        Common unit suffixes of 'k', 'm', or 'g' are
        supported.
  
@@@ -2566,9 -2548,8 +2566,9 @@@ repack.writeBitmaps:
        objects to disk (e.g., when `git repack -a` is run).  This
        index can speed up the "counting objects" phase of subsequent
        packs created for clones and fetches, at the cost of some disk
 -      space and extra time spent on the initial repack.  Defaults to
 -      false.
 +      space and extra time spent on the initial repack.  This has
 +      no effect if multiple packfiles are created.
 +      Defaults to false.
  
  rerere.autoUpdate::
        When set to true, `git-rerere` updates the index with the
diff --combined config.c
index adf12a17ef41f70244df320df404d9ccaefd7b4b,a6adc8bc9ecdec9a92aba2bdf80af8b51e4c7863..6dbc8a409e7e6e674e399e1d9b8ef8ef3c9290b7
+++ b/config.c
@@@ -108,7 -108,7 +108,7 @@@ static int handle_path_include(const ch
  
        expanded = expand_user_path(path);
        if (!expanded)
 -              return error("Could not expand include path '%s'", path);
 +              return error("could not expand include path '%s'", path);
        path = expanded;
  
        /*
@@@ -803,8 -803,6 +803,6 @@@ static int git_default_core_config(cons
  
        if (!strcmp(var, "core.autocrlf")) {
                if (value && !strcasecmp(value, "input")) {
-                       if (core_eol == EOL_CRLF)
-                               return error("core.autocrlf=input conflicts with core.eol=crlf");
                        auto_crlf = AUTO_CRLF_INPUT;
                        return 0;
                }
                        core_eol = EOL_NATIVE;
                else
                        core_eol = EOL_UNSET;
-               if (core_eol == EOL_CRLF && auto_crlf == AUTO_CRLF_INPUT)
-                       return error("core.autocrlf=input conflicts with core.eol=crlf");
                return 0;
        }
  
                return 0;
        }
  
 +      if (!strcmp(var, "core.hidedotfiles")) {
 +              if (value && !strcasecmp(value, "dotgitonly"))
 +                      hide_dotfiles = HIDE_DOTFILES_DOTGITONLY;
 +              else
 +                      hide_dotfiles = git_config_bool(var, value);
 +              return 0;
 +      }
 +
        /* Add other config variables here and to Documentation/config.txt. */
        return 0;
  }
@@@ -958,7 -946,7 +954,7 @@@ static int git_default_branch_config(co
                else if (!strcmp(value, "always"))
                        autorebase = AUTOREBASE_ALWAYS;
                else
 -                      return error("Malformed value for %s", var);
 +                      return error("malformed value for %s", var);
                return 0;
        }
  
@@@ -984,7 -972,7 +980,7 @@@ static int git_default_push_config(cons
                else if (!strcmp(value, "current"))
                        push_default = PUSH_DEFAULT_CURRENT;
                else {
 -                      error("Malformed value for %s: %s", var, value);
 +                      error("malformed value for %s: %s", var, value);
                        return error("Must be one of nothing, matching, simple, "
                                     "upstream or current.");
                }
@@@ -1196,12 -1184,11 +1192,12 @@@ int git_config_system(void
        return !git_env_bool("GIT_CONFIG_NOSYSTEM", 0);
  }
  
 -int git_config_early(config_fn_t fn, void *data, const char *repo_config)
 +static int do_git_config_sequence(config_fn_t fn, void *data)
  {
        int ret = 0, found = 0;
        char *xdg_config = xdg_config_home("config");
        char *user_config = expand_user_path("~/.gitconfig");
 +      char *repo_config = git_pathdup("config");
  
        if (git_config_system() && !access_or_die(git_etc_gitconfig(), R_OK, 0)) {
                ret += git_config_from_file(fn, git_etc_gitconfig(),
  
        free(xdg_config);
        free(user_config);
 +      free(repo_config);
        return ret == 0 ? found : ret;
  }
  
@@@ -1245,6 -1231,8 +1241,6 @@@ int git_config_with_options(config_fn_
                            struct git_config_source *config_source,
                            int respect_includes)
  {
 -      char *repo_config = NULL;
 -      int ret;
        struct config_include_data inc = CONFIG_INCLUDE_INIT;
  
        if (respect_includes) {
        else if (config_source && config_source->blob)
                return git_config_from_blob_ref(fn, config_source->blob, data);
  
 -      repo_config = git_pathdup("config");
 -      ret = git_config_early(fn, data, repo_config);
 -      if (repo_config)
 -              free(repo_config);
 -      return ret;
 +      return do_git_config_sequence(fn, data);
  }
  
  static void git_config_raw(config_fn_t fn, void *data)
@@@ -1317,11 -1309,14 +1313,11 @@@ static struct config_set_element *confi
        struct config_set_element k;
        struct config_set_element *found_entry;
        char *normalized_key;
 -      int ret;
        /*
         * `key` may come from the user, so normalize it before using it
         * for querying entries from the hashmap.
         */
 -      ret = git_config_parse_key(key, &normalized_key, NULL);
 -
 -      if (ret)
 +      if (git_config_parse_key(key, &normalized_key, NULL))
                return NULL;
  
        hashmap_entry_init(&k, strhash(normalized_key));
@@@ -2222,13 -2217,9 +2218,13 @@@ void git_config_set_multivar_in_file(co
                                     const char *key, const char *value,
                                     const char *value_regex, int multi_replace)
  {
 -      if (git_config_set_multivar_in_file_gently(config_filename, key, value,
 -                                                 value_regex, multi_replace) < 0)
 -              die(_("Could not set '%s' to '%s'"), key, value);
 +      if (!git_config_set_multivar_in_file_gently(config_filename, key, value,
 +                                                  value_regex, multi_replace))
 +              return;
 +      if (value)
 +              die(_("could not set '%s' to '%s'"), key, value);
 +      else
 +              die(_("could not unset '%s'"), key);
  }
  
  int git_config_set_multivar_gently(const char *key, const char *value,
@@@ -2409,7 -2400,7 +2405,7 @@@ int git_config_rename_section(const cha
  #undef config_error_nonbool
  int config_error_nonbool(const char *var)
  {
 -      return error("Missing value for '%s'", var);
 +      return error("missing value for '%s'", var);
  }
  
  int parse_config_key(const char *var,