Re: [PATCH 2/4] add chdir-notify API

2018-03-29 Thread Duy Nguyen
On Thu, Mar 29, 2018 at 7:48 PM, Jeff King wrote: > On Thu, Mar 29, 2018 at 04:53:42PM +0200, Duy Nguyen wrote: > >> On Wed, Mar 28, 2018 at 7:40 PM, Jeff King wrote: >> > +static void reparent_cb(const char *old_cwd, >> > + const char *new_cwd, >> > +

Re: [PATCH 2/4] add chdir-notify API

2018-03-29 Thread Jeff King
On Thu, Mar 29, 2018 at 04:53:42PM +0200, Duy Nguyen wrote: > On Wed, Mar 28, 2018 at 7:40 PM, Jeff King wrote: > > +static void reparent_cb(const char *old_cwd, > > + const char *new_cwd, > > + void *data) > > +{ > > + char **path = data; > > Ma

Re: [PATCH 2/4] add chdir-notify API

2018-03-29 Thread Duy Nguyen
On Wed, Mar 28, 2018 at 7:40 PM, Jeff King wrote: > +static void reparent_cb(const char *old_cwd, > + const char *new_cwd, > + void *data) > +{ > + char **path = data; Maybe check data == NULL and return early. This is just for convenience, e.g. i

Re: [PATCH 2/4] add chdir-notify API

2018-03-28 Thread Jeff King
On Wed, Mar 28, 2018 at 01:58:18PM -0400, Eric Sunshine wrote: > On Wed, Mar 28, 2018 at 1:40 PM, Jeff King wrote: > > [...] > > Let's provide an API to let code that stores relative paths > > "subscribe" to updates to the current working directory. > > This means that callers of chdir() don't ne

Re: [PATCH 2/4] add chdir-notify API

2018-03-28 Thread Eric Sunshine
On Wed, Mar 28, 2018 at 1:40 PM, Jeff King wrote: > [...] > Let's provide an API to let code that stores relative paths > "subscribe" to updates to the current working directory. > This means that callers of chdir() don't need to know about > all subscribers ahead of time; they can simply consult

[PATCH 2/4] add chdir-notify API

2018-03-28 Thread Jeff King
If one part of the code does a permanent chdir(), then this invalidates any relative paths that may be held by other parts of the code. For example, setup_work_tree() moves us to the top of the working tree, which may invalidate a previously stored relative gitdir. We've hacked around this case by