Unified · Split
| @@ -10,7 +10,7 @@ use crate::name::is_pseudo_ref; · 9 unmodified lines | ||
| 10 | 10 | use crate::{ |
| 11 | 11 | file, |
| 12 | 12 | store_impl::{file::loose, packed}, |
| 13 | − BString, FullNameRef, PartialNameCow, Reference, | |
| 13 | + BStr, BString, FullNameRef, PartialNameCow, Reference, | |
| 14 | 14 | }; |
| 15 | 15 | |
| 16 | 16 | enum Transform { |
| @@ -161,26 +161,26 @@ impl file::Store { · 144 unmodified lines | ||
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | impl file::Store { |
| 164 | − fn base_for_name(&self, name: FullNameRef<'_>) -> &Path { | |
| 164 | + fn base_dir_and_rela_path_for_name<'a>(&self, name: FullNameRef<'a>) -> (&Path, &'a BStr) { | |
| 165 | 165 | self.common_dir |
| 166 | 166 | .as_deref() |
| 167 | 167 | .and_then(|commondir| { |
| 168 | − name.category().map(|c| { | |
| 168 | + name.category_and_short_name().and_then(|(c, sn)| { | |
| 169 | 169 | use crate::Category::*; |
| 170 | − match c { | |
| 171 | − Tag | LocalBranch | RemoteBranch | Note | MainRef | MainPseudoRef | LinkedRef | |
| 172 | − | LinkedPseudoRef => commondir, | |
| 173 | − PseudoRef | Bisect | Rewritten | WorktreePrivate => self.git_dir.as_path(), | |
| 174 | − } | |
| 170 | + Some(match c { | |
| 171 | + Tag | LocalBranch | RemoteBranch | Note => (commondir, name.as_bstr()), | |
| 172 | + MainRef | MainPseudoRef | LinkedRef | LinkedPseudoRef => (commondir, sn), | |
| 173 | + PseudoRef | Bisect | Rewritten | WorktreePrivate => return None, | |
| 174 | + }) | |
| 175 | 175 | }) |
| 176 | 176 | }) |
| 177 | − .unwrap_or(self.git_dir.as_path()) | |
| 177 | + .unwrap_or((self.git_dir.as_path(), name.as_bstr())) | |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | /// Implements the logic required to transform a fully qualified refname into a filesystem path |
| 181 | 181 | pub(crate) fn reference_path(&self, name: FullNameRef<'_>) -> PathBuf { |
| 182 | − let base = self.base_for_name(name); | |
| 183 | − let relative_path = git_path::to_native_path_on_windows(name.as_bstr()); | |
| 182 | + let (base, relative_path) = self.base_dir_and_rela_path_for_name(name); | |
| 183 | + let relative_path = git_path::to_native_path_on_windows(relative_path); | |
| 184 | 184 | match &self.namespace { |
| 185 | 185 | None => base.join(relative_path), |
| 186 | 186 | Some(namespace) => base.join(namespace.to_path()).join(relative_path), |