git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC PATCH] git-sh-setup: Use "cd" option, not /bin/pwd, for symlinked work tree

From
Marcel M. Cary <marcel@oak.homeunix.org>
Date
Feb 8, 2009, 18:11 UTC
Message-ID
<498F2049.9030608@oak.homeunix.org>
In-Reply-To
<alpine.DEB.1.00.0902071324230.10279@pacific.mpi-cbg.de>
Johannes Schindelin wrote:
Show 6 quoted lines
> On Fri, 6 Feb 2009, Marcel M. Cary wrote:
>> While the "-P" option may be slightly less commonly supported than
>> /bin/pwd,
>
> Does this not suggest that your patch should at least fall back to
> using /bin/pwd when it was detected that "cd -P" does not work?

Having the "cd -P" strategy fall back to /bin/pwd negates most of the value I saw in using the simpler strategy.

I haven't found cases where "cd -P" is more correct. Are there other reasons to bother with "cd -P" at all? Maybe performance: "cd -P" would save a fork, which seems to make it ~10x faster. Dropping buffer caches doesn't seem to widen or narrow the gap, so I don't think the filesystem access is much different, performance-wise. But I don't expect this "cd" to be a performance bottleneck; most scripts that do something repetitive can just start off in the work tree root to avoid the issue.

Falling back to /bin/pwd would help compatibility if it were easy to detect when "cd -P" failed. But since its failure is hypothetical for me at this point -- I don't know of an environment where it fails -- I'm not sure whether to expect it to fail with non-zero exit status or by silently ignoring the "-P". And to handle the cases of silently ignoring the "-P" I'd guess cd_to_toplevel would have to run /bin/pwd just to check that it ended up in the right place, which seems counterproductive to me. Do you think it would be reasonable to just assume "cd -P" will exit non-zero if "cd" doesn't understand "-P", send its stderr to /dev/null, and try again using /bin/pwd?

Marcel
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 24 of 27 in “fixing git pull from symlinked directory”
  1. 0/2 fixing git pull from symlinked directoryMarcel M. Cary, Nov 15, 2008
  2. 1/2 Add failing test for "git pull" in symlinked directoryMarcel M. Cary, Nov 15, 2008
  3. 2/2 Support shell scripts that run from symlinks into a git working dirMarcel M. Cary, Nov 15, 2008
  4. rev-parse: Fix shell scripts whose cwd is a symlink into a git work-dirMarcel M. Cary, Nov 22, 2008
  5. Jakub NarebskiNov 22, 2008
  6. Andreas EricssonNov 23, 2008
  7. Marcel M. CaryNov 25, 2008
  8. Andreas EricssonNov 25, 2008
  9. Marcel M. CaryNov 25, 2008
  10. Johannes SixtNov 25, 2008
  11. Marcel M. CaryNov 25, 2008
  12. Johannes SixtNov 25, 2008
  13. Junio C HamanoNov 25, 2008
  14. git-sh-setup: Fix scripts whose PWD is a symlink into a git work-dirMarcel M. Cary, Dec 3, 2008
  15. Junio C HamanoDec 3, 2008
  16. git-sh-setup: Fix scripts whose PWD is a symlink into a git work-dirMarcel M. Cary, Dec 10, 2008
  17. Junio C HamanoDec 10, 2008
  18. git-sh-setup: Fix scripts whose PWD is a symlink into a git work-dirMarcel M. Cary, Dec 13, 2008
  19. Junio C HamanoDec 14, 2008
  20. git-sh-setup: Fix scripts whose PWD is a symlink into a git work-dirMarcel M. Cary, Dec 15, 2008
  21. Marcel M. CaryDec 15, 2008
  22. git-sh-setup: Use "cd" option, not /bin/pwd, for symlinked work treeMarcel M. Cary, Feb 7, 2009
  23. Johannes SchindelinFeb 7, 2009
  24. Marcel M. CaryFeb 8, 2009
  25. Johannes SchindelinFeb 8, 2009
  26. Marcel M. CaryFeb 11, 2009
  27. Jeff KingFeb 11, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.