[PATCH 1/3] strbuf: add strbuf_add_cwd()

2014-07-20 Thread René Scharfe
Add strbuf_add_cwd(), which adds the current working directory to a strbuf. Because it doesn't use a fixed-size buffer it supports arbitrarily long paths, as long as the platform's getcwd() does as well. At least on Linux and FreeBSD it handles paths longer than PATH_MAX just fine.

Re: [PATCH 1/3] strbuf: add strbuf_add_cwd()

2014-07-20 Thread Duy Nguyen
On Sun, Jul 20, 2014 at 6:21 PM, René Scharfe l@web.de wrote: +int strbuf_add_cwd(struct strbuf *sb) +{ + size_t oldalloc = sb-alloc; + size_t guessed_len = 32; For Linux, I think this is enough to succesfully get cwd in the first pass. Windows' $HOME is usually deep in

Re: [PATCH 1/3] strbuf: add strbuf_add_cwd()

2014-07-20 Thread René Scharfe
Am 20.07.2014 14:33, schrieb Duy Nguyen: On Sun, Jul 20, 2014 at 6:21 PM, René Scharfe l@web.de wrote: +int strbuf_add_cwd(struct strbuf *sb) +{ + size_t oldalloc = sb-alloc; + size_t guessed_len = 32; For Linux, I think this is enough to succesfully get cwd in the first pass.