git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/2] merge-one-file: fix broken merges with GIT_WORK_TREE

From
Jeff King <peff@peff.net>
Date
Apr 29, 2011, 18:52 UTC
Message-ID
<20110429185228.GA27268@sigill.intra.peff.net>
In-Reply-To
<BANLkTimoehqY9ViF7AkQC3YU8e4Sq-OT_w@mail.gmail.com>
On Fri, Apr 29, 2011 at 07:19:09PM +0200, Martin von Zweigbergk wrote:
Show 9 quoted lines
> On Apr 29, 2011 12:41 AM, "Jeff King" <peff@peff.net> 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
Next: Jeff King
Message 1 of 5 in “Re: [PATCH 2/2] merge-one-file: fix broken merges with GIT_WORK_TREE”
  1. Jeff KingApr 29, 2011
  2. 1/2 add tests for merge-index / merge-one-fileJeff King, Apr 29, 2011
  3. 2/2 merge-one-file: fix broken merges with alternate work treesJeff King, Apr 29, 2011
  4. Junio C HamanoApr 29, 2011
  5. Jeff KingApr 29, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.