From: Jeff King Date: Wed, 04 May 2011 08:50:14 GMT Subject: Re: [RFC] require-work-tree wants more than what its name says Message-ID: <20110504085014.GA9739@sigill.intra.peff.net> In-Reply-To: <4DC112A1.5090805@drmicha.warpmail.net> On Wed, May 04, 2011 at 10:47:29AM +0200, Michael J Gruber wrote: > The only thing I can imagine doing right now is changing > require_work_tree() to actually cd to toplevel when possible, so that > (like before) on success we're really within. But that changes cwd, of > course. In summary, a require_work_tree() now can have three assumptions > when it returns with success: > > - we have a worktree > - we are within worktree > - cwd has not changed > > I'd rather break the last one than the second one, but breaking any may > be a problem, depending on the caller. Check out some of the older scripts in contrib/examples. Several of them require_work_tree, but do not cd_to_toplevel immediately; instead, they do it much later for some specific bits. I didn't go through and analyze what would happen in each case if we did the cd_to_toplevel first. I suspect some of it would be pretty mild breakage (like "git commit -F foo" not finding "foo"). But it would be breakage nonetheless. -Peff