On 12/02, Jeff King wrote: > 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@xxxxxxxxxxx/ > > 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). I've actually been working on updating our implementation of realpath today. Its slow going but we'll see if it works when i'm done :) Also we can just drop in realpath since it requires that all path components are valid, while ours allows for the final component to be invalid. -- Brandon Williams