Skip to content

Commit a0cc80d

Browse files
committed
remove special handling in favor of allowing shell-avoidance.
1 parent 05972f1 commit a0cc80d

File tree

12 files changed

+24
-32
lines changed

12 files changed

+24
-32
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gitoxide-core/src/pack/multi_index.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ pub fn entries(multi_index_path: PathBuf, format: OutputFormat, mut out: impl st
8282
if format != OutputFormat::Human {
8383
bail!("Only human format is supported right now");
8484
}
85-
let file = gix::odb::pack::multi_index::File::at(&multi_index_path)?;
85+
let file = gix::odb::pack::multi_index::File::at(multi_index_path)?;
8686
for entry in file.iter() {
8787
writeln!(out, "{} {} {}", entry.oid, entry.pack_index, entry.pack_offset)?;
8888
}

gitoxide-core/src/repository/exclude.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub fn query(
3838
let index = repo.index()?;
3939
let mut cache = repo.excludes(
4040
&index,
41-
Some(gix::ignore::Search::from_overrides(&mut overrides.into_iter())),
41+
Some(gix::ignore::Search::from_overrides(overrides.into_iter())),
4242
Default::default(),
4343
)?;
4444

gitoxide-core/src/repository/index/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub fn from_list(
4949
let object_hash = gix::hash::Kind::Sha1;
5050

5151
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() {
5353
let path: PathBuf = path?.into();
5454
if !path.is_relative() {
5555
bail!("Input paths need to be relative, but {path:?} is not.")

gix-attributes/tests/state/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ mod value {
1515
}
1616

1717
#[test]
18+
#[allow(invalid_from_utf8)]
1819
fn from_value() {
1920
assert!(std::str::from_utf8(ILLFORMED_UTF8).is_err());
2021
assert!(

gix-credentials/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ gix-trace = { version = "^0.1.3", path = "../gix-trace" }
2828
thiserror = "1.0.32"
2929
serde = { version = "1.0.114", optional = true, default-features = false, features = ["derive"] }
3030
bstr = { version = "1.3.0", default-features = false, features = ["std"]}
31-
shell-words = "1.0"
3231

3332

3433

gix-credentials/src/program/mod.rs

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -80,24 +80,10 @@ impl Program {
8080
args.insert_str(0, "credential-");
8181
args.insert_str(0, " ");
8282
args.insert_str(0, git_program);
83-
let split_args = if args.find_byteset(b"\\|&;<>()$`\n*?[#~%").is_none() {
84-
args.to_str()
85-
.ok()
86-
.and_then(|args| shell_words::split(args).ok().map(Vec::into_iter))
87-
} else {
88-
None
89-
};
90-
match split_args {
91-
Some(mut args) => {
92-
let mut cmd = Command::new(args.next().expect("non-empty input"));
93-
cmd.args(args).arg(action.as_arg(true));
94-
cmd
95-
}
96-
None => gix_command::prepare(gix_path::from_bstr(args.as_ref()).into_owned())
97-
.arg(action.as_arg(true))
98-
.with_shell()
99-
.into(),
100-
}
83+
gix_command::prepare(gix_path::from_bstr(args.as_ref()).into_owned())
84+
.arg(action.as_arg(true))
85+
.with_shell_allow_argument_splitting()
86+
.into()
10187
}
10288
Kind::ExternalShellScript(for_shell)
10389
| Kind::ExternalPath {

gix-credentials/tests/program/from_custom_definition.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,11 @@ fn path_with_args_that_definitely_need_shell() {
7373
assert!(matches!(&prog.kind, Kind::ExternalPath{path_and_args} if path_and_args == input));
7474
assert_eq!(
7575
format!("{:?}", prog.to_command(&helper::Action::Store("egal".into()))),
76-
format!(r#""{SH}" "-c" "/abs/name --arg --bar=\"a b\" \"$@\"" "--" "store""#)
76+
if cfg!(windows) {
77+
r#""/abs/name" "--arg" "--bar=a b" "store""#.to_owned()
78+
} else {
79+
format!(r#""{SH}" "-c" "/abs/name --arg --bar=\"a b\" \"$@\"" "--" "store""#)
80+
}
7781
);
7882
}
7983

@@ -96,7 +100,11 @@ fn path_with_simple_args() {
96100
assert!(matches!(&prog.kind, Kind::ExternalPath{path_and_args} if path_and_args == input));
97101
assert_eq!(
98102
format!("{:?}", prog.to_command(&helper::Action::Store("egal".into()))),
99-
format!(r#""{SH}" "-c" "/abs/name a b \"$@\"" "--" "store""#),
100-
"a shell is used as well because there are arguments, and we don't do splitting ourselves. On windows, this can be a problem."
103+
if cfg!(windows) {
104+
r#""/abs/name" "a" "b" "store""#.to_owned()
105+
} else {
106+
format!(r#""{SH}" "-c" "/abs/name a b \"$@\"" "--" "store""#)
107+
},
108+
"a shell is used as there are arguments, and it's generally more flexible, but on windows we split ourselves"
101109
);
102110
}

gix-index/src/extension/link.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ impl Link {
8181
.expect("split index file in .git folder")
8282
.join(format!("sharedindex.{}", self.shared_index_checksum));
8383
let mut shared_index = crate::File::at(
84-
&shared_index_path,
84+
shared_index_path,
8585
object_hash,
8686
skip_hash,
8787
crate::decode::Options {

gix-pack/tests/pack/index.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ mod version {
1919
#[test]
2020
fn lookup() -> Result<(), Box<dyn std::error::Error>> {
2121
let object_hash = gix_hash::Kind::Sha1;
22-
let file = index::File::at(&fixture_path(INDEX_V1), object_hash)?;
22+
let file = index::File::at(fixture_path(INDEX_V1), object_hash)?;
2323
for (id, desired_index, assertion) in &[
2424
(&b"036bd66fe9b6591e959e6df51160e636ab1a682e"[..], Some(0), "first"),
2525
(b"f7f791d96b9a34ef0f08db4b007c5309b9adc3d6", Some(65), "close to last"),
@@ -63,7 +63,7 @@ mod version {
6363
#[test]
6464
fn lookup() -> Result<(), Box<dyn std::error::Error>> {
6565
let object_hash = gix_hash::Kind::Sha1;
66-
let file = index::File::at(&fixture_path(INDEX_V2), object_hash)?;
66+
let file = index::File::at(fixture_path(INDEX_V2), object_hash)?;
6767
for (id, expected, assertion_message, hex_len) in [
6868
(&b"0ead45fc727edcf5cadca25ef922284f32bb6fc1"[..], Some(0), "first", 4),
6969
(b"e800b9c207e17f9b11e321cc1fba5dfe08af4222", Some(29), "last", 40),

gix/src/remote/connection/fetch/update_refs/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ mod update {
191191

192192
#[test]
193193
fn checked_out_branches_in_worktrees_are_rejected_with_additional_information() -> Result {
194-
let root = gix_path::realpath(&gix_testtools::scripted_fixture_read_only_with_args(
194+
let root = gix_path::realpath(gix_testtools::scripted_fixture_read_only_with_args(
195195
"make_fetch_repos.sh",
196196
[base_repo_path()],
197197
)?)?;

gix/tests/repository/shallow.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ mod traverse {
7171
#[test]
7272
#[parallel]
7373
fn complex_graphs_can_be_iterated_despite_multiple_shallow_boundaries() -> crate::Result {
74-
let base =
75-
gix_path::realpath(&gix_testtools::scripted_fixture_read_only("make_remote_repos.sh")?.join("base"))?;
74+
let base = gix_path::realpath(gix_testtools::scripted_fixture_read_only("make_remote_repos.sh")?.join("base"))?;
7675
let shallow_base = gix_testtools::scripted_fixture_read_only_with_args(
7776
"make_complex_shallow_repo.sh",
7877
Some(base.to_string_lossy()),

0 commit comments

Comments
 (0)