]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'tb/core-eol-fix'
authorJunio C Hamano <gitster@pobox.com>
Mon, 23 May 2016 21:54:30 +0000 (14:54 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 23 May 2016 21:54:30 +0000 (14:54 -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 e4cd29146a06cfd1f2d0ffd9ba6103530c0fa901,4a27ad41cb93da45ffa693d30843c5dafb0d65f8..54253d163590091cba2d1f3ed5215c59b65a81ae
@@@ -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,25 -615,8 +630,25 @@@ 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.hooksPath::
 +      By default Git will look for your hooks in the
 +      '$GIT_DIR/hooks' directory. Set this to different path,
 +      e.g. '/etc/git/hooks', and Git will try to find your hooks in
 +      that directory, e.g. '/etc/git/hooks/pre-receive' instead of
 +      in '$GIT_DIR/hooks/pre-receive'.
 ++
 +The path can be either absolute or relative. A relative path is
 +taken as relative to the directory where the hooks are run (see
 +the "DESCRIPTION" section of linkgit:githooks[5]).
 ++
 +This configuration variable is useful in cases where you'd like to
 +centrally configure your Git hooks instead of configuring them on a
 +per-repository basis, or as a more flexible and centralized
 +alternative to having an `init.templateDir` where you've changed
 +default hooks.
  
  core.editor::
        Commands such as `commit` and `tag` that lets you edit
@@@ -1138,15 -1106,15 +1138,15 @@@ 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
        password credential is needed; the helper may consult external
 -      storage to avoid prompting the user for the credentials. See
 -      linkgit:gitcredentials[7] for details.
 +      storage to avoid prompting the user for the credentials. Note
 +      that multiple helpers may be defined. See linkgit:gitcredentials[7]
 +      for details.
  
  credential.useHttpPath::
        When acquiring credentials, consider the "path" component of an http
@@@ -1366,7 -1334,7 +1366,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::
@@@ -1506,13 -1474,13 +1506,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.
  
@@@ -1525,7 -1493,7 +1525,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::
@@@ -1686,19 -1654,12 +1686,19 @@@ http.emptyAuth:
        a username in the URL, as libcurl normally requires a username for
        authentication.
  
 +http.extraHeader::
 +      Pass an additional HTTP header when communicating with a server.  If
 +      more than one such entry exists, all of them are added as extra
 +      headers.  To allow overriding the settings inherited from the system
 +      config, an empty value will reset the extra headers to the empty list.
 +
  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::
@@@ -1925,14 -1886,6 +1925,14 @@@ interactive.singleKey:
        setting is silently ignored if portable keystroke input
        is not available; requires the Perl module Term::ReadKey.
  
 +interactive.diffFilter::
 +      When an interactive command (such as `git add --patch`) shows
 +      a colorized diff, git will pipe the diff through the shell
 +      command defined by this configuration variable. The command may
 +      mark up the diff further for human consumption, provided that it
 +      retains a one-to-one correspondence with the lines in the
 +      original diff. Defaults to disabled (no filtering).
 +
  log.abbrevCommit::
        If true, makes linkgit:git-log[1], linkgit:git-show[1], and
        linkgit:git-whatchanged[1] assume `--abbrev-commit`. You may
@@@ -2194,11 -2147,8 +2194,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.
  
@@@ -2598,9 -2548,8 +2598,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
@@@ -2780,17 -2729,6 +2780,17 @@@ submodule.<name>.ignore:
        "--ignore-submodules" option. The 'git submodule' commands are not
        affected by this setting.
  
 +submodule.fetchJobs::
 +      Specifies how many submodules are fetched/cloned at the same time.
 +      A positive integer allows up to that number of submodules fetched
 +      in parallel. A value of 0 will give some reasonable default.
 +      If unset, it defaults to 1.
 +
 +tag.forceSignAnnotated::
 +      A boolean to specify whether annotated tags created should be GPG signed.
 +      If `--annotate` is specified on the command line, it takes
 +      precedence over this option.
 +
  tag.sort::
        This variable controls the sort ordering of tags when displayed by
        linkgit:git-tag[1]. Without the "--sort=<value>" option provided, the
diff --combined config.c
index 096fe03166650f2e1e974bb1d2abac8a93ef33d6,a6adc8bc9ecdec9a92aba2bdf80af8b51e4c7863..f51c56bf92d384ace98e580c510842bd7eab9871
+++ 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;
  
        /*
@@@ -162,7 -162,7 +162,7 @@@ void git_config_push_parameter(const ch
  {
        struct strbuf env = STRBUF_INIT;
        const char *old = getenv(CONFIG_DATA_ENVIRONMENT);
 -      if (old) {
 +      if (old && *old) {
                strbuf_addstr(&env, old);
                strbuf_addch(&env, ' ');
        }
@@@ -717,9 -717,6 +717,9 @@@ static int git_default_core_config(cons
        if (!strcmp(var, "core.attributesfile"))
                return git_config_pathname(&git_attributes_file, var, value);
  
 +      if (!strcmp(var, "core.hookspath"))
 +              return git_config_pathname(&git_hooks_path, var, value);
 +
        if (!strcmp(var, "core.bare")) {
                is_bare_repository_cfg = git_config_bool(var, value);
                return 0;
  
        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;
  }
@@@ -961,7 -946,7 +957,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;
        }
  
@@@ -987,7 -972,7 +983,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.");
                }
@@@ -1199,12 -1184,11 +1195,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;
  }
  
@@@ -1248,6 -1231,8 +1244,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)
@@@ -1320,11 -1309,14 +1316,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));
@@@ -2020,7 -2012,7 +2016,7 @@@ int git_config_set_multivar_in_file_gen
        lock = xcalloc(1, sizeof(struct lock_file));
        fd = hold_lock_file_for_update(lock, config_filename, 0);
        if (fd < 0) {
 -              error("could not lock config file %s: %s", config_filename, strerror(errno));
 +              error_errno("could not lock config file %s", config_filename);
                free(store.key);
                ret = CONFIG_NO_LOCK;
                goto out_free;
                free(store.key);
  
                if ( ENOENT != errno ) {
 -                      error("opening %s: %s", config_filename,
 -                            strerror(errno));
 +                      error_errno("opening %s", config_filename);
                        ret = CONFIG_INVALID_FILE; /* same as "invalid config file" */
                        goto out_free;
                }
                if (contents == MAP_FAILED) {
                        if (errno == ENODEV && S_ISDIR(st.st_mode))
                                errno = EISDIR;
 -                      error("unable to mmap '%s': %s",
 -                            config_filename, strerror(errno));
 +                      error_errno("unable to mmap '%s'", config_filename);
                        ret = CONFIG_INVALID_FILE;
                        contents = NULL;
                        goto out_free;
                in_fd = -1;
  
                if (chmod(get_lock_file_path(lock), st.st_mode & 07777) < 0) {
 -                      error("chmod on %s failed: %s",
 -                            get_lock_file_path(lock), strerror(errno));
 +                      error_errno("chmod on %s failed", get_lock_file_path(lock));
                        ret = CONFIG_NO_WRITE;
                        goto out_free;
                }
        }
  
        if (commit_lock_file(lock) < 0) {
 -              error("could not write config file %s: %s", config_filename,
 -                    strerror(errno));
 +              error_errno("could not write config file %s", config_filename);
                ret = CONFIG_NO_WRITE;
                lock = NULL;
                goto out_free;
@@@ -2221,13 -2217,9 +2217,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,
@@@ -2334,8 -2326,8 +2330,8 @@@ int git_config_rename_section_in_file(c
        fstat(fileno(config_file), &st);
  
        if (chmod(get_lock_file_path(lock), st.st_mode & 07777) < 0) {
 -              ret = error("chmod on %s failed: %s",
 -                          get_lock_file_path(lock), strerror(errno));
 +              ret = error_errno("chmod on %s failed",
 +                                get_lock_file_path(lock));
                goto out;
        }
  
        fclose(config_file);
  unlock_and_out:
        if (commit_lock_file(lock) < 0)
 -              ret = error("could not write config file %s: %s",
 -                          config_filename, strerror(errno));
 +              ret = error_errno("could not write config file %s",
 +                                config_filename);
  out:
        free(filename_buf);
        return ret;
@@@ -2408,7 -2400,7 +2404,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,