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,53 @@ 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
+ // TODO: should this be displayed? How to prevent double-display?
140
+ continue ;
141
+ }
142
+ } ;
143
+ writeln ! (
144
+ out,
145
+ "{status: >2} {rela_path}" ,
146
+ rela_path = gix:: path:: relativize_with_prefix( & gix:: path:: from_bstr( location) , prefix) . display( ) ,
147
+ ) ?;
148
+ }
149
+ status:: Item :: IndexWorktree ( index_worktree:: Item :: Modification {
118
150
entry : _,
119
151
entry_index : _,
120
152
rela_path,
121
153
status,
122
- } => print_index_entry_status ( & mut out, prefix, rela_path. as_ref ( ) , status) ?,
123
- Item :: DirectoryContents {
154
+ } ) => print_index_entry_status ( & mut out, prefix, rela_path. as_ref ( ) , status) ?,
155
+ status :: Item :: IndexWorktree ( index_worktree :: Item :: DirectoryContents {
124
156
entry,
125
157
collapsed_directory_status,
126
- } => {
158
+ } ) => {
127
159
if collapsed_directory_status. is_none ( ) {
128
160
writeln ! (
129
161
out,
@@ -139,12 +171,12 @@ pub fn show(
139
171
) ?;
140
172
}
141
173
}
142
- Item :: Rewrite {
174
+ status :: Item :: IndexWorktree ( index_worktree :: Item :: Rewrite {
143
175
source,
144
176
dirwalk_entry,
145
177
copy : _, // TODO: how to visualize copies?
146
178
..
147
- } => {
179
+ } ) => {
148
180
// TODO: handle multi-status characters, there can also be modifications at the same time as determined by their ID and potentially diffstats.
149
181
writeln ! (
150
182
out,
@@ -175,9 +207,8 @@ pub fn show(
175
207
writeln ! ( err, "{outcome:#?}" , outcome = out. index_worktree) . ok ( ) ;
176
208
}
177
209
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 ( ) ) ;
210
+ progress. init ( Some ( out. worktree_index . entries ( ) . len ( ) ) , gix:: progress:: count ( "files" ) ) ;
211
+ progress. set ( out. worktree_index . entries ( ) . len ( ) ) ;
181
212
progress. show_throughput ( start) ;
182
213
Ok ( ( ) )
183
214
}
0 commit comments