Re: [PATCH v6 1/6] submodules: add helper functions to determine presence of submodules

2016-12-02 Thread Brandon Williams
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.

Re: [PATCH v6 1/6] submodules: add helper functions to determine presence of submodules

2016-12-02 Thread Jeff King
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.

Re: [PATCH v6 1/6] submodules: add helper functions to determine presence of submodules

2016-12-02 Thread Brandon Williams
On 12/02, Jacob Keller wrote: > On Fri, Dec 2, 2016 at 11:28 AM, Stefan Beller wrote: > > On Fri, Dec 2, 2016 at 11:20 AM, Jacob Keller > > wrote: > >>> > >>> So is there a reason why the library function realpath() can't be used? > >>> From a cursory

Re: [PATCH v6 1/6] submodules: add helper functions to determine presence of submodules

2016-12-02 Thread Jacob Keller
On Fri, Dec 2, 2016 at 11:28 AM, Stefan Beller wrote: > On Fri, Dec 2, 2016 at 11:20 AM, Jacob Keller wrote: >>> >>> So is there a reason why the library function realpath() can't be used? >>> From a cursory look at its man page it seems to do the

Re: [PATCH v6 1/6] submodules: add helper functions to determine presence of submodules

2016-12-02 Thread Stefan Beller
On Fri, Dec 2, 2016 at 11:20 AM, Jacob Keller wrote: >> >> So is there a reason why the library function realpath() can't be used? >> From a cursory look at its man page it seems to do the symlink >> resolution. >> >> -- >> Brandon Williams > > I believe it uses the same

Re: [PATCH v6 1/6] submodules: add helper functions to determine presence of submodules

2016-12-02 Thread Jacob Keller
On Fri, Dec 2, 2016 at 10:49 AM, Brandon Williams wrote: > On 12/02, Jacob Keller wrote: >> On Fri, Dec 2, 2016 at 10:36 AM, Brandon Williams wrote: >> > On 12/01, Jeff King wrote: >> >> On Thu, Dec 01, 2016 at 01:56:32PM -0800, Stefan Beller wrote: >> >> >>

Re: [PATCH v6 1/6] submodules: add helper functions to determine presence of submodules

2016-12-02 Thread Brandon Williams
On 12/02, Jacob Keller wrote: > On Fri, Dec 2, 2016 at 10:36 AM, Brandon Williams wrote: > > On 12/01, Jeff King wrote: > >> On Thu, Dec 01, 2016 at 01:56:32PM -0800, Stefan Beller wrote: > >> > >> > > Bleh. Looks like it happens as part of the recently-added > >> > >

Re: [PATCH v6 1/6] submodules: add helper functions to determine presence of submodules

2016-12-02 Thread Jacob Keller
On Fri, Dec 2, 2016 at 10:36 AM, Brandon Williams wrote: > On 12/01, Jeff King wrote: >> On Thu, Dec 01, 2016 at 01:56:32PM -0800, Stefan Beller wrote: >> >> > > Bleh. Looks like it happens as part of the recently-added >> > > get_common_dir(). I'm not sure if that is ever

Re: [PATCH v6 1/6] submodules: add helper functions to determine presence of submodules

2016-12-02 Thread Brandon Williams
On 12/01, Jeff King wrote: > On Thu, Dec 01, 2016 at 01:56:32PM -0800, Stefan Beller wrote: > > > > Bleh. Looks like it happens as part of the recently-added > > > get_common_dir(). I'm not sure if that is ever relevant for submodules, > > > but I guess in theory you could have a submodule clone

Re: [PATCH v6 1/6] submodules: add helper functions to determine presence of submodules

2016-12-01 Thread Jeff King
On Thu, Dec 01, 2016 at 01:56:32PM -0800, Stefan Beller wrote: > > Bleh. Looks like it happens as part of the recently-added > > get_common_dir(). I'm not sure if that is ever relevant for submodules, > > but I guess in theory you could have a submodule clone that is part of a > > worktree? > >

Re: [PATCH v6 1/6] submodules: add helper functions to determine presence of submodules

2016-12-01 Thread Stefan Beller
On Thu, Dec 1, 2016 at 12:59 PM, Jeff King wrote: > On Thu, Dec 01, 2016 at 12:54:44PM -0800, Brandon Williams wrote: > >> > I think this more robust check is probably a good idea, that way we >> > don't step into a submodule with a .git directory that isn't really a >> > .git dir.

Re: [PATCH v6 1/6] submodules: add helper functions to determine presence of submodules

2016-12-01 Thread Jeff King
On Thu, Dec 01, 2016 at 12:54:44PM -0800, Brandon Williams wrote: > > I think this more robust check is probably a good idea, that way we > > don't step into a submodule with a .git directory that isn't really a > > .git dir. > > Looks like this is a no-go as well...the call to

Re: [PATCH v6 1/6] submodules: add helper functions to determine presence of submodules

2016-12-01 Thread Brandon Williams
On 12/01, Brandon Williams wrote: > On 12/01, Jeff King wrote: > > On Thu, Dec 01, 2016 at 10:46:23AM -0800, Junio C Hamano wrote: > > > > > > mkpath() is generally an unsafe function because it uses a static > > > > buffer, but it's handy and safe for handing values to syscalls like > > > >

Re: [PATCH v6 1/6] submodules: add helper functions to determine presence of submodules

2016-12-01 Thread Brandon Williams
On 12/01, Jeff King wrote: > On Thu, Dec 01, 2016 at 10:46:23AM -0800, Junio C Hamano wrote: > > > > mkpath() is generally an unsafe function because it uses a static > > > buffer, but it's handy and safe for handing values to syscalls like > > > this. > > > > I think your "unsafe" is not about

Re: [PATCH v6 1/6] submodules: add helper functions to determine presence of submodules

2016-12-01 Thread Jeff King
On Thu, Dec 01, 2016 at 10:46:23AM -0800, Junio C Hamano wrote: > > mkpath() is generally an unsafe function because it uses a static > > buffer, but it's handy and safe for handing values to syscalls like > > this. > > I think your "unsafe" is not about thread-safety but about "the > caller

Re: [PATCH v6 1/6] submodules: add helper functions to determine presence of submodules

2016-12-01 Thread Junio C Hamano
Jeff King writes: > On Wed, Nov 30, 2016 at 05:28:29PM -0800, Brandon Williams wrote: > >> +/* >> + * Determine if a submodule has been populated at a given 'path' >> + */ >> +int is_submodule_populated(const char *path) >> +{ >> +int ret = 0; >> +struct stat st; >> +

Re: [PATCH v6 1/6] submodules: add helper functions to determine presence of submodules

2016-12-01 Thread Stefan Beller
On Wed, Nov 30, 2016 at 8:29 PM, Jeff King wrote: > On Wed, Nov 30, 2016 at 05:28:29PM -0800, Brandon Williams wrote: > >> +/* >> + * Determine if a submodule has been populated at a given 'path' >> + */ >> +int is_submodule_populated(const char *path) >> +{ >> + int ret = 0;

Re: [PATCH v6 1/6] submodules: add helper functions to determine presence of submodules

2016-11-30 Thread Jeff King
On Wed, Nov 30, 2016 at 05:28:29PM -0800, Brandon Williams wrote: > +/* > + * Determine if a submodule has been populated at a given 'path' > + */ > +int is_submodule_populated(const char *path) > +{ > + int ret = 0; > + struct stat st; > + char *gitdir = xstrfmt("%s/.git", path); > +

[PATCH v6 1/6] submodules: add helper functions to determine presence of submodules

2016-11-30 Thread Brandon Williams
Add two helper functions to submodules.c. `is_submodule_initialized()` checks if a submodule has been initialized at a given path and `is_submodule_populated()` check if a submodule has been checked out at a given path. Signed-off-by: Brandon Williams --- submodule.c | 39