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

Re: [PATCH] rev-parse: Fix shell scripts whose cwd is a symlink into a git work-dir

From
Marcel M. Cary <marcel@oak.homeunix.org>
Date
Nov 25, 2008, 05:54 UTC
Message-ID
<492B9321.8090706@oak.homeunix.org>
In-Reply-To
<49290203.7060808@op5.se>
> AFAIR, it was introduced to make test-builds of really large projects in
> really deep directories with a ton of symlinks leading to the path work a
> lot faster.
Andreas,

I see value in keeping Git very fast. That is, after all, why I chose Git over Mercurial. Do you know where that discussion was, if was in the archives? I found these reasons to avoid absolute paths in the git archives:

* paths with more components are slower to work with (in the context of
  add and diff, which deal with many many paths)
* absolute paths may exceed PATH_MAX while relative ones didn't
* getcwd() will fail if parent directories are not executable, or on
  some platforms, if parent directories are not readable

My impression is that the performance issue is probably not significant for cd_to_toplevel since it's not in a tight inner loop, and dito for other potential callers of --show-cdup. The PATH_MAX seems to be a restriction elsewhere in the code already.

Even if there were a scenario that put --show-cdup in a tight loop, I wonder whether current implementation provides much performance benefit, at least when bash is the calling language: bash seems to make the relative path absolute anyway inside the "cd" builtin.

The commit (5f94c730) that introduces that code doesn't mention performance. It compares to:

  git rev-parse --show-prefix | sed -e 's|[^/][^/]*|..|g'

I also noticed that this failure case with "--show-cdup" in a symlinked directory has come up more than once before. http://marc.info/?l=git&m=122452534912000&w=2 http://marc.info/?l=git&m=121613416212958&w=2 https://kerneltrap.org/mailarchive/git/2007/4/25/244653/thread

Marcel
Previous: Andreas EricssonNext: Andreas Ericsson
Message 7 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.