1. 04 8月, 2017 2 次提交
    • B
      submodule-config: lazy-load a repository's .gitmodules file · ff6f1f56
      Brandon Williams 提交于
      In order to use the submodule-config subsystem, callers first need to
      initialize it by calling 'repo_read_gitmodules()' or
      'gitmodules_config()' (which just redirects to
      'repo_read_gitmodules()').  There are a couple of callers who need to
      load an explicit revision of the repository's .gitmodules file (grep) or
      need to modify the .gitmodules file so they would need to load it before
      modify the file (checkout), but the majority of callers are simply
      reading the .gitmodules file present in the working tree.  For the
      common case it would be nice to avoid the boilerplate of initializing
      the submodule-config system before using it, so instead let's perform
      lazy-loading of the submodule-config system.
      
      Remove the calls to reading the gitmodules file from ls-files to show
      that lazy-loading the .gitmodules file works.
      Signed-off-by: NBrandon Williams <bmwill@google.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ff6f1f56
    • B
      submodule-config: move submodule-config functions to submodule-config.c · 1b796ace
      Brandon Williams 提交于
      Migrate the functions used to initialize the submodule-config to
      submodule-config.c so that the callback routine used in the
      initialization process can be static and prevent it from being used
      outside of initializing the submodule-config through the main API.
      Signed-off-by: NBrandon Williams <bmwill@google.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      1b796ace
  2. 24 6月, 2017 1 次提交
  3. 16 6月, 2017 1 次提交
  4. 14 6月, 2017 13 次提交
  5. 12 5月, 2017 1 次提交
    • B
      ls-files: prevent prune_cache from overeagerly pruning submodules · cbca060e
      Brandon Williams 提交于
      Since (ae8d0824 pathspec: pass directory indicator to
      match_pathspec_item()) the path matching logic has been able to cope
      with submodules without needing to strip off a trailing slash if a path
      refers to a submodule.
      
      ls-files is the only caller of 'parse_pathspec()' which relies on the
      behavior of the PATHSPEC_STRIP_SUBMODULE_SLASH_CHEAP flag because it
      uses the result to construct a common prefix of all provided pathspecs
      which is then used to prune the index of all entries which don't have
      that prefix.  Since submodules entries in the index don't have a
      trailing slash 'prune_cache()' will be overeager and prune a submodule
      'sub' if the common prefix is 'sub/'.  To correct this behavior, only
      prune entries which don't match up to, but not including, a trailing
      slash of the common prefix.
      
      This is in preparation to remove the
      PATHSPEC_STRIP_SUBMODULE_SLASH_CHEAP flag in a later patch.
      Signed-off-by: NBrandon Williams <bmwill@google.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      cbca060e
  6. 08 5月, 2017 2 次提交
  7. 06 5月, 2017 2 次提交
  8. 19 4月, 2017 1 次提交
    • J
      ls-files: fix path used when recursing into submodules · 2cfe66a8
      Jacob Keller 提交于
      Don't assume that the current working directory is the root of the
      repository. Correctly generate the path for the recursing child
      processes by building it from the work_tree() root instead. Otherwise if
      we run ls-files using --git-dir or --work-tree it will not work
      correctly as it attempts to change directory into a potentially invalid
      location. Best case, it doesn't exist and we produce an error. Worst
      case we cd into the wrong location and unknown behavior occurs.
      
      Add a new test which highlights this possibility.
      Signed-off-by: NJacob Keller <jacob.keller@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      2cfe66a8
  9. 18 4月, 2017 1 次提交
    • J
      ls-files: fix recurse-submodules with nested submodules · 2e5d6503
      Jacob Keller 提交于
      Since commit e77aa336 ("ls-files: optionally recurse into
      submodules", 2016-10-07) ls-files has known how to recurse into
      submodules when displaying files.
      
      Unfortunately this fails for certain cases, including when nesting more
      than one submodule, called from within a submodule that itself has
      submodules, or when the GIT_DIR environemnt variable is set.
      
      Prior to commit b58a68c1 ("setup: allow for prefix to be passed to
      git commands", 2017-03-17) this resulted in an error indicating that
      --prefix and --super-prefix were incompatible.
      
      After this commit, instead, the process loops forever with a GIT_DIR set
      to the parent and continuously reads the parent submodule files and
      recursing forever.
      
      Fix this by preparing the environment properly for submodules when
      setting up the child process. This is similar to how other commands such
      as grep behave.
      
      This was not caught by the original tests because the scenario is
      avoided if the submodules are created separately and not stored as the
      standard method of putting the submodule git directory under
      .git/modules/<name>. We can update the test to show the failure by the
      addition of "git submodule absorbgitdirs" to the test case. However,
      note that this new test would run forever without the necessary fix in
      this patch.
      Signed-off-by: NJacob Keller <jacob.keller@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      2e5d6503
  10. 18 3月, 2017 2 次提交
    • B
      ls-files: fix bug when recursing with relative pathspec · b2dfeb7c
      Brandon Williams 提交于
      When using the --recurse-submodules flag with a relative pathspec which
      includes "..", an error is produced inside the child process spawned for a
      submodule.  When creating the pathspec struct in the child, the ".." is
      interpreted to mean "go up a directory" which causes an error stating that the
      path ".." is outside of the repository.
      
      While it is true that ".." is outside the scope of the submodule, it is
      confusing to a user who originally invoked the command where ".." was indeed
      still inside the scope of the superproject.  Since the child process launched
      for the submodule has some context that it is operating underneath a
      superproject, this error could be avoided.
      
      This patch fixes the bug by passing the 'prefix' to the child process.  Now
      each child process that works on a submodule has two points of reference to the
      superproject: (1) the 'super_prefix' which is the path from the root of the
      superproject down to root of the submodule and (2) the 'prefix' which is the
      path from the root of the superproject down to the directory where the user
      invoked the git command.
      
      With these two pieces of information a child process can correctly interpret
      the pathspecs provided by the user as well as being able to properly format its
      output relative to the directory the user invoked the original command from.
      Signed-off-by: NBrandon Williams <bmwill@google.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b2dfeb7c
    • B
      ls-files: fix typo in variable name · e4770f67
      Brandon Williams 提交于
      Signed-off-by: NBrandon Williams <bmwill@google.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      e4770f67
  11. 14 2月, 2017 2 次提交
  12. 11 10月, 2016 3 次提交
  13. 08 9月, 2016 1 次提交
  14. 27 7月, 2016 1 次提交
  15. 02 2月, 2016 1 次提交
    • J
      apply, ls-files: simplify "-z" parsing · 1f3c79a9
      Jeff King 提交于
      As a short option, we cannot handle negation. Thus a callback
      handling "unset" is overkill, and we can just use OPT_SET_INT
      instead to handle setting the option.
      
      Anybody who adds "--nul" synonym to this later would need to be
      careful not to break "--no-nul", which should mean that lines are
      terminated with LF at the end.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      1f3c79a9
  16. 19 1月, 2016 1 次提交
    • T
      ls-files: add eol diagnostics · a7630bd4
      Torsten Bögershausen 提交于
      When working in a cross-platform environment, a user may want to
      check if text files are stored normalized in the repository and
      if .gitattributes are set appropriately.
      
      Make it possible to let Git show the line endings in the index and
      in the working tree and the effective text/eol attributes.
      
      The end of line ("eolinfo") are shown like this:
      
          "-text"        binary (or with bare CR) file
          "none"         text file without any EOL
          "lf"           text file with LF
          "crlf"         text file with CRLF
          "mixed"        text file with mixed line endings.
      
      The effective text/eol attribute is one of these:
      
          "", "-text", "text", "text=auto", "text eol=lf", "text eol=crlf"
      
      git ls-files --eol gives an output like this:
      
          i/none   w/none   attr/text=auto      t/t5100/empty
          i/-text  w/-text  attr/-text          t/test-binary-2.png
          i/lf     w/lf     attr/text eol=lf    t/t5100/rfc2047-info-0007
          i/lf     w/crlf   attr/text eol=crlf  doit.bat
          i/mixed  w/mixed  attr/               locale/XX.po
      
      to show what eol convention is used in the data in the index ('i'),
      and in the working tree ('w'), and what attribute is in effect,
      for each path that is shown.
      
      Add test cases in t0027.
      Helped-By: NEric Sunshine <sunshine@sunshineco.com>
      Signed-off-by: NTorsten Bögershausen <tboegi@web.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      a7630bd4
  17. 21 8月, 2015 1 次提交
  18. 25 3月, 2015 1 次提交
    • J
      report_path_error(): move to dir.c · 777c55a6
      Junio C Hamano 提交于
      The expected call sequence is for the caller to use match_pathspec()
      repeatedly on a set of pathspecs, accumulating the "hits" in a
      separate array, and then call this function to diagnose a pathspec
      that never matched anything, as that can indicate a typo from the
      command line, e.g. "git commit Maekfile".
      
      Many builtin commands use this function from builtin/ls-files.c,
      which is not a very healthy arrangement.  ls-files might have been
      the first command to feel the need for such a helper, but the need
      is shared by everybody who uses the "match and then report" pattern.
      
      Move it to dir.c where match_pathspec() is defined.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      777c55a6
  19. 15 1月, 2015 1 次提交
  20. 03 9月, 2014 1 次提交
  21. 25 2月, 2014 1 次提交
    • N
      pathspec: pass directory indicator to match_pathspec_item() · ae8d0824
      Nguyễn Thái Ngọc Duy 提交于
      This patch activates the DO_MATCH_DIRECTORY code in m_p_i(), which
      makes "git diff HEAD submodule/" and "git diff HEAD submodule" produce
      the same output. Previously only the version without trailing slash
      returns the difference (if any).
      
      That's the effect of new ce_path_match(). dir_path_match() is not
      executed by the new tests. And it should not introduce regressions.
      
      Previously if path "dir/" is passed in with pathspec "dir/", they
      obviously match. With new dir_path_match(), the path becomes
      _directory_ "dir" vs pathspec "dir/", which is not executed by the old
      code path in m_p_i(). The new code path is executed and produces the
      same result.
      
      The other case is pathspec "dir" and path "dir/" is now turned to
      "dir" (with DO_MATCH_DIRECTORY). Still the same result before or after
      the patch.
      
      So why change? Because of the next patch about clean.c.
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ae8d0824