@@ -18,11 +18,9 @@ pub(super) mod function {
18
18
. context ( "Can't start `git` subprocess to list index" ) ?;
19
19
20
20
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 ) {
22
22
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) ?;
26
24
}
27
25
28
26
let status = child. wait ( ) . context ( "Failure running `git` subprocess to list index" ) ?;
@@ -37,7 +35,7 @@ pub(super) mod function {
37
35
38
36
/// Find the top-level directory of the current repository working tree.
39
37
fn find_root ( ) -> anyhow:: Result < OsString > {
40
- let output = Command :: new ( "git" )
38
+ let output = Command :: new ( gix :: path :: env :: exe_invocation ( ) )
41
39
. args ( [ "rev-parse" , "--show-toplevel" ] )
42
40
. output ( )
43
41
. context ( "Can't run `git` to find worktree root" ) ?;
@@ -52,7 +50,6 @@ pub(super) mod function {
52
50
. context ( "Can't parse worktree root" ) ?
53
51
. to_os_str ( ) ?
54
52
. to_owned ( ) ;
55
-
56
53
Ok ( root)
57
54
}
58
55
@@ -62,18 +59,18 @@ pub(super) mod function {
62
59
/// where `git -C` will be able to use it, without alteration, regardless of the platform.
63
60
/// (Otherwise, it may be preferable to set `root` as the `cwd` of the `git` process instead.)
64
61
fn git_on ( root : & OsStr ) -> Command {
65
- let mut cmd = Command :: new ( "git" ) ;
62
+ let mut cmd = Command :: new ( gix :: path :: env :: exe_invocation ( ) ) ;
66
63
cmd. arg ( "-C" ) . arg ( root) ;
67
64
cmd
68
65
}
69
66
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
-
75
67
/// On mismatch, report it and return `Some(true)`.
76
68
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
+
77
74
let fields = RECORD_REGEX . captures ( record) . context ( "Malformed record from `git`" ) ?;
78
75
let mode = fields. get ( 1 ) . expect ( "match should get mode" ) . as_bytes ( ) ;
79
76
let oid = fields
0 commit comments