(git: &GitRepository)
| 2847 | } |
| 2848 | |
| 2849 | pub(crate) fn require_clean_git_worktree(git: &GitRepository) -> CliResult<()> { |
| 2850 | let index = git |
| 2851 | .index() |
| 2852 | .map_err(|error| git_error(format!("cannot read Git index: {error}")))?; |
| 2853 | if index.has_conflicts() { |
| 2854 | return Err(git_error("Git index contains unresolved conflicts")); |
| 2855 | } |
| 2856 | |
| 2857 | let mut options = GitStatusOptions::new(); |
| 2858 | options |
| 2859 | .include_untracked(false) |
| 2860 | .recurse_untracked_dirs(false); |
| 2861 | let statuses = git |
| 2862 | .statuses(Some(&mut options)) |
| 2863 | .map_err(|error| git_error(format!("cannot inspect Git status: {error}")))?; |
| 2864 | if statuses.iter().any(|entry| tracked_delta(entry.status())) { |
| 2865 | return Err(git_error( |
| 2866 | "Git has staged or unstaged changes to tracked paths", |
| 2867 | )); |
| 2868 | } |
| 2869 | Ok(()) |
| 2870 | } |
| 2871 | |
| 2872 | fn require_matching_clean_workspaces<'repo>( |
| 2873 | repo: &Repository, |
no test coverage detected