summaryrefslogtreecommitdiffstats
path: root/vendor/gix-credentials/src
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:36 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:36 +0000
commite02c5b5930c2c9ba3e5423fe12e2ef0155017297 (patch)
treefd60ebbbb5299e16e5fca8c773ddb74f764760db /vendor/gix-credentials/src
parentAdding debian version 1.73.0+dfsg1-1. (diff)
downloadrustc-e02c5b5930c2c9ba3e5423fe12e2ef0155017297.tar.xz
rustc-e02c5b5930c2c9ba3e5423fe12e2ef0155017297.zip
Merging upstream version 1.74.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/gix-credentials/src')
-rw-r--r--vendor/gix-credentials/src/helper/invoke.rs7
-rw-r--r--vendor/gix-credentials/src/program/mod.rs42
-rw-r--r--vendor/gix-credentials/src/protocol/context/serde.rs9
3 files changed, 31 insertions, 27 deletions
diff --git a/vendor/gix-credentials/src/helper/invoke.rs b/vendor/gix-credentials/src/helper/invoke.rs
index 563f3b2ff..e5662f4ca 100644
--- a/vendor/gix-credentials/src/helper/invoke.rs
+++ b/vendor/gix-credentials/src/helper/invoke.rs
@@ -4,7 +4,7 @@ use crate::helper::{Action, Context, Error, NextAction, Outcome, Result};
impl Action {
/// Send ourselves to the given `write` which is expected to be credentials-helper compatible
- pub fn send(&self, mut write: impl std::io::Write) -> std::io::Result<()> {
+ pub fn send(&self, write: &mut dyn std::io::Write) -> std::io::Result<()> {
match self {
Action::Get(ctx) => ctx.write_to(write),
Action::Store(last) | Action::Erase(last) => {
@@ -40,11 +40,12 @@ pub fn invoke(helper: &mut crate::Program, action: &Action) -> Result {
}
pub(crate) fn raw(helper: &mut crate::Program, action: &Action) -> std::result::Result<Option<Vec<u8>>, Error> {
- let (stdin, stdout) = helper.start(action)?;
+ let (mut stdin, stdout) = helper.start(action)?;
if let (Action::Get(_), None) = (&action, &stdout) {
panic!("BUG: `Helper` impls must return an output handle to read output from if Action::Get is provided")
}
- action.send(stdin)?;
+ action.send(&mut stdin)?;
+ drop(stdin);
let stdout = stdout
.map(|mut stdout| {
let mut buf = Vec::new();
diff --git a/vendor/gix-credentials/src/program/mod.rs b/vendor/gix-credentials/src/program/mod.rs
index e13e0a5ec..801466018 100644
--- a/vendor/gix-credentials/src/program/mod.rs
+++ b/vendor/gix-credentials/src/program/mod.rs
@@ -39,29 +39,31 @@ impl Program {
/// Parse the given input as per the custom helper definition, supporting `!<script>`, `name` and `/absolute/name`, the latter two
/// also support arguments which are ignored here.
pub fn from_custom_definition(input: impl Into<BString>) -> Self {
- let mut input = input.into();
- let kind = if input.starts_with(b"!") {
- input.remove(0);
- Kind::ExternalShellScript(input)
- } else {
- let path = gix_path::from_bstr(
- input
- .find_byte(b' ')
- .map_or(input.as_slice(), |pos| &input[..pos])
- .as_bstr(),
- );
- if gix_path::is_absolute(path) {
- Kind::ExternalPath { path_and_args: input }
+ fn from_custom_definition_inner(mut input: BString) -> Program {
+ let kind = if input.starts_with(b"!") {
+ input.remove(0);
+ Kind::ExternalShellScript(input)
} else {
- input.insert_str(0, "git credential-");
- Kind::ExternalName { name_and_args: input }
+ let path = gix_path::from_bstr(
+ input
+ .find_byte(b' ')
+ .map_or(input.as_slice(), |pos| &input[..pos])
+ .as_bstr(),
+ );
+ if gix_path::is_absolute(path) {
+ Kind::ExternalPath { path_and_args: input }
+ } else {
+ input.insert_str(0, "git credential-");
+ Kind::ExternalName { name_and_args: input }
+ }
+ };
+ Program {
+ kind,
+ child: None,
+ stderr: true,
}
- };
- Program {
- kind,
- child: None,
- stderr: true,
}
+ from_custom_definition_inner(input.into())
}
}
diff --git a/vendor/gix-credentials/src/protocol/context/serde.rs b/vendor/gix-credentials/src/protocol/context/serde.rs
index f713cbf4c..0f3b4b024 100644
--- a/vendor/gix-credentials/src/protocol/context/serde.rs
+++ b/vendor/gix-credentials/src/protocol/context/serde.rs
@@ -74,7 +74,10 @@ pub mod decode {
let mut ctx = Context::default();
for res in input.lines().take_while(|line| !line.is_empty()).map(|line| {
let mut it = line.splitn(2, |b| *b == b'=');
- match (it.next().and_then(|k| k.to_str().ok()), it.next().map(|v| v.as_bstr())) {
+ match (
+ it.next().and_then(|k| k.to_str().ok()),
+ it.next().map(ByteSlice::as_bstr),
+ ) {
(Some(key), Some(value)) => validate(key, value)
.map(|_| (key, value.to_owned()))
.map_err(Into::into),
@@ -99,9 +102,7 @@ pub mod decode {
"url" => ctx.url = Some(value),
"path" => ctx.path = Some(value),
"quit" => {
- ctx.quit = gix_config_value::Boolean::try_from(value.as_ref())
- .ok()
- .map(|b| b.into());
+ ctx.quit = gix_config_value::Boolean::try_from(value.as_ref()).ok().map(Into::into);
}
_ => {}
}