Skip to content

Commit 7e8aedf

Browse files
committed
minor refactors
1 parent 5a803b3 commit 7e8aedf

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

tests/it/src/commands/check_mode.rs

+9-12
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@ pub(super) mod function {
1818
.context("Can't start `git` subprocess to list index")?;
1919

2020
let stdout = child.stdout.take().expect("should have captured stdout");
21-
for result in BufReader::new(stdout).split(b'\0') {
21+
for result in BufReader::new(stdout).split(0) {
2222
let record = result.context(r"Can't read '\0'-terminated record")?;
23-
if check_for_mismatch(&root, &record)? {
24-
any_mismatch = true;
25-
}
23+
any_mismatch |= check_for_mismatch(&root, &record)?;
2624
}
2725

2826
let status = child.wait().context("Failure running `git` subprocess to list index")?;
@@ -37,7 +35,7 @@ pub(super) mod function {
3735

3836
/// Find the top-level directory of the current repository working tree.
3937
fn find_root() -> anyhow::Result<OsString> {
40-
let output = Command::new("git")
38+
let output = Command::new(gix::path::env::exe_invocation())
4139
.args(["rev-parse", "--show-toplevel"])
4240
.output()
4341
.context("Can't run `git` to find worktree root")?;
@@ -52,7 +50,6 @@ pub(super) mod function {
5250
.context("Can't parse worktree root")?
5351
.to_os_str()?
5452
.to_owned();
55-
5653
Ok(root)
5754
}
5855

@@ -62,18 +59,18 @@ pub(super) mod function {
6259
/// where `git -C` will be able to use it, without alteration, regardless of the platform.
6360
/// (Otherwise, it may be preferable to set `root` as the `cwd` of the `git` process instead.)
6461
fn git_on(root: &OsStr) -> Command {
65-
let mut cmd = Command::new("git");
62+
let mut cmd = Command::new(gix::path::env::exe_invocation());
6663
cmd.arg("-C").arg(root);
6764
cmd
6865
}
6966

70-
static RECORD_REGEX: Lazy<Regex> = Lazy::new(|| {
71-
let pattern = r"(?-u)\A([0-7]+) ([[:xdigit:]]+) [[:digit:]]+\t(.+)\z";
72-
Regex::new(pattern).expect("regex should be valid")
73-
});
74-
7567
/// On mismatch, report it and return `Some(true)`.
7668
fn check_for_mismatch(root: &OsStr, record: &[u8]) -> anyhow::Result<bool> {
69+
static RECORD_REGEX: Lazy<Regex> = Lazy::new(|| {
70+
let pattern = r"(?-u)\A([0-7]+) ([[:xdigit:]]+) [[:digit:]]+\t(.+)\z";
71+
Regex::new(pattern).expect("regex should be valid")
72+
});
73+
7774
let fields = RECORD_REGEX.captures(record).context("Malformed record from `git`")?;
7875
let mode = fields.get(1).expect("match should get mode").as_bytes();
7976
let oid = fields

0 commit comments

Comments
 (0)