From: Jeff King Date: Fri, 29 Apr 2011 18:52:28 GMT Subject: Re: [PATCH 2/2] merge-one-file: fix broken merges with GIT_WORK_TREE Message-ID: <20110429185228.GA27268@sigill.intra.peff.net> In-Reply-To: On Fri, Apr 29, 2011 at 07:19:09PM +0200, Martin von Zweigbergk wrote: > On Apr 29, 2011 12:41 AM, "Jeff King" wrote: > > > > - git checkout-index -f --stage=2 -- "$4" && cat "$src1" >"$4" > > + git checkout-index -f --stage=2 -- "$4" && > > + cat "$src1" >"${GIT_WORK_TREE:+$GIT_WORK_TREE/}$4" || > > + exit 1 > > Would "git rev-parse --show-toplevel" be better here? Does it work with > core.worktree etc otherwise? (Maybe git-sh-setup sets the env var?) Good catch. I believe the git wrapper will convert "git --work-tree" into an environment variable, but the config seems to be handled separately. and either way, I think we technically still support calling "git-merge-one-file" directly without the git wrapper. Thinking on it more, it probably makes more sense to "cd_to_toplevel" via git-sh-setup. It seems pretty clear to me the original script was written with the expectation of being at the top of the working tree (and that is certainly where it ends up when called via git-merge-octopus and git-merge-resolve). Let me extend the tests a bit and roll a new series. -Peff