The branch name used for reconcile direction classification. An attached HEAD keeps its branch; a detached HEAD keeps the workspace view (§7.5): the symbolic branch did not change, so only commit/tree movement counts as a Git-side change and routes to the §7.5 import.
(git: &GitRepository, view: &str)
| 2831 | /// view (§7.5): the symbolic branch did not change, so only commit/tree |
| 2832 | /// movement counts as a Git-side change and routes to the §7.5 import. |
| 2833 | fn current_git_branch_or_view(git: &GitRepository, view: &str) -> CliResult<String> { |
| 2834 | match observe_head(git).map_err(observation_error)? { |
| 2835 | HeadObservation::Attached { symref, .. } => symref |
| 2836 | .strip_prefix("refs/heads/") |
| 2837 | .map(str::to_string) |
| 2838 | .ok_or_else(|| git_error(format!("Git HEAD symref '{symref}' is not a local branch"))), |
| 2839 | HeadObservation::Detached { .. } => Ok(view.to_string()), |
| 2840 | HeadObservation::Unborn { symref } => { |
| 2841 | Err(git_error(format!("Git HEAD is unborn at '{symref}'"))) |
| 2842 | } |
| 2843 | HeadObservation::MissingTarget { symref } => Err(git_error(format!( |
| 2844 | "Git HEAD target '{symref}' does not exist" |
| 2845 | ))), |
| 2846 | } |
| 2847 | } |
| 2848 | |
| 2849 | pub(crate) fn require_clean_git_worktree(git: &GitRepository) -> CliResult<()> { |
| 2850 | let index = git |
no test coverage detected