1
1
use anyhow:: { bail, Context } ;
2
+ use gix:: bstr:: ByteSlice ;
2
3
use gix:: {
3
4
bstr:: { BStr , BString } ,
4
5
index:: Entry ,
@@ -46,7 +47,7 @@ pub fn show(
46
47
let mut index = repo. index_or_empty ( ) ?;
47
48
let index = gix:: threading:: make_mut ( & mut index) ;
48
49
let pathspec = repo. pathspec (
49
- pathspecs,
50
+ pathspecs. iter ( ) . map ( |p| p . as_bstr ( ) ) ,
50
51
true ,
51
52
index,
52
53
gix:: worktree:: stack:: state:: attributes:: Source :: WorktreeThenIdMapping ,
@@ -74,23 +75,67 @@ pub fn show(
74
75
out,
75
76
changes : Vec :: new ( ) ,
76
77
} ;
77
- let outcome = gix_status:: index_as_worktree (
78
- index,
79
- repo. work_dir ( )
80
- . context ( "This operation cannot be run on a bare repository" ) ?,
81
- & mut printer,
82
- FastEq ,
83
- Submodule ,
84
- repo. objects . clone ( ) . into_arc ( ) ?,
85
- & mut progress,
86
- pathspec. detach ( ) ?,
87
- repo. filter_pipeline ( Some ( gix:: hash:: ObjectId :: empty_tree ( repo. object_hash ( ) ) ) ) ?
88
- . 0
89
- . into_parts ( )
90
- . 0 ,
91
- & gix:: interrupt:: IS_INTERRUPTED ,
92
- options,
93
- ) ?;
78
+ let filter_pipeline = repo
79
+ . filter_pipeline ( Some ( gix:: hash:: ObjectId :: empty_tree ( repo. object_hash ( ) ) ) ) ?
80
+ . 0
81
+ . into_parts ( )
82
+ . 0 ;
83
+
84
+ let mut collect = gix:: dir:: walk:: delegate:: Collect :: default ( ) ;
85
+ let ( outcome, walk_outcome) = gix:: features:: parallel:: threads ( |scope| -> anyhow:: Result < _ > {
86
+ // TODO: it's either this, or not running both in parallel and setting UPTODATE flags whereever
87
+ // there is no modification. This can save disk queries as dirwalk can then trust what's in
88
+ // the index regarding the type.
89
+ // NOTE: collect here as rename-tracking needs that anyway.
90
+ let walk_outcome = gix:: features:: parallel:: build_thread ( )
91
+ . name ( "gix status::dirwalk" . into ( ) )
92
+ . spawn_scoped ( scope, {
93
+ let repo = repo. clone ( ) . into_sync ( ) ;
94
+ let index = & index;
95
+ let collect = & mut collect;
96
+ move || {
97
+ let repo = repo. to_thread_local ( ) ;
98
+ repo. dirwalk (
99
+ index,
100
+ pathspecs,
101
+ repo. dirwalk_options ( ) ?
102
+ . emit_untracked ( gix:: dir:: walk:: EmissionMode :: CollapseDirectory ) ,
103
+ collect,
104
+ )
105
+ }
106
+ } ) ?;
107
+
108
+ let outcome = gix_status:: index_as_worktree (
109
+ index,
110
+ repo. work_dir ( )
111
+ . context ( "This operation cannot be run on a bare repository" ) ?,
112
+ & mut printer,
113
+ FastEq ,
114
+ Submodule ,
115
+ repo. objects . clone ( ) . into_arc ( ) ?,
116
+ & mut progress,
117
+ pathspec. detach ( ) ?,
118
+ filter_pipeline,
119
+ & gix:: interrupt:: IS_INTERRUPTED ,
120
+ options,
121
+ ) ?;
122
+
123
+ let walk_outcome = walk_outcome. join ( ) . expect ( "no panic" ) ?;
124
+ Ok ( ( outcome, walk_outcome) )
125
+ } ) ?;
126
+
127
+ for entry in collect
128
+ . into_entries_by_path ( )
129
+ . into_iter ( )
130
+ . filter_map ( |( entry, dir_status) | dir_status. is_none ( ) . then_some ( entry) )
131
+ {
132
+ writeln ! (
133
+ printer. out,
134
+ "{status: >3} {rela_path}" ,
135
+ status = "?" ,
136
+ rela_path = entry. rela_path
137
+ ) ?;
138
+ }
94
139
95
140
if outcome. entries_to_update != 0 && allow_write {
96
141
{
@@ -115,6 +160,7 @@ pub fn show(
115
160
116
161
if statistics {
117
162
writeln ! ( err, "{outcome:#?}" ) . ok ( ) ;
163
+ writeln ! ( err, "{walk_outcome:#?}" ) . ok ( ) ;
118
164
}
119
165
120
166
writeln ! ( err, "\n head -> index and untracked files aren't implemented yet" ) ?;
0 commit comments