# Register Git submodules under their own project path \(\#61859\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/998fbf30ff2929cce866bd19b77237210db88484)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 998fbf30ff2929cce866bd19b77237210db88484

Requested commit: 998fbf30ff2929cce866bd19b77237210db88484

Commit: 998fbf30ff2929cce866bd19b77237210db88484

Tree: 2e3eecef3ee6c96cf27e9300307e808afa7d095b

Author: Ayush Patil

Committer: GitHub

## Message

```
Register Git submodules under their own project path (#61859)

Closes #61671

A submodule's `.git` is a file pointing into the superproject's
`.git/modules/<name>`, which looks just like a linked worktree's `.git`
file. The identity-path resolution used for recent projects and project
grouping treated them the same, so submodules got registered under
`.git/modules/<name>` instead of their own folder.

The fix detects submodule git dirs (`is_submodule_git_dir`) and skips
resolution for them, so a submodule keeps its own working directory as
its identity. Linked worktrees and bare repos are unaffected.

### Current vs. Expected

Current: opening submodule `Foo/Bar` registers the path as
`Foo/.git/modules/Bar`.
Expected: it registers as `Foo/Bar`, like any other project.

### Video


https://github.com/user-attachments/assets/e2eee5e7-ef64-47ed-9780-6fcafda5ae30

### Tests

- `is_submodule_git_dir` unit test
- `resolve_git_worktree_to_main_repo` returns `None` for a submodule
- persistence test asserting the submodule identity stays at its own
folder

Release Notes:

- Fixed Git submodules being registered under the parent repository's
`.git/modules` directory instead of their own path
```

## Parents

- [790dcefb01b8dd939434265c5524c8ae476ad77d](https://git.cafe/gitcafe/zed/commit/790dcefb01b8dd939434265c5524c8ae476ad77d?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/998fbf30ff2929cce866bd19b77237210db88484?format=markdown)
