Skip to content

Commit

Permalink
fix: it's no error if credential helpers don't receive context as input.
Browse files Browse the repository at this point in the history
They might ignore all input and output hardcoded credentials for good reason,
so we don't validate writes to the helper similarly to how git does it.

Note that we also don't care if credentials are stored or erased for similar reasons.
I would happily make the case that we should be more adamant about error handling in that
case, but typically we check error codes and that's the only indicator for success or failure.

Related to rust-lang/cargo#11821
  • Loading branch information
Byron committed Mar 10, 2023
1 parent 7f6e67d commit ee1e269
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions gix-credentials/src/helper/invoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ impl Action {
match self {
Action::Get(ctx) => ctx.write_to(write),
Action::Store(last) | Action::Erase(last) => {
write.write_all(last)?;
write.write_all(&[b'\n'])
write.write_all(last).ok();
write.write_all(&[b'\n']).ok();
Ok(())
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions gix-credentials/src/protocol/context/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ mod write {
if let Some(value) = value {
validate(key, value.as_slice().into())
.map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err))?;
write_key(&mut out, key, value.as_ref())?;
write_key(&mut out, key, value.as_ref()).ok();
}
}
for (key, value) in [
Expand All @@ -33,7 +33,7 @@ mod write {
if let Some(value) = value {
validate(key, value.as_str().into())
.map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err))?;
write_key(&mut out, key, value.as_bytes().as_bstr())?;
write_key(&mut out, key, value.as_bytes().as_bstr()).ok();
}
}
Ok(())
Expand Down

0 comments on commit ee1e269

Please sign in to comment.