# Fix submodules being incorrectly classified as linked worktrees \(\#52507\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 7cf26f4046774ba8be6276aebef24347a4164694

Requested commit: 7cf26f4046774ba8be6276aebef24347a4164694

Commit: 7cf26f4046774ba8be6276aebef24347a4164694

Tree: 555b763cef87fae742ccc6513f96ece992a79996

Author: Richard Feldman

Committer: GitHub

## Message

```
Fix submodules being incorrectly classified as linked worktrees (#52507)

For submodules, `common_dir_abs_path` equals `repository_dir_abs_path`
(since submodules don't have a `commondir` file). The previous code
passed this path to `original_repo_path_from_common_dir`
unconditionally, which returned the `.git/modules/<name>` path as the
`original_repo_abs_path` — causing `linked_worktree_path()` to return a
false positive for submodules.

Now we detect linked worktrees by checking whether `common_dir` differs
from `repository_dir` (only true for actual linked worktrees that have a
`commondir` file). For normal repos and submodules,
`original_repo_abs_path` is simply `work_directory_abs_path`.

Also fixes the misleading doc comment on `common_dir_abs_path` in
`LocalRepositoryEntry` and adds test assertions for
`original_repo_abs_path` and `linked_worktree_path()` on both worktrees
and submodules.

Closes AI-102

Release Notes:

- Fixed git submodules being incorrectly classified as linked worktrees,
which could cause issues with worktree-related operations.
```

## Parents

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

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