forked from mirrors/jj
git: move import-related types close to import_refs() function
This commit is contained in:
parent
f991705e47
commit
dbb1adaf0a
1 changed files with 30 additions and 30 deletions
|
@ -58,36 +58,6 @@ impl fmt::Display for RefName {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum GitImportError {
|
||||
#[error("Failed to read Git HEAD target commit {id}: {err}", id=id.hex())]
|
||||
MissingHeadTarget {
|
||||
id: CommitId,
|
||||
#[source]
|
||||
err: BackendError,
|
||||
},
|
||||
#[error("Ancestor of Git ref {ref_name} is missing: {err}")]
|
||||
MissingRefAncestor {
|
||||
ref_name: String,
|
||||
#[source]
|
||||
err: BackendError,
|
||||
},
|
||||
#[error(
|
||||
"Git remote named '{name}' is reserved for local Git repository",
|
||||
name = REMOTE_NAME_FOR_LOCAL_GIT_REPO
|
||||
)]
|
||||
RemoteReservedForLocalGitRepo,
|
||||
#[error("Unexpected git error when importing refs: {0}")]
|
||||
InternalGitError(#[from] git2::Error),
|
||||
}
|
||||
|
||||
/// Describes changes made by `import_refs()` or `fetch()`.
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub struct GitImportStats {
|
||||
/// Commits superseded by newly imported commits.
|
||||
pub abandoned_commits: Vec<CommitId>,
|
||||
}
|
||||
|
||||
fn parse_git_ref(ref_name: &str) -> Option<RefName> {
|
||||
if let Some(branch_name) = ref_name.strip_prefix("refs/heads/") {
|
||||
// Git CLI says 'HEAD' is not a valid branch name
|
||||
|
@ -173,6 +143,36 @@ fn resolve_git_ref_to_commit_id(
|
|||
Some(CommitId::from_bytes(git_commit.id().as_bytes()))
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum GitImportError {
|
||||
#[error("Failed to read Git HEAD target commit {id}: {err}", id=id.hex())]
|
||||
MissingHeadTarget {
|
||||
id: CommitId,
|
||||
#[source]
|
||||
err: BackendError,
|
||||
},
|
||||
#[error("Ancestor of Git ref {ref_name} is missing: {err}")]
|
||||
MissingRefAncestor {
|
||||
ref_name: String,
|
||||
#[source]
|
||||
err: BackendError,
|
||||
},
|
||||
#[error(
|
||||
"Git remote named '{name}' is reserved for local Git repository",
|
||||
name = REMOTE_NAME_FOR_LOCAL_GIT_REPO
|
||||
)]
|
||||
RemoteReservedForLocalGitRepo,
|
||||
#[error("Unexpected git error when importing refs: {0}")]
|
||||
InternalGitError(#[from] git2::Error),
|
||||
}
|
||||
|
||||
/// Describes changes made by `import_refs()` or `fetch()`.
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub struct GitImportStats {
|
||||
/// Commits superseded by newly imported commits.
|
||||
pub abandoned_commits: Vec<CommitId>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct RefsToImport {
|
||||
/// Git ref `(full_name, new_target)`s to be copied to the view.
|
||||
|
|
Loading…
Reference in a new issue