1
1
use anyhow:: bail;
2
2
use gix:: bstr:: { BStr , BString , ByteSlice } ;
3
- use gix:: status:: index_worktree:: Item ;
3
+ use gix:: status:: { self , index_worktree} ;
4
4
use gix_status:: index_as_worktree:: { Change , Conflict , EntryStatus } ;
5
5
use std:: path:: Path ;
6
6
@@ -109,21 +109,54 @@ pub fn show(
109
109
}
110
110
None => gix:: status:: Submodule :: AsConfigured { check_dirty : false } ,
111
111
} )
112
- . into_index_worktree_iter ( pathspecs) ?;
112
+ . into_iter ( pathspecs) ?;
113
113
114
114
for item in iter. by_ref ( ) {
115
115
let item = item?;
116
116
match item {
117
- Item :: Modification {
117
+ status:: Item :: TreeIndex ( change) => {
118
+ let ( location, _, _, _) = change. fields ( ) ;
119
+ let status = match change {
120
+ gix:: diff:: index:: Change :: Addition { .. } => "A" ,
121
+ gix:: diff:: index:: Change :: Deletion { .. } => "D" ,
122
+ gix:: diff:: index:: Change :: Modification { .. } => "M" ,
123
+ gix:: diff:: index:: Change :: Rewrite {
124
+ ref source_location, ..
125
+ } => {
126
+ let source_location = gix:: path:: from_bstr ( source_location. as_ref ( ) ) ;
127
+ let source_location = gix:: path:: relativize_with_prefix ( & source_location, prefix) ;
128
+ writeln ! (
129
+ out,
130
+ "{status: >2} {source_rela_path} → {dest_rela_path}" ,
131
+ status = "R" ,
132
+ source_rela_path = source_location. display( ) ,
133
+ dest_rela_path =
134
+ gix:: path:: relativize_with_prefix( & gix:: path:: from_bstr( location) , prefix) . display( ) ,
135
+ ) ?;
136
+ continue ;
137
+ }
138
+ gix:: diff:: index:: Change :: Unmerged { .. } => {
139
+ // Unmerged entries from the worktree-index are displayed as part of the index-worktree comparison.
140
+ // Here we have nothing to do with them and can ignore.
141
+ continue ;
142
+ }
143
+ } ;
144
+ writeln ! (
145
+ out,
146
+ "{status: >2} {rela_path}" ,
147
+ rela_path = gix:: path:: relativize_with_prefix( & gix:: path:: from_bstr( location) , prefix) . display( ) ,
148
+ ) ?;
149
+ }
150
+ status:: Item :: IndexWorktree ( index_worktree:: Item :: Modification {
118
151
entry : _,
119
152
entry_index : _,
120
153
rela_path,
121
154
status,
122
- } => print_index_entry_status ( & mut out, prefix, rela_path. as_ref ( ) , status) ?,
123
- Item :: DirectoryContents {
155
+ } ) => print_index_entry_status ( & mut out, prefix, rela_path. as_ref ( ) , status) ?,
156
+ status :: Item :: IndexWorktree ( index_worktree :: Item :: DirectoryContents {
124
157
entry,
125
158
collapsed_directory_status,
126
- } => {
159
+ } ) => {
127
160
if collapsed_directory_status. is_none ( ) {
128
161
writeln ! (
129
162
out,
@@ -139,12 +172,12 @@ pub fn show(
139
172
) ?;
140
173
}
141
174
}
142
- Item :: Rewrite {
175
+ status :: Item :: IndexWorktree ( index_worktree :: Item :: Rewrite {
143
176
source,
144
177
dirwalk_entry,
145
178
copy : _, // TODO: how to visualize copies?
146
179
..
147
- } => {
180
+ } ) => {
148
181
// TODO: handle multi-status characters, there can also be modifications at the same time as determined by their ID and potentially diffstats.
149
182
writeln ! (
150
183
out,
@@ -175,9 +208,8 @@ pub fn show(
175
208
writeln ! ( err, "{outcome:#?}" , outcome = out. index_worktree) . ok ( ) ;
176
209
}
177
210
178
- writeln ! ( err, "\n head -> index isn't implemented yet" ) ?;
179
- progress. init ( Some ( out. index . entries ( ) . len ( ) ) , gix:: progress:: count ( "files" ) ) ;
180
- progress. set ( out. index . entries ( ) . len ( ) ) ;
211
+ progress. init ( Some ( out. worktree_index . entries ( ) . len ( ) ) , gix:: progress:: count ( "files" ) ) ;
212
+ progress. set ( out. worktree_index . entries ( ) . len ( ) ) ;
181
213
progress. show_throughput ( start) ;
182
214
Ok ( ( ) )
183
215
}
0 commit comments