lazygit
lazygit copied to clipboard
Review code for completeness/consistency of CWD management
Topic In #3183, @jesseduffield writes:
we should do an audit on where we're calling os.Getwd and os.Chdir and confirm that it all makes sense and that we're sticking with the pattern of having the CWD be the worktree root
This is an issue to track a review of CWD-related policy and issues. As a kickoff, post-3183, here are some baselines:
-
lazygitis no longer bound to starting in a repository/worktree root. It can run from any subdirectory of a repo, including through symlinks, etc. Anything git itself can handle. - Paths within the repo are, e.g. for modified or staged files, are always relative to the repo root not to lazygit's starting CWD
- The prior item implies that certain git commands, esp. any "diff-like" commands, must be run from the worktree root, not from CWD. This is generally done by passing an explicit
-Cparameter to git, ala:git -C /path/to/worktreeRoot diff .... - The
-Coption has another benefit: explicitness during logging and in integration test expectations. For example, 3183 included a change to parallelize git invocations related to retrieving info from all worktrees. These calls are indistinguishable without-C. This obfuscates the logs, and breaks the integration tests which can no longer discern which call matches which expected result.
In light of the above, the review is intended to find any loose ends such as: bugs, missed edge cases, obsolete/misaligned code, etc. w.r.t. the new CWD landscape.