History

Keep showing debug representation of paths in gitoxide-core

Where this was done already, in `bail!` and `anyhow!`. A newly enforced clippy lint warns about this, making the good point that the debug representation can change in the future. But the display representation it recommends using is less suitable in these places, because it can result in more ambiguous output due to the absence of quoting and escaping. (In some cases, it seems like the display representation could slightly exacerbate CVE-2024-43785 / #1534, but using the debug representation on these two macro calls is peripheral to the cases of greatest concern, and this doesn't really mitigate that.) The clippy lint being suppressed here in two specific places is: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_debug_formatting

Eliah Kagan committed 1 year ago

Commit 6f192671 parent f4c37c02 files · +2 −0Browse files

Unified · Split

2 files
  1. gitoxide-core/src/repository/attributes/validate_baseline.rs +1 −0
  2. gitoxide-core/src/repository/index/mod.rs +1 −0
gitoxide-core/src/repository/attributes/validate_baseline.rs+1−0
@@ -114,6 +114,7 @@ pub(crate) mod function { · 113 unmodified lines
114 };114 };
115 let work_dir = ignore115 let work_dir = ignore
116 .then(|| {116 .then(|| {
117 #[allow(clippy::unnecessary_debug_formatting)]
117 repo.workdir()118 repo.workdir()
118 .map(ToOwned::to_owned)119 .map(ToOwned::to_owned)
119 .ok_or_else(|| anyhow!("repository at {:?} must have a worktree checkout", repo.path()))120 .ok_or_else(|| anyhow!("repository at {:?} must have a worktree checkout", repo.path()))
gitoxide-core/src/repository/index/mod.rs+1−0
@@ -51,6 +51,7 @@ pub fn from_list( · 50 unmodified lines
51 let mut index = gix::index::State::new(object_hash);51 let mut index = gix::index::State::new(object_hash);
52 for path in std::io::BufReader::new(std::fs::File::open(entries_file)?).lines() {52 for path in std::io::BufReader::new(std::fs::File::open(entries_file)?).lines() {
53 let path: PathBuf = path?.into();53 let path: PathBuf = path?.into();
54 #[allow(clippy::unnecessary_debug_formatting)]
54 if !path.is_relative() {55 if !path.is_relative() {
55 bail!("Input paths need to be relative, but {path:?} is not.")56 bail!("Input paths need to be relative, but {path:?} is not.")
56 }57 }