Subject: Re: [PATCH 1/3] After chdir to run grep, return to old directory

From: David Turner <[email-masked]>
Date: Wed, 07 May 2014 13:57:19 -0700

On Wed, 2014-05-07 at 10:42 -0700, Junio C Hamano wrote:
> David Turner <[email-masked]> writes:
> 
> > This causes my test to pass and generally seems correct to me.
> 
> Yes, this approach is very sensible, and I'll queue.
> 
> But watchman support _should_ be prepared for a program that does
> not do this.  Developing your support in on a codebase with this
> patch may be sweeping a bug in your code under the rug.

I agree that good defensive coding practice would be to not depend on
the cwd.  That's just what everything in environment.c presently does.
I don't want to change the rest of the get_*_file functions, because I
don't know what their callers expect of them.  Here is my patch to do
change just the fs_cache bit:

https://github.com/dturner-tw/git/commit/3fe93aeaee9719ee171a253c49af5126a057c513.patch

(I went ahead and made it part of 
the watchman branch on https://github.com/dturner-tw/git.git )

I wanted to just do the fixup where the path is used, but I couldn't see
a function for that.  If there's no function, that indicates to me that
it's probably a bad idea.  But maybe I'm just missing it.