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
114114 };
115115 let work_dir = ignore
116116 .then(|| {
117+ #[allow(clippy::unnecessary_debug_formatting)]
117118 repo.workdir()
118119 .map(ToOwned::to_owned)
119120 .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
5151 let mut index = gix::index::State::new(object_hash);
5252 for path in std::io::BufReader::new(std::fs::File::open(entries_file)?).lines() {
5353 let path: PathBuf = path?.into();
54+ #[allow(clippy::unnecessary_debug_formatting)]
5455 if !path.is_relative() {
5556 bail!("Input paths need to be relative, but {path:?} is not.")
5657 }