fix(paths): handle submodule gitdirs in worktree IDs#1359
Open
MuskanPaliwal wants to merge 4 commits into
Open
fix(paths): handle submodule gitdirs in worktree IDs#1359MuskanPaliwal wants to merge 4 commits into
MuskanPaliwal wants to merge 4 commits into
Conversation
Entire-Checkpoint: 803ea1872413
Author
|
Hi @blackgirlbytes , can I get a review on this PR ? |
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.
Fixes #640.
This fixes session initialization in repositories that contain Git submodules.
GetWorktreeIDpreviously treated any.gitfile whosegitdir:target did not contain.git/worktrees/<id>or.bare/worktrees/<id>as invalid. Ordinary submodules use a different valid Git layout: their checkout has a.gitfile pointing into the parent repository.git/modules/...directory. That caused Entire to fail before a session could initialize withunexpected gitdir format (no worktrees).Core Changes:
GetWorktreeIDto recognize ordinary submodule gitdirs under.git/modules/<submodule>and return an empty worktree ID for them..git/worktrees/<id>and bare-worktree layouts under.bare/worktrees/<id>..git/modules/<submodule>/worktrees/<id>..git/worktrees/<parent-worktree>/modules/<submodule>means the parent repo is a linked worktree, but the submodule itself is still an ordinary submodule checkout, so the returned submodule worktree ID should be empty.parseWorktreeIDso the shape-specific logic is isolated and covered by focused tests.API Notes:
GetWorktreeIDcontract remains: return an empty string for the main checkout namespace, return a non-empty ID for a real linked worktree namespace, and return an error for unrecognized.gitfile formats.Compatibility / Release Notes:
pathspackage regression tests and a manual local submodule smoke check.Validation:
GOCACHE=/private/tmp/entire-go-cache go test ./cmd/entire/cli/paths -run ^TestGetWorktreeID$ -count=1passed.git diff --check upstream/main...HEADpassed.gitdir: ../../.git/modules/deps/libfor a real submodule checkout, matching the issue layout.