1. 02 9月, 2015 2 次提交
  2. 02 12月, 2014 3 次提交
    • N
      git_path(): keep "info/sparse-checkout" per work-tree · 6cfbdcb2
      Nguyễn Thái Ngọc Duy 提交于
      Currently git_path("info/sparse-checkout") resolves to
      $GIT_COMMON_DIR/info/sparse-checkout in multiple worktree mode. It
      makes more sense for the sparse checkout patterns to be per worktree,
      so you can have multiple checkouts with different parts of the tree.
      
      With this, "git checkout --to <new>" on a sparse checkout will create
      <new> as a full checkout. Which is expected, it's how a new checkout
      is made. The user can reshape the worktree afterwards.
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      6cfbdcb2
    • N
      $GIT_COMMON_DIR: a new environment variable · c7b3a3d2
      Nguyễn Thái Ngọc Duy 提交于
      This variable is intended to support multiple working directories
      attached to a repository. Such a repository may have a main working
      directory, created by either "git init" or "git clone" and one or more
      linked working directories. These working directories and the main
      repository share the same repository directory.
      
      In linked working directories, $GIT_COMMON_DIR must be defined to point
      to the real repository directory and $GIT_DIR points to an unused
      subdirectory inside $GIT_COMMON_DIR. File locations inside the
      repository are reorganized from the linked worktree view point:
      
       - worktree-specific such as HEAD, logs/HEAD, index, other top-level
         refs and unrecognized files are from $GIT_DIR.
      
       - the rest like objects, refs, info, hooks, packed-refs, shallow...
         are from $GIT_COMMON_DIR (except info/sparse-checkout, but that's
         a separate patch)
      
      Scripts are supposed to retrieve paths in $GIT_DIR with "git rev-parse
      --git-path", which will take care of "$GIT_DIR vs $GIT_COMMON_DIR"
      business.
      
      The redirection is done by git_path(), git_pathdup() and
      strbuf_git_path(). The selected list of paths goes to $GIT_COMMON_DIR,
      not the other way around in case a developer adds a new
      worktree-specific file and it's accidentally promoted to be shared
      across repositories (this includes unknown files added by third party
      commands)
      
      The list of known files that belong to $GIT_DIR are:
      
      ADD_EDIT.patch BISECT_ANCESTORS_OK BISECT_EXPECTED_REV BISECT_LOG
      BISECT_NAMES CHERRY_PICK_HEAD COMMIT_MSG FETCH_HEAD HEAD MERGE_HEAD
      MERGE_MODE MERGE_RR NOTES_EDITMSG NOTES_MERGE_WORKTREE ORIG_HEAD
      REVERT_HEAD SQUASH_MSG TAG_EDITMSG fast_import_crash_* logs/HEAD
      next-index-* rebase-apply rebase-merge rsync-refs-* sequencer/*
      shallow_*
      
      Path mapping is NOT done for git_path_submodule(). Multi-checkouts are
      not supported as submodules.
      Helped-by: NJens Lehmann <Jens.Lehmann@web.de>
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c7b3a3d2
    • N
      git_path(): be aware of file relocation in $GIT_DIR · 557bd833
      Nguyễn Thái Ngọc Duy 提交于
      We allow the user to relocate certain paths out of $GIT_DIR via
      environment variables, e.g. GIT_OBJECT_DIRECTORY, GIT_INDEX_FILE and
      GIT_GRAFT_FILE. Callers are not supposed to use git_path() or
      git_pathdup() to get those paths. Instead they must use
      get_object_directory(), get_index_file() and get_graft_file()
      respectively. This is inconvenient and could be missed in review (for
      example, there's git_path("objects/info/alternates") somewhere in
      sha1_file.c).
      
      This patch makes git_path() and git_pathdup() understand those
      environment variables. So if you set GIT_OBJECT_DIRECTORY to /foo/bar,
      git_path("objects/abc") should return /foo/bar/abc. The same is done
      for the two remaining env variables.
      
      "git rev-parse --git-path" is the wrapper for script use.
      
      This patch kinda reverts a0279e18 (setup_git_env: use git_pathdup
      instead of xmalloc + sprintf - 2014-06-19) because using git_pathdup
      here would result in infinite recursion:
      
        setup_git_env() -> git_pathdup("objects") -> .. -> adjust_git_path()
        -> get_object_directory() -> oops, git_object_directory is NOT set
        yet -> setup_git_env()
      
      I wanted to make git_pathdup_literal() that skips adjust_git_path().
      But that won't work because later on when $GIT_COMMON_DIR is
      introduced, git_pathdup_literal("objects") needs adjust_git_path() to
      replace $GIT_DIR with $GIT_COMMON_DIR.
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      557bd833
  3. 05 2月, 2014 4 次提交
  4. 14 10月, 2013 3 次提交
  5. 27 6月, 2013 3 次提交
    • J
      test: run testcases with POSIX absolute paths on Windows · abd4284b
      Jiang Xin 提交于
      Some test cases are skipped on Windows by marking with POSIX prereq.
      This is because arguments look like absolute paths (such as /a/b)
      for regular Windows programs (*.exe executables, no bash scripts)
      are changed to Windows paths (like C:/msysgit/a/b).
      
      There is no cygpath nor equivalent on msysGit, but it is easy to
      write one. New subcommand "mingw_path" is added in test-path-utils,
      so that we can get the expected absolute paths on Windows. E.g.
      
          COMMAND LINE                        Linux output  Windows output
          ==================================  ============  ===============
          test-path-utils mingw_path /        /             C:/msysgit
          test-path-utils mingw_path /a/b/    /a/b/         C:/msysgit/a/b/
      
      With this utility, most skipped test cases in t0060 can be turned on
      to be tested correctly on Windows.
      Signed-off-by: NJiang Xin <worldhello.net@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      abd4284b
    • J
      path.c: refactor relative_path(), not only strip prefix · e02ca72f
      Jiang Xin 提交于
      Original design of relative_path() is simple, just strip the prefix
      (*base) from the absolute path (*abs).
      
      In most cases, we need a real relative path, such as: ../foo,
      ../../bar.  That's why there is another reimplementation
      (path_relative()) in quote.c.
      
      Borrow some codes from path_relative() in quote.c to refactor
      relative_path() in path.c, so that it could return real relative
      path, and user can reuse this function without reimplementing
      his/her own.  The function path_relative() in quote.c will be
      substituted, and I would use the new relative_path() function when
      implementing the interactive git-clean later.
      
      Different results for relative_path() before and after this refactor:
      
          abs path  base path  relative (original)  relative (refactor)
          ========  =========  ===================  ===================
          /a/b      /a/b       .                    ./
          /a/b/     /a/b       .                    ./
          /a        /a/b/      /a                   ../
          /         /a/b/      /                    ../../
          /a/c      /a/b/      /a/c                 ../c
          /x/y      /a/b/      /x/y                 ../../x/y
      
          a/b/      a/b/       .                    ./
          a/b/      a/b        .                    ./
          a         a/b        a                    ../
          x/y       a/b/       x/y                  ../../x/y
          a/c       a/b        a/c                  ../c
      
          (empty)   (null)     (empty)              ./
          (empty)   (empty)    (empty)              ./
          (empty)   /a/b       (empty)              ./
          (null)    (null)     (null)               ./
          (null)    (empty)    (null)               ./
          (null)    /a/b       (segfault)           ./
      
      You may notice that return value "." has been changed to "./".
      It is because:
      
       * Function quote_path_relative() in quote.c will show the relative
         path as "./" if abs(in) and base(prefix) are the same.
      
       * Function relative_path() is called only once (in setup.c), and
         it will be OK for the return value as "./" instead of ".".
      Signed-off-by: NJiang Xin <worldhello.net@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      e02ca72f
    • J
      test: add test cases for relative_path · 203439b2
      Jiang Xin 提交于
      Add subcommand "relative_path" in test-path-utils, and add test cases
      in t0060.
      
      Johannes tested an earlier version of this patch on Windows, and
      found that some relative_path tests should be skipped on
      Windows. This is because the bash on Windows rewrites arguments of
      regular Windows programs, such as git and the test helpers, if the
      arguments look like absolute POSIX paths. As a consequence, the
      actual tests performed are not what the tests scripts expect.
      
      The tests that need *not* be skipped are those where the two paths passed
      to 'test-path-utils relative_path' have the same prefix and the result is
      expected to be a relative path. This is because the rewriting changes
      "/a/b" to "D:/Src/MSysGit/a/b", and when both inputs are extended the same
      way, this just cancels out in the relative path computation.
      Signed-off-by: NJiang Xin <worldhello.net@gmail.com>
      Helped-by: NJohannes Sixt <j6t@kdbg.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      203439b2
  6. 29 10月, 2012 1 次提交
    • M
      longest_ancestor_length(): require prefix list entries to be normalized · 9e2326c7
      Michael Haggerty 提交于
      Move the responsibility for normalizing prefixes from
      longest_ancestor_length() to its callers. Use slightly different
      normalizations at the two callers:
      
      In setup_git_directory_gently_1(), use the old normalization, which
      ignores paths that are not usable.  In the next commit we will change
      this caller to also resolve symlinks in the paths from
      GIT_CEILING_DIRECTORIES as part of the normalization.
      
      In "test-path-utils longest_ancestor_length", use the old
      normalization, but die() if any paths are unusable.  Also change t0060
      to only pass normalized paths to the test program (no empty entries or
      non-absolute paths, strip trailing slashes from the paths, and remove
      tests that thereby become redundant).
      
      The point of this change is to reduce the scope of the ancestor_length
      tests in t0060 from testing normalization+longest_prefix to testing
      only mostly longest_prefix.  This is necessary because when
      setup_git_directory_gently_1() starts resolving symlinks as part of
      its normalization, it will not be reasonable to do the same in the
      test suite, because that would make the test results depend on the
      contents of the root directory of the filesystem on which the test is
      run.  HOWEVER: under Windows, bash mangles arguments that look like
      absolute POSIX paths into DOS paths.  So we have to retain the level
      of normalization done by normalize_path_copy() to convert the
      bash-mangled DOS paths (which contain backslashes) into paths that use
      forward slashes.
      Signed-off-by: NMichael Haggerty <mhagger@alum.mit.edu>
      Signed-off-by: NJeff King <peff@peff.net>
      9e2326c7
  7. 11 9月, 2012 1 次提交
  8. 07 9月, 2012 8 次提交
  9. 23 3月, 2009 2 次提交
    • J
      t0060: fix whitespace in "wc -c" invocation · 28baf82e
      Jeff King 提交于
      Some platforms like to stick extra whitespace in the output
      of "wc -c"; using the result without quotes gets the shell
      to collapse the whitespace.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      28baf82e
    • J
      t0060: Fix tests on Windows · 2718e852
      Johannes Sixt 提交于
      Since the MSYS bash mangles absolute paths that it passes as command line
      arguments to non-MSYS progams (such as git or test-path-utils), we have to
      bend over backwards to squeeze some usefulness out of the existing tests.
      
      In particular, a set of path normalization tests is added that test
      relative paths. Some paths in the ancestor path tests are adjusted to help
      MSYS bash's path mangling heuristics.
      Signed-off-by: NJohannes Sixt <j6t@kdbg.org>
      2718e852
  10. 20 2月, 2009 1 次提交
  11. 08 2月, 2009 1 次提交
    • J
      Test and fix normalize_path_copy() · f42302b4
      Johannes Sixt 提交于
      This changes the test-path-utils utility to invoke normalize_path_copy()
      instead of normalize_absolute_path() because the latter is about to be
      removed.
      
      The test cases in t0060 are adjusted in two regards:
      
      - normalize_path_copy() more often leaves a trailing slash in the result.
        This has no negative side effects because the new user of this function,
        longest_ancester_length(), already accounts for this behavior.
      
      - The function can fail.
      
      The tests uncover a flaw in normalize_path_copy(): If there are
      sufficiently many '..' path components so that the root is reached, such as
      in "/d1/s1/../../d2", then the leading slash was lost. This manifested
      itself that (assuming there is a repository at /tmp/foo)
      
        $ git add /d1/../tmp/foo/some-file
      
      reported 'pathspec is outside repository'. This is now fixed.
      
      Moreover, the test case descriptions of t0060 now include the test data and
      expected outcome.
      Signed-off-by: NJohannes Sixt <j6t@kdbg.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      f42302b4
  12. 24 5月, 2008 2 次提交