@@ -19,7 +19,7 @@ pub(crate) mod function {
19
19
use gix:: odb:: FindExt ;
20
20
use gix:: Progress ;
21
21
22
- use crate :: repository:: attributes:: query:: attributes_cache;
22
+ use crate :: repository:: attributes:: query:: { attributes_cache, index_on_demand } ;
23
23
use crate :: repository:: attributes:: validate_baseline:: Options ;
24
24
use crate :: OutputFormat ;
25
25
@@ -32,21 +32,30 @@ pub(crate) mod function {
32
32
Options {
33
33
format,
34
34
statistics,
35
- ignore,
35
+ mut ignore,
36
36
} : Options ,
37
37
) -> anyhow:: Result < ( ) > {
38
38
if format != OutputFormat :: Human {
39
39
bail ! ( "JSON output isn't implemented yet" ) ;
40
40
}
41
41
42
+ if repo. is_bare ( ) {
43
+ writeln ! (
44
+ err,
45
+ "Repo {:?} is bare - disabling git-ignore baseline as `git check-ignore` needs a worktree" ,
46
+ repo. path( )
47
+ )
48
+ . ok ( ) ;
49
+ ignore = false ;
50
+ }
42
51
let mut num_entries = None ;
43
52
let pathspecs = pathspecs
44
53
. map ( |i| anyhow:: Result :: Ok ( Box :: new ( i) as Box < dyn Iterator < Item = gix:: path:: Spec > + Send + ' static > ) )
45
54
. unwrap_or_else ( {
46
55
let repo = repo. clone ( ) ;
47
56
let num_entries = & mut num_entries;
48
57
move || -> anyhow:: Result < _ > {
49
- let index = repo. open_index ( ) ? ;
58
+ let index = index_on_demand ( & repo) ? . into_owned ( ) ;
50
59
let ( entries, path_backing) = index. into_parts ( ) . 0 . into_entries ( ) ;
51
60
* num_entries = Some ( entries. len ( ) ) ;
52
61
Ok ( Box :: new ( entries. into_iter ( ) . map ( move |e| {
@@ -55,15 +64,11 @@ pub(crate) mod function {
55
64
}
56
65
} ) ?;
57
66
58
- let work_dir = repo
59
- . work_dir ( )
60
- . map ( ToOwned :: to_owned)
61
- . ok_or_else ( || anyhow ! ( "repository at {:?} must have a worktree checkout" , repo. path( ) ) ) ?;
62
67
let ( tx_base, rx_base) = std:: sync:: mpsc:: channel :: < ( String , Baseline ) > ( ) ;
63
68
let feed_attrs = {
64
69
let ( tx, rx) = std:: sync:: mpsc:: sync_channel :: < gix:: path:: Spec > ( 1 ) ;
65
70
std:: thread:: spawn ( {
66
- let path = work_dir . clone ( ) ;
71
+ let path = repo . path ( ) . to_owned ( ) ;
67
72
let tx_base = tx_base. clone ( ) ;
68
73
let mut progress = progress. add_child ( "attributes" ) ;
69
74
move || -> anyhow:: Result < ( ) > {
@@ -106,10 +111,17 @@ pub(crate) mod function {
106
111
} ) ;
107
112
tx
108
113
} ;
114
+ let work_dir = ignore
115
+ . then ( || {
116
+ repo. work_dir ( )
117
+ . map ( ToOwned :: to_owned)
118
+ . ok_or_else ( || anyhow ! ( "repository at {:?} must have a worktree checkout" , repo. path( ) ) )
119
+ } )
120
+ . transpose ( ) ?;
109
121
let feed_excludes = ignore. then ( || {
110
122
let ( tx, rx) = std:: sync:: mpsc:: sync_channel :: < gix:: path:: Spec > ( 1 ) ;
111
123
std:: thread:: spawn ( {
112
- let path = work_dir. clone ( ) ;
124
+ let path = work_dir. expect ( "present if we are here" ) ;
113
125
let tx_base = tx_base. clone ( ) ;
114
126
let mut progress = progress. add_child ( "excludes" ) ;
115
127
move || -> anyhow:: Result < ( ) > {
@@ -239,7 +251,7 @@ pub(crate) mod function {
239
251
}
240
252
bail ! (
241
253
"{}: Validation failed with {} mismatches out of {}" ,
242
- gix:: path:: realpath( & work_dir) . unwrap_or( work_dir ) . display( ) ,
254
+ gix:: path:: realpath( repo . work_dir( ) . unwrap_or( repo . git_dir ( ) ) ) ? . display( ) ,
243
255
mismatches. len( ) ,
244
256
progress
245
257
. counter( )
0 commit comments