ok/jj
1
0
Fork 0
forked from mirrors/jj

cli: don't bury GitImportError sources

#3301
This commit is contained in:
Yuya Nishihara 2024-03-16 11:57:33 +09:00
parent a6ee51a998
commit 429cdb38d7
2 changed files with 8 additions and 4 deletions

View file

@ -303,7 +303,6 @@ impl From<git2::Error> for CommandError {
impl From<GitImportError> for CommandError {
fn from(err: GitImportError) -> Self {
let message = format!("Failed to import refs from underlying Git repo: {err}");
let hint = match &err {
GitImportError::MissingHeadTarget { .. }
| GitImportError::MissingRefAncestor { .. } => Some(
@ -323,7 +322,10 @@ repository contents."
GitImportError::InternalGitError(_) => None,
GitImportError::UnexpectedBackend => None,
};
user_error_with_hint_opt(message, hint)
user_error_with_hint_opt(
ErrorWithMessage::new("Failed to import refs from underlying Git repo", err),
hint,
)
}
}

View file

@ -276,7 +276,8 @@ fn test_git_fetch_from_remote_named_git() {
// Try fetching from the remote named 'git'.
let stderr = &test_env.jj_cmd_failure(&repo_path, &["git", "fetch", "--remote=git"]);
insta::assert_snapshot!(stderr, @r###"
Error: Failed to import refs from underlying Git repo: Git remote named 'git' is reserved for local Git repository
Error: Failed to import refs from underlying Git repo
Caused by: Git remote named 'git' is reserved for local Git repository
Hint: Run `jj git remote rename` to give different name.
"###);
@ -288,7 +289,8 @@ fn test_git_fetch_from_remote_named_git() {
// Explicit import is an error.
// (This could be warning if we add mechanism to report ignored refs.)
insta::assert_snapshot!(test_env.jj_cmd_failure(&repo_path, &["git", "import"]), @r###"
Error: Failed to import refs from underlying Git repo: Git remote named 'git' is reserved for local Git repository
Error: Failed to import refs from underlying Git repo
Caused by: Git remote named 'git' is reserved for local Git repository
Hint: Run `jj git remote rename` to give different name.
"###);