1. 22 5月, 2018 1 次提交
  2. 06 7月, 2017 1 次提交
    • T
      cygwin: allow pushing to UNC paths · 496f2569
      Torsten Bögershausen 提交于
       cygwin can use an UNC path like //server/share/repo
      
       $ cd //server/share/dir
       $ mkdir test
       $ cd test
       $ git init --bare
      
       However, when we try to push from a local Git repository to this repo,
       there is a problem: Git converts the leading "//" into a single "/".
      
       As cygwin handles an UNC path so well, Git can support them better:
      
       - Introduce cygwin_offset_1st_component() which keeps the leading "//",
         similar to what Git for Windows does.
      
       - Move CYGWIN out of the POSIX in the tests for path normalization in t0060
      Signed-off-by: NTorsten Bögershausen <tboegi@web.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      496f2569
  3. 26 10月, 2016 1 次提交
    • J
      t0060: sidestep surprising path mangling results on Windows · 77b63ac3
      Johannes Sixt 提交于
      When an MSYS program (such as the bash that drives the test suite)
      invokes git on Windows, absolute Unix style paths are transformed into
      Windows native absolute paths (drive letter form). However, this
      transformation also includes some simplifications that are not just
      straight-forward textual substitutions:
      
      - When the path ends in "/.", then the dot is stripped, but not the
        directory separator.
      
      - When the path contains "..", then it is optimized away if possible,
        e.g., "/c/dir/foo/../bar" becomes "c:/dir/bar".
      
      These additional transformations violate the assumptions of some
      submodule path tests. We can avoid them when the input is already a
      Windows native path, because then MSYS leaves the path unmolested.
      
      Convert the uses of $PWD to $(pwd); the latter returns a native Windows
      path.
      Signed-off-by: NJohannes Sixt <j6t@kdbg.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      77b63ac3
  4. 11 10月, 2016 2 次提交
  5. 17 4月, 2016 1 次提交
    • S
      submodule: port resolve_relative_url from shell to C · 63e95beb
      Stefan Beller 提交于
      Later on we want to automatically call `git submodule init` from
      other commands, such that the users don't have to initialize the
      submodule themselves.  As these other commands are written in C
      already, we'd need the init functionality in C, too.  The
      `resolve_relative_url` function is a large part of that init
      functionality, so start by porting this function to C.
      
      To create the tests in t0060, the function `resolve_relative_url`
      was temporarily enhanced to write all inputs and output to disk
      when running the test suite. The added tests in this patch are
      a small selection thereof.
      Signed-off-by: NStefan Beller <sbeller@google.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      63e95beb
  6. 28 1月, 2016 1 次提交
    • J
      mingw: accomodate t0060-path-utils for MSYS2 · fc56c7b3
      Johannes Schindelin 提交于
      On Windows, there are no POSIX paths, only Windows ones (an absolute
      Windows path looks like "C:\Program Files\Git\ReleaseNotes.html", under
      most circumstances, forward slashes are also allowed and synonymous to
      backslashes).
      
      So when a POSIX shell (such as MSYS2's Bash, which is used by Git for
      Windows to execute all those shell scripts that are part of Git) passes
      a POSIX path to test-path-utils.exe (which is not POSIX-aware), the path
      is translated into a Windows path. For example, /etc/profile becomes
      C:/Program Files/Git/etc/profile.
      
      This path translation poses a problem when passing the root directory as
      parameter to test-path-utils.exe, as it is not well defined whether the
      translated root directory should end in a slash or not. MSys1 stripped
      the trailing slash, but MSYS2 does not.
      
      Originally, the Git for Windows project patched MSYS2's runtime to
      accomodate Git's regression test, but we really should do it the other
      way round.
      
      To work with both of MSys1's and MSYS2's behaviors, we simply test what
      the current system does in the beginning of t0060-path-utils.sh and then
      adjust the expected longest ancestor length accordingly.
      
      It looks quite a bit tricky what we actually do in this patch: first, we
      adjust the expected length for the trailing slash we did not originally
      expect (subtracting one). So far, so good.
      
      But now comes the part where things work in a surprising way: when the
      expected length was 0, the prefix to match is the root directory. If the
      root directory is converted into a path with a trailing slash, however,
      we know that the logic in longest_ancestor_length() cannot match: to
      avoid partial matches of the last directory component, it verifies that
      the character after the matching prefix is a slash (but because the
      slash was part of the matching prefix, the next character cannot be a
      slash). So the return value is -1. Alas, this is exactly what the
      expected length is after subtracting the value of $rootslash! So we skip
      adding the $rootoff value in that case (and only in that case).
      
      Directories other than the root directory are handled fine (as they are
      specified without a trailing slash, something not possible for the root
      directory, and MSYS2 converts them into Windows paths that also lack
      trailing slashes), therefore we do not need any more special handling.
      
      Thanks to Ray Donnelly for his patient help with this issue.
      Signed-off-by: NJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      fc56c7b3
  7. 13 1月, 2016 1 次提交
  8. 02 9月, 2015 2 次提交
  9. 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
  10. 05 2月, 2014 4 次提交
  11. 14 10月, 2013 3 次提交
  12. 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
  13. 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
  14. 11 9月, 2012 1 次提交
  15. 07 9月, 2012 8 次提交
  16. 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
  17. 20 2月, 2009 1 次提交
  18. 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
  19. 24 5月, 2008 2 次提交