Previously, the expanded prefix would be a list of possibilities, even though it's such a common case that we really want to avoid spamming the remote about it when asking for HEAD during clone for instance.
Unified · Split
| @@ -134,6 +134,9 @@ impl<'a> RefSpecRef<'a> { · 133 unmodified lines | ||
| 134 | 134 | Operation::Fetch => self.source(), |
| 135 | 135 | Operation::Push => self.destination(), |
| 136 | 136 | }?; |
| 137 | + if source == "HEAD" { | |
| 138 | + return source.into(); | |
| 139 | + } | |
| 137 | 140 | let suffix = source.strip_prefix(b"refs/")?; |
| 138 | 141 | let slash_pos = suffix.find_byte(b'/')?; |
| 139 | 142 | let prefix = source[..="refs/".len() + slash_pos].as_bstr(); |
| @@ -1,6 +1,11 @@ | ||
| 1 | 1 | mod prefix { |
| 2 | 2 | use git_refspec::{parse::Operation, RefSpec}; |
| 3 | 3 | |
| 4 | + #[test] | |
| 5 | + fn head_is_specifically_known() { | |
| 6 | + assert_eq!(parse("HEAD").to_ref().prefix().unwrap(), "HEAD"); | |
| 7 | + } | |
| 8 | + | |
| 4 | 9 | #[test] |
| 5 | 10 | fn partial_refs_have_no_prefix() { |
| 6 | 11 | assert_eq!(parse("main").to_ref().prefix(), None); |
| @@ -58,14 +63,13 @@ mod prefix { · 51 unmodified lines | ||
| 58 | 63 | mod expand_prefixes { |
| 59 | 64 | use git_refspec::parse::Operation; |
| 60 | 65 | |
| 66 | + #[test] | |
| 67 | + fn head_is_specifically_known() { | |
| 68 | + assert_eq!(parse("HEAD"), ["HEAD"]); | |
| 69 | + } | |
| 70 | + | |
| 61 | 71 | #[test] |
| 62 | 72 | fn partial_refs_have_many_prefixes() { |
| 63 | − // "%.*s", | |
| 64 | − // "refs/%.*s", | |
| 65 | − // "refs/tags/%.*s", | |
| 66 | − // "refs/heads/%.*s", | |
| 67 | − // "refs/remotes/%.*s", | |
| 68 | − // "refs/remotes/%.*s/HEAD", | |
| 69 | 73 | assert_eq!( |
| 70 | 74 | parse("main"), |
| 71 | 75 | [ |