mirror of
https://github.com/martinvonz/jj.git
synced 2024-12-24 12:48:55 +00:00
diff_util: unify handling of unexpected cases
This moves the error cases last in each `match` block, switches to using format strings, and includes the full value in the message.
This commit is contained in:
parent
6df7db3dc0
commit
5ef925deb8
1 changed files with 7 additions and 13 deletions
|
@ -352,12 +352,6 @@ fn diff_content(
|
|||
let target = repo.store().read_symlink(path, id)?;
|
||||
Ok(target.into_bytes())
|
||||
}
|
||||
TreeValue::Tree(_) => {
|
||||
panic!(
|
||||
"Got an unexpected tree in a diff of path {}",
|
||||
path.to_internal_file_string()
|
||||
);
|
||||
}
|
||||
TreeValue::GitSubmodule(id) => {
|
||||
Ok(format!("Git submodule checked out at {}", id.hex()).into_bytes())
|
||||
}
|
||||
|
@ -367,6 +361,9 @@ fn diff_content(
|
|||
conflicts::materialize(&conflict, repo.store(), path, &mut content).unwrap();
|
||||
Ok(content)
|
||||
}
|
||||
TreeValue::Tree(_) => {
|
||||
panic!("Unexpected {value:?} in diff at path {path:?}",);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -506,12 +503,6 @@ fn git_diff_part(
|
|||
let target = repo.store().read_symlink(path, id)?;
|
||||
content = target.into_bytes();
|
||||
}
|
||||
TreeValue::Tree(_) => {
|
||||
panic!(
|
||||
"Got an unexpected tree in a diff of path {}",
|
||||
path.to_internal_file_string()
|
||||
);
|
||||
}
|
||||
TreeValue::GitSubmodule(id) => {
|
||||
// TODO: What should we actually do here?
|
||||
mode = "040000".to_string();
|
||||
|
@ -523,6 +514,9 @@ fn git_diff_part(
|
|||
let conflict = repo.store().read_conflict(path, id).unwrap();
|
||||
conflicts::materialize(&conflict, repo.store(), path, &mut content).unwrap();
|
||||
}
|
||||
TreeValue::Tree(_) => {
|
||||
panic!("Unexpected {value:?} in diff at path {path:?}");
|
||||
}
|
||||
}
|
||||
let hash = hash[0..10].to_string();
|
||||
Ok(GitDiffPart {
|
||||
|
@ -896,6 +890,6 @@ fn diff_summary_char(value: Option<&TreeValue>) -> char {
|
|||
Some(TreeValue::Symlink(_)) => 'L',
|
||||
Some(TreeValue::GitSubmodule(_)) => 'G',
|
||||
Some(TreeValue::Conflict(_)) => 'C',
|
||||
Some(TreeValue::Tree(_)) => panic!("unexpected tree entry in diff"),
|
||||
Some(TreeValue::Tree(_)) => panic!("Unexpected {value:?} in diff"),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue