1. 23 6月, 2016 1 次提交
    • J
      t2300: "git --exec-path" is not usable in $PATH on Windows as-is · 412b9a16
      Johannes Schindelin 提交于
      The "git" command prepends the exec-path to the PATH environment
      variable for processes it spawns.  That is how ". git-sh-setup" in
      our scripted Porcelains can find the dot-sourced file in the
      exec-path location that is not usually on user's PATH.
      
      When t2300 runs, because it is not spawned by the "git" command, the
      scriptlet being tested did not run with a realistic setting of PATH
      environment.  It lacked the exec-path on the PATH, and failed to
      find the dot-sourced file.  A recent update to t2300 attempted to
      fix this, with "PATH=$(git --exec-path):$PATH", which has been the
      recommended way around v1.6.0 days (a script whose original was
      written before that release that survives to this day is likely to
      have such a line).
      
      However, the "git --exec-path" command outputs C:\path\to\exec\dir
      (not /c/path/to/exec/dir) on Windows; the recent update failed to
      consider the problem that comes from it.
      
      Even though Git itself, when doing the equivalent internally, does
      so in a platform native way (i.e. on Windows, C:\path\to\exec\dir is
      prepended to the existing value of %PATH% using ';' as a component
      separator), the result is further massaged by bash and gets turned
      into $PATH that uses /c/path/to/exec/dir with ':' separating the
      components, which is the form understood by bash, so scripted
      Porcelains find commands from PATH correctly.
      
      An end user script written in shell, however, cannot prepend
      "C:\path\to\exec\dir:" to the existing value of $PATH and expect
      bash to magically turn it into the form it understands.  In other
      words, "PATH=$(git --exec-path):$PATH" does not work as an emulation
      of what "Git" internally does to the PATH on Windows.
      
      To correctly emulate how exec-path is prepended to the PATH
      environment internally on Windows, we'd need to convert
      C:\git-sdk-64\usr\src\git to at least /c\git-sdk-64\usr\src\git
      ourselves before prepending it to PATH.
      Signed-off-by: NJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      412b9a16
  2. 02 6月, 2016 1 次提交
    • J
      t2300: run git-sh-setup in an environment that better mimics the real life · fe17fc00
      Junio C Hamano 提交于
      When we run scripted Porcelains, "git" potty has set up the $PATH by
      prepending $GIT_EXEC_PATH, the path given by "git --exec-path=$there
      $cmd", etc. already.  Because of this, scripted Porcelains can
      dot-source shell script library like git-sh-setup with simple dot
      without specifying any path.
      
      t2300 however dot-sources git-sh-setup without adjusting $PATH like
      the real "git" potty does.  This has not been a problem so far, but
      once git-sh-setup wants to rely on the $PATH adjustment, just like
      any scripted Porcelains already do, it would become one.  It cannot
      for example dot-source another shell library without specifying the
      full path to it by prefixing $(git --exec-path).
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      fe17fc00
  3. 30 11月, 2009 1 次提交
  4. 23 3月, 2009 1 次提交
    • J
      Use prerequisite tags to skip tests that depend on symbolic links · 704a3143
      Johannes Sixt 提交于
      Many tests depend on that symbolic links work.  This introduces a check
      that sets the prerequisite tag SYMLINKS if the file system supports
      symbolic links.  Since so many tests have to check for this prerequisite,
      we do the check in test-lib.sh, so that we don't need to repeat the test
      in many scripts.
      
      To check for 'ln -s' failures, you can use a FAT partition on Linux:
      
      $ mkdosfs -C git-on-fat 1000000
      $ sudo mount -o loop,uid=j6t,gid=users,shortname=winnt git-on-fat /mnt
      
      Clone git to /mnt and
      
      $ GIT_SKIP_TESTS='t0001.1[34] t0010 t1301 t403[34] t4129.[47] t5701.7
                t7701.3 t9100 t9101.26 t9119 t9124.[67] t9200.10 t9600.6' \
              make test
      
      (These additionally skipped tests depend on POSIX permissions that FAT on
      Linux does not provide.)
      Signed-off-by: NJohannes Sixt <j6t@kdbg.org>
      704a3143
  5. 07 2月, 2009 1 次提交
    • M
      git-sh-setup: Use "cd" option, not /bin/pwd, for symlinked work tree · 2c3c395e
      Marcel M. Cary 提交于
      In cd_to_toplevel, instead of 'cd $(unset PWD; /bin/pwd)/$path'
      use 'cd -P $path'.  The "-P" option yields a desirable similarity to
      C chdir.
      
      While the "-P" option may be slightly less commonly supported than
      /bin/pwd, it is more concise, better tested, and less error prone.
      I've already added the 'unset PWD' to fix the /bin/pwd solution on
      BSD; there may be more edge cases out there.
      
      This still passes all the same test cases in t5521-pull-symlink.sh and
      t2300-cd-to-toplevel.sh, even before updating them to use 'pwd -P'.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      2c3c395e
  6. 06 1月, 2009 1 次提交
  7. 21 12月, 2008 1 次提交
    • M
      git-sh-setup: Fix scripts whose PWD is a symlink into a git work-dir · 08fc0608
      Marcel M. Cary 提交于
      I want directories of my working tree to be linked to from various
      paths on my filesystem where third-party components expect them, both
      in development and production environments.  A build system's install
      step could solve this, but I develop scripts and web pages that don't
      need to be built.  Git's submodule system could solve this, but we
      tend to develop, branch, and test those directories all in unison, so
      one big repository feels more natural.  We prefer to edit and commit
      on the symlinked paths, not the canonical ones, and in that setting,
      "git pull" fails to find the top-level directory of the repository
      while other commands work fine.
      
      "git pull" fails because POSIX shells have a notion of current working
      directory that is different from getcwd().  The shell stores this path
      in PWD.  As a result, "cd ../" can be interpreted differently in a
      shell script than chdir("../") in a C program.  The shell interprets
      "../" by essentially stripping the last textual path component from
      PWD, whereas C chdir() follows the ".." link in the current directory
      on the filesystem.  When PWD is a symlink, these are different
      destinations.  As a result, Git's C commands find the correct
      top-level working tree, and shell scripts do not.
      
      Changes:
      
      * When interpreting a relative upward (../) path in cd_to_toplevel,
        prepend the cwd without symlinks, given by /bin/pwd
      * Add tests for cd_to_toplevel and "git pull" in a symlinked
        directory that failed before this fix, plus contrasting scenarios
        that already worked
      Signed-off-by: NMarcel M. Cary <marcel@oak.homeunix.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      08fc0608