1. 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
  2. 06 1月, 2009 1 次提交
  3. 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