History

fix: uncategorized refs should not be per-worktree

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.

Peter Grayson committed 3 years ago

Commit 3d6832c1 parent 877951a1 file · +2 −2Browse files

Unified · Split

gix-ref/src/store/file/find.rs+2−2
@@ -186,10 +186,10 @@ impl file::Store { · 185 unmodified lines
186186 }
187187 })
188188 .unwrap_or((commondir.into(), sn)),
189− PseudoRef | Bisect | Rewritten | WorktreePrivate => return None,
189+ PseudoRef | Bisect | Rewritten | WorktreePrivate => (self.git_dir.as_path().into(), name),
190190 })
191191 })
192− .unwrap_or((self.git_dir.as_path().into(), name))
192+ .unwrap_or((commondir.into(), name))
193193 }
194194
195195 /// Implements the logic required to transform a fully qualified refname into a filesystem path