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

Re: [PATCH] sequencer.c: set GIT_WORK_TREE in run_git_checkout

From
Glen Choo <chooglen@google.com>
Date
Jan 25, 2022, 23:39 UTC
Message-ID
<kl6lfspb1j23.fsf@chooglen-macbookpro.roam.corp.google.com>
In-Reply-To
<20220125233612.46831-1-chooglen@google.com>
Glen Choo <chooglen@google.com> writes:
Show 30 quoted lines
> When rebasing in a subdirectory of a worktree, Git fails due to a dirty
> worktree:
>
>   error: The following untracked working tree files would be overwritten
> by merge:
>           a/b/c
>   Please move or remove them before you merge.
>
> This occurs because "git rebase" invokes a "git checkout" without
> propagating the GIT_WORK_TREE environment variable, causing the worktree
> to be assumed to be ".". This was not an issue until bc3ae46b42 (rebase:
> do not attempt to remove startup_info->original_cwd, 2021-12-09), when
> the .dir of the "git checkout" child process was changed such that it no
> longer runs at the root of the worktree.
>
> Propagate GIT_WORK_TREE to the "git checkout" child process and test
> that rebase in a subdirectory of a worktree succeeds.
>
> Signed-off-by: Glen Choo <chooglen@google.com>
> ---
> Here is a fix for the bug I found in [1]. I didn't look through the rest
> of the "preserve cwd" thread for other possible bugs pertaining to
> worktrees, but I didn't find any during a cursory glance at sequencer.c.
>
> I'm also not sure if this is the idiomatic way to do it since, I assume,
> we'd always want to propagate GIT_WORK_TREE, but this is identical to
> how do_exec() sets GIT_WORK_TREE in the same file (perhaps this is
> something that should be refactored).
>
> [1] https://lore.kernel.org/git/kl6lilu71rzl.fsf@chooglen-macbookpro.roam.corp.google.com
I forgot to add this to the previous email:
cc-ing Junio because this bug is in master.
Previous: Glen ChooNext: Elijah Newren
Message 2 of 5 in “sequencer.c: set GIT_WORK_TREE in run_git_checkout”
  1. sequencer.c: set GIT_WORK_TREE in run_git_checkoutGlen Choo, Jan 25, 2022
  2. Glen ChooJan 25, 2022
  3. Elijah NewrenJan 26, 2022
  4. Elijah NewrenJan 26, 2022
  5. Glen ChooJan 26, 2022

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.