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