When creating a new ref from using a Repository instantiated from a linked worktree, if the ref did not fit one of the well-known categories, it would be incorrectly stored as a per-worktree reference instead of a shared reference. For example, the reference "refs/stacks/linked" does not fit any of the well known categories. According to git-worktree(1), this ref should be shared across all worktrees; i.e. located at $GIT_COMMON_DIR/refs/stacks/linked and *not* in $GIT_COMMON_DIR/worktrees/linked/refs/stacks/linked. This change tweaks the control flow so that uncategorized refs correctly fallback to being relative to commondir while still placing refs that are supposed to be per-worktree in the per-worktree location.
Unified · Split
| @@ -186,10 +186,10 @@ impl file::Store { · 185 unmodified lines | ||
| 186 | 186 | } |
| 187 | 187 | }) |
| 188 | 188 | .unwrap_or((commondir.into(), sn)), |
| 189 | − PseudoRef | Bisect | Rewritten | WorktreePrivate => return None, | |
| 189 | + PseudoRef | Bisect | Rewritten | WorktreePrivate => (self.git_dir.as_path().into(), name), | |
| 190 | 190 | }) |
| 191 | 191 | }) |
| 192 | − .unwrap_or((self.git_dir.as_path().into(), name)) | |
| 192 | + .unwrap_or((commondir.into(), name)) | |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | /// Implements the logic required to transform a fully qualified refname into a filesystem path |