Unified · Split
| @@ -94,15 +94,15 @@ pub mod parse { · 93 unmodified lines | |||
| 94 | if name.is_empty() && sep == Some(b'@') { | 94 | if name.is_empty() && sep == Some(b'@') { |
| 95 | delegate.set_ref("HEAD".into()).ok_or(Error::Delegate)?; | 95 | delegate.set_ref("HEAD".into()).ok_or(Error::Delegate)?; |
| 96 | } else { | 96 | } else { |
| 97 | if consecutive_hex_chars.unwrap_or(0) >= git_hash::Prefix::MIN_HEX_LEN { | 97 | (consecutive_hex_chars.unwrap_or(0) >= git_hash::Prefix::MIN_HEX_LEN) |
| 98 | git_hash::Prefix::from_hex(name.to_str().expect("hexadecimal only")) | 98 | .then(|| { |
| 99 | .ok() | 99 | git_hash::Prefix::from_hex(name.to_str().expect("hexadecimal only")) |
| 100 | .and_then(|prefix| delegate.set_prefix(prefix)) | 100 | .ok() |
| 101 | .or_else(|| delegate.set_ref(name)) | 101 | .and_then(|prefix| delegate.set_prefix(prefix)) |
| 102 | } else { | 102 | }) |
| 103 | delegate.set_ref(name) | 103 | .flatten() |
| 104 | } | 104 | .or_else(|| delegate.set_ref(name)) |
| 105 | .ok_or(Error::Delegate)?; | 105 | .ok_or(Error::Delegate)?; |
| 106 | } | 106 | } |
| 107 | 107 | ||
| 108 | let past_sep = input[sep_pos.map(|pos| pos + 1).unwrap_or(input.len())..].as_bstr(); | 108 | let past_sep = input[sep_pos.map(|pos| pos + 1).unwrap_or(input.len())..].as_bstr(); |