| @@ -28,11 +28,11 @@ impl file::Store { · 27 unmodified lines |
| 28 | /// The lookup algorithm follows the one in [the git documentation][git-lookup-docs]. | 28 | /// The lookup algorithm follows the one in [the git documentation][git-lookup-docs]. |
| 29 | /// | 29 | /// |
| 30 | /// [git-lookup-docs]: https://github.com/git/git/blob/5d5b1473453400224ebb126bf3947e0a3276bdf5/Documentation/revisions.txt#L34-L46 | 30 | /// [git-lookup-docs]: https://github.com/git/git/blob/5d5b1473453400224ebb126bf3947e0a3276bdf5/Documentation/revisions.txt#L34-L46 |
| 31 | pub fn find<'a, 'p, Name, E>( | 31 | pub fn find<'a, 'p, 's, Name, E>( |
| 32 | &self, | 32 | &'s self, |
| 33 | partial: Name, | 33 | partial: Name, |
| 34 | packed: Option<&'p packed::Buffer>, | 34 | packed: Option<&'p packed::Buffer>, |
| 35 | ) -> Result<Option<file::Reference<'_>>, Error> | 35 | ) -> Result<Option<file::loose_then_packed::Reference<'p, 's>>, Error> |
| 36 | where | 36 | where |
| 37 | Name: TryInto<PartialName<'a>, Error = E>, | 37 | Name: TryInto<PartialName<'a>, Error = E>, |
| 38 | Error: From<E>, | 38 | Error: From<E>, |
| @@ -41,11 +41,11 @@ impl file::Store { · 2 unmodified lines |
| 41 | self.find_one_with_verified_input(path.to_partial_path().as_ref(), packed) | 41 | self.find_one_with_verified_input(path.to_partial_path().as_ref(), packed) |
| 42 | } | 42 | } |
| 43 | | 43 | |
| 44 | pub(in crate::store::file) fn find_one_with_verified_input<'p>( | 44 | pub(in crate::store::file) fn find_one_with_verified_input<'p, 's>( |
| 45 | &self, | 45 | &'s self, |
| 46 | relative_path: &Path, | 46 | relative_path: &Path, |
| 47 | packed: Option<&'p packed::Buffer>, | 47 | packed: Option<&'p packed::Buffer>, |
| 48 | ) -> Result<Option<file::Reference<'_>>, Error> { | 48 | ) -> Result<Option<file::loose_then_packed::Reference<'p, 's>>, Error> { |
| 49 | let is_all_uppercase = relative_path | 49 | let is_all_uppercase = relative_path |
| 50 | .to_string_lossy() | 50 | .to_string_lossy() |
| 51 | .as_ref() | 51 | .as_ref() |
| @@ -74,13 +74,13 @@ impl file::Store { · 22 unmodified lines |
| 74 | ) | 74 | ) |
| 75 | } | 75 | } |
| 76 | | 76 | |
| 77 | fn find_inner<'p>( | 77 | fn find_inner<'p, 's>( |
| 78 | &self, | 78 | &'s self, |
| 79 | inbetween: &str, | 79 | inbetween: &str, |
| 80 | relative_path: &Path, | 80 | relative_path: &Path, |
| 81 | packed: Option<&'p packed::Buffer>, | 81 | packed: Option<&'p packed::Buffer>, |
| 82 | transform: Transform, | 82 | transform: Transform, |
| 83 | ) -> Result<Option<file::Reference<'_>>, Error> { | 83 | ) -> Result<Option<file::loose_then_packed::Reference<'p, 's>>, Error> { |
| 84 | let (base, is_definitely_absolute) = match transform { | 84 | let (base, is_definitely_absolute) = match transform { |
| 85 | Transform::EnforceRefsPrefix => ( | 85 | Transform::EnforceRefsPrefix => ( |
| 86 | if relative_path.starts_with("refs") { | 86 | if relative_path.starts_with("refs") { |
| @@ -100,8 +100,8 @@ impl file::Store { · 13 unmodified lines |
| 100 | if let Some(packed) = packed { | 100 | if let Some(packed) = packed { |
| 101 | let full_name = path_to_name(relative_path); | 101 | let full_name = path_to_name(relative_path); |
| 102 | let full_name = PartialName((*full_name).as_bstr()); | 102 | let full_name = PartialName((*full_name).as_bstr()); |
| 103 | if let Some(_packed_ref) = packed.find(full_name)? { | 103 | if let Some(packed_ref) = packed.find(full_name)? { |
| 104 | todo!("transform packed ref into standard ref") | 104 | return Ok(Some(file::loose_then_packed::Reference::Packed(packed_ref))); |
| 105 | }; | 105 | }; |
| 106 | } | 106 | } |
| 107 | } | 107 | } |
| @@ -111,6 +111,7 @@ impl file::Store { · 3 unmodified lines |
| 111 | }; | 111 | }; |
| 112 | Ok(Some( | 112 | Ok(Some( |
| 113 | file::Reference::try_from_path(self, &relative_path, &contents) | 113 | file::Reference::try_from_path(self, &relative_path, &contents) |
| | 114 | .map(file::loose_then_packed::Reference::Loose) |
| 114 | .map_err(|err| Error::ReferenceCreation { err, relative_path })?, | 115 | .map_err(|err| Error::ReferenceCreation { err, relative_path })?, |
| 115 | )) | 116 | )) |
| 116 | } | 117 | } |
| @@ -153,11 +154,11 @@ pub mod existing { · 36 unmodified lines |
| 153 | | 154 | |
| 154 | impl file::Store { | 155 | impl file::Store { |
| 155 | /// Similar to [`file::Store::find()`] but a non-existing ref is treated as error. | 156 | /// Similar to [`file::Store::find()`] but a non-existing ref is treated as error. |
| 156 | pub fn find_existing<'a, 'p, Name, E>( | 157 | pub fn find_existing<'a, 'p, 's, Name, E>( |
| 157 | &self, | 158 | &'s self, |
| 158 | partial: Name, | 159 | partial: Name, |
| 159 | packed: Option<&'p packed::Buffer>, | 160 | packed: Option<&'p packed::Buffer>, |
| 160 | ) -> Result<file::Reference<'_>, Error> | 161 | ) -> Result<file::loose_then_packed::Reference<'p, 's>, Error> |
| 161 | where | 162 | where |
| 162 | Name: TryInto<PartialName<'a>, Error = E>, | 163 | Name: TryInto<PartialName<'a>, Error = E>, |
| 163 | crate::name::Error: From<E>, | 164 | crate::name::Error: From<E>, |