Re: [PATCH v6 1/6] submodules: add helper functions to determine presence of submodules
- From
Jeff King <peff@peff.net>
- Date
- Dec 2, 2016, 21:45 UTC
- Message-ID
- <20161202214529.mjekdaixrdoyroxq@sigill.intra.peff.net>
- In-Reply-To
- <CAGZ79kYPpc0=NAJaNPW+8faszOPAkq=b3m-EopY5A8oFwh+9=g@mail.gmail.com>
On Fri, Dec 02, 2016 at 11:28:49AM -0800, Stefan Beller wrote:
> I just reviewed 2 libc implementations (glibc and an Android libc) and > both of them > do not use chdir internally, but use readlink and compose the path 'manually' > c.f. http://osxr.org:8080/glibc/source/stdlib/canonicalize.c?v=glibc-2.13
Interesting. It might be worth updating our implementation. The original comes all the way from 54f4b8745 (Library code for user-relative paths, take three., 2005-11-17). That references a suggestion which I think comes from:
http://public-inbox.org/git/Pine.LNX.4.64.0510181728490.3369@g5.osdl.org/
where it's claimed to be simpler and more efficient (which sounds plausible to me). But back then it was _just_ git-daemon doing a canonicalization, and nobody cared about things like thread safety.
Looking at the glibc implementation, it's really not that bad. We _could_ even rely on the system realpath() and just provide our own fallback for systems without it, but I think ours might be a little more featureful (at the very least, it handles arbitrary-sized paths via strbufs).
-Peff