That way the caller has to be aware of the possibility of an unborn branch (probably the only unborn branch) on the remote.
Unified · Split
| @@ -89,21 +89,18 @@ impl Ref { · 88 unmodified lines | |||
| 89 | /// In case of peeled refs, the tag object itself is returned as it is what the ref directly refers to, and target of the tag is returned | 89 | /// In case of peeled refs, the tag object itself is returned as it is what the ref directly refers to, and target of the tag is returned |
| 90 | /// as `peeled`. | 90 | /// as `peeled`. |
| 91 | /// If `unborn`, the first object id will be the null oid. | 91 | /// If `unborn`, the first object id will be the null oid. |
| 92 | pub fn unpack(&self) -> (&BStr, &git_hash::oid, Option<&git_hash::oid>) { | 92 | pub fn unpack(&self) -> (&BStr, Option<&git_hash::oid>, Option<&git_hash::oid>) { |
| 93 | match self { | 93 | match self { |
| 94 | Ref::Direct { full_ref_name, object } | 94 | Ref::Direct { full_ref_name, object } |
| 95 | | Ref::Symbolic { | 95 | | Ref::Symbolic { |
| 96 | full_ref_name, object, .. | 96 | full_ref_name, object, .. |
| 97 | } => (full_ref_name.as_ref(), object, None), | 97 | } => (full_ref_name.as_ref(), Some(object), None), |
| 98 | Ref::Peeled { | 98 | Ref::Peeled { |
| 99 | full_ref_name, | 99 | full_ref_name, |
| 100 | tag: object, | 100 | tag: object, |
| 101 | object: peeled, | 101 | object: peeled, |
| 102 | } => (full_ref_name.as_ref(), object, Some(peeled)), | 102 | } => (full_ref_name.as_ref(), Some(object), Some(peeled)), |
| 103 | Ref::Unborn { target: _ } => { | 103 | Ref::Unborn { target: _ } => ("HEAD".into(), None, None), |
| 104 | static NULL: git_hash::ObjectId = git_hash::ObjectId::null(git_hash::Kind::Sha1); | ||
| 105 | ("HEAD".into(), &NULL, None) | ||
| 106 | } | ||
| 107 | } | 104 | } |
| 108 | } | 105 | } |
| 109 | } | 106 | } |
| @@ -41,7 +41,9 @@ impl fetch::DelegateBlocking for CloneDelegate { · 40 unmodified lines | |||
| 41 | _previous_response: Option<&Response>, | 41 | _previous_response: Option<&Response>, |
| 42 | ) -> io::Result<Action> { | 42 | ) -> io::Result<Action> { |
| 43 | for r in refs { | 43 | for r in refs { |
| 44 | arguments.want(r.unpack().1); | 44 | if let Some(id) = r.unpack().1 { |
| 45 | arguments.want(id); | ||
| 46 | } | ||
| 45 | } | 47 | } |
| 46 | Ok(Action::Cancel) | 48 | Ok(Action::Cancel) |
| 47 | } | 49 | } |