Resolve a stash reference (`stash@{N}`, `N`, or a view name) to its entry. `None` resolves to the most recent stash.
(&self, reference: Option<&str>)
| 444 | /// Resolve a stash reference (`stash@{N}`, `N`, or a view name) to |
| 445 | /// its entry. `None` resolves to the most recent stash. |
| 446 | pub fn stash_resolve(&self, reference: Option<&str>) -> Result<StashEntry, String> { |
| 447 | let stashes = self.stash_list()?; |
| 448 | if stashes.is_empty() { |
| 449 | return Err("No stashes found".to_string()); |
| 450 | } |
| 451 | |
| 452 | let reference = reference.unwrap_or("0"); |
| 453 | let index = if reference.starts_with("stash@{") && reference.ends_with('}') { |
| 454 | reference[7..reference.len() - 1].parse::<usize>().ok() |
| 455 | } else { |
| 456 | reference.parse::<usize>().ok() |
| 457 | }; |
| 458 | if let Some(idx) = index { |
| 459 | return stashes |
| 460 | .into_iter() |
| 461 | .find(|s| s.index == idx) |
| 462 | .ok_or_else(|| format!("stash@{{{idx}}} does not exist")); |
| 463 | } |
| 464 | |
| 465 | let full_name = if reference.starts_with(STASH_PREFIX) { |
| 466 | reference.to_string() |
| 467 | } else { |
| 468 | format!("{STASH_PREFIX}{reference}") |
| 469 | }; |
| 470 | stashes |
| 471 | .into_iter() |
| 472 | .find(|s| s.view_name == full_name) |
| 473 | .ok_or_else(|| format!("stash '{reference}' not found")) |
| 474 | } |
| 475 | |
| 476 | /// Apply a stash to the working copy: restore bytes and recorded deletions. |
| 477 | /// Pure filesystem operation — no graph interaction. Returns the |
no test coverage detected