jesseduffield.lazygit/pkg/integration/tests/worktree
Stefan Haller d19af37ee7 Tell git where the repo is when it can't find it itself
git finds a repo by looking for a .git in the directory a command runs
in. Lazygit runs its commands in the work tree, so that normally works —
but not when the git dir lives somewhere else entirely, which is what
core.worktree and --work-tree are for. Lazygit chdir'd into such a work
tree and then ran commands that couldn't see any repo from there, so
opening a repo with core.worktree set panicked on startup. It only
worked with --git-dir because that leaves GIT_DIR in the environment for
every command to inherit.

Work out at startup whether git can find the repo from its work tree,
and when it can't, put GIT_DIR and GIT_WORK_TREE on every command the
repo's builder produces. As with the working directory the builder pins
(527124d0e0), these also go into the process env — subprocesses don't
come through the builder — but the commands don't read them from there,
because the process env belongs to whichever repo we have switched to
since.

Working out whether git can find the repo means asking git, rather than
reading the .git file, whose contents can spell the same directory
differently than git does. The extra query is skipped for a repo whose
git dir is simply its .git directory, which is nearly all of them.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-08 11:15:01 +02:00
..
add_for_existing_branch.go Move the new-worktree keybinding from worktrees to universal 2026-07-03 18:53:05 +02:00
add_from_branch.go Move the new-worktree keybinding from worktrees to universal 2026-07-03 18:53:05 +02:00
add_from_branch_detached.go Move the new-worktree keybinding from worktrees to universal 2026-07-03 18:53:05 +02:00
add_from_commit.go Move the new-worktree keybinding from worktrees to universal 2026-07-03 18:53:05 +02:00
add_from_remote_branch.go Move the new-worktree keybinding from worktrees to universal 2026-07-03 18:53:05 +02:00
add_from_stash.go Move the new-worktree keybinding from worktrees to universal 2026-07-03 18:53:05 +02:00
add_from_tag.go Move the new-worktree keybinding from worktrees to universal 2026-07-03 18:53:05 +02:00
associate_branch_bisect.go Show worktree name next to branch in branches list 2026-03-09 11:34:34 +01:00
associate_branch_rebase.go Show worktree name next to branch in branches list 2026-03-09 11:34:34 +01:00
bare_repo.go Set working directory in lazygit test command 2024-01-12 19:59:31 +11:00
bare_repo_worktree_config.go Fix typos 2025-01-03 10:50:36 +11:00
crud.go Offer to delete the branch when removing a worktree 2026-07-03 19:04:44 +02:00
custom_command.go Convert custom command Key fields to Keybinding 2026-05-25 15:32:47 +02:00
default_path_tilde.go Expand a leading ~ in worktree paths to the home directory 2026-07-03 18:53:05 +02:00
detach_worktree_from_branch.go Delete the branch when deleting it via its worktree 2026-07-03 19:04:44 +02:00
dotfile_bare_repo.go Set working directory in lazygit test command 2024-01-12 19:59:31 +11:00
double_nested_linked_submodule.go Use getters for AppState and UserConfig instead of accessing the fields directly 2024-08-18 10:24:52 +02:00
exclude_file_in_worktree.go Show branch name and detached HEAD in worktrees tab 2026-03-08 12:51:46 +01:00
fast_forward_worktree_branch.go Show worktree name next to branch in branches list 2026-03-09 11:34:34 +01:00
fast_forward_worktree_branch_should_not_pollute_current_worktree.go Show worktree name next to branch in branches list 2026-03-09 11:34:34 +01:00
force_remove_worktree.go Offer to delete the branch when removing a worktree 2026-07-03 19:04:44 +02:00
force_remove_worktree_with_submodules.go Offer to delete the branch when removing a worktree 2026-07-03 19:04:44 +02:00
location_candidates.go Move the new-worktree keybinding from worktrees to universal 2026-07-03 18:53:05 +02:00
new_worktree_picker.go Rework the worktrees-panel 'n' into a branch picker 2026-07-03 18:53:05 +02:00
new_worktree_picker_remote.go Rework the worktrees-panel 'n' into a branch picker 2026-07-03 18:53:05 +02:00
remove_worktree_and_both_branches.go Offer to delete the branch when removing a worktree 2026-07-03 19:04:44 +02:00
remove_worktree_and_branch.go Offer to delete the branch when removing a worktree 2026-07-03 19:04:44 +02:00
remove_worktree_and_delete_local_and_remote_branch.go Allow deleting local+remote of a worktree-checked-out branch at once 2026-07-03 19:04:44 +02:00
remove_worktree_from_branch.go Delete the branch when deleting it via its worktree 2026-07-03 19:04:44 +02:00
reset_window_tabs.go Show branch name and detached HEAD in worktrees tab 2026-03-08 12:51:46 +01:00
separate_work_tree_config.go Tell git where the repo is when it can't find it itself 2026-08-08 11:15:01 +02:00
symlink_into_repo_subdir.go Use getters for AppState and UserConfig instead of accessing the fields directly 2024-08-18 10:24:52 +02:00
worktree_in_repo.go Rework the worktrees-panel 'n' into a branch picker 2026-07-03 18:53:05 +02:00