git: fix REBASE_HEAD, MERGE_HEAD and CHERRY_PICK_HEAD paths for linked worktrees#309180
Open
yogeshwaran-c wants to merge 1 commit intomicrosoft:mainfrom
Open
git: fix REBASE_HEAD, MERGE_HEAD and CHERRY_PICK_HEAD paths for linked worktrees#309180yogeshwaran-c wants to merge 1 commit intomicrosoft:mainfrom
yogeshwaran-c wants to merge 1 commit intomicrosoft:mainfrom
Conversation
…d worktrees In a linked git worktree (created with git worktree add), the worktree-specific gitdir files (REBASE_HEAD, MERGE_HEAD, CHERRY_PICK_HEAD, rebase-apply/, rebase-merge/) live under dotGit.path (.git/worktrees/<name>/), not under the working-tree root's .git entry, which is a plain file (a gitdir redirect). The three methods that detect in-progress operations were building paths with path.join(this.repository.root, '.git', ...): getRebaseCommit() -- REBASE_HEAD, rebase-apply, rebase-merge isMergeInProgress() -- MERGE_HEAD isCherryPickInProgress() -- CHERRY_PICK_HEAD Because repository.root/.git is a file rather than a directory in a linked worktree, all fs.exists() calls returned false and fs.readFile failed, so VS Code never detected an in-progress rebase, merge, or cherry-pick when operating inside a linked worktree. The Source Control view consequently showed no rebase commit, no merge indicators, and no cherry-pick state. Fix all three methods to use this.repository.dotGit.path, which already points to the worktree-specific gitdir for linked worktrees and to the .git/ directory for the main worktree — matching the pattern established by getHEADFS() and revParse().
Contributor
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: @lszomoruMatched files:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In a linked git worktree (
git worktree add), the worktree-specific gitdir files —REBASE_HEAD,MERGE_HEAD,CHERRY_PICK_HEAD,rebase-apply/,rebase-merge/— live underdotGit.path(.git/worktrees/<name>/), not under the working-tree root's.gitentry, which is a plain redirect file.Three methods in
extensions/git/src/repository.tswere building those paths withpath.join(this.repository.root, '.git', ...):getRebaseCommit()REBASE_HEAD,rebase-apply/,rebase-merge/isMergeInProgress()MERGE_HEADisCherryPickInProgress()CHERRY_PICK_HEADBecause
repository.root/.gitis a file (not a directory) in a linked worktree, allfs.exists()calls returnedfalseandfs.readFilethrew. As a result VS Code never detected an in-progress rebase, merge, or cherry-pick in a linked worktree: the Source Control view showed no rebase commit, no merge conflict indicators, and no cherry-pick state.Fix: Use
this.repository.dotGit.pathin all three methods — the same gitdir pointer already used bygetHEADFS(),revParse(), and theDotGitWatcher. For the main worktree,dotGit.pathequals<root>/.git/, so behaviour is unchanged there.Files changed
extensions/git/src/repository.ts—getRebaseCommit(),isMergeInProgress(),isCherryPickInProgress()