@@ -186,6 +186,37 @@ mod open {
186
186
Ok ( ( ) )
187
187
}
188
188
189
+ #[ test]
190
+ fn modified_in_index_only ( ) -> crate :: Result {
191
+ let repo = repo ( "submodule-index-changed" ) ?;
192
+ let sm = repo. submodules ( ) ?. into_iter ( ) . flatten ( ) . next ( ) . expect ( "one submodule" ) ;
193
+
194
+ for mode in [
195
+ gix:: submodule:: config:: Ignore :: Untracked ,
196
+ gix:: submodule:: config:: Ignore :: None ,
197
+ ] {
198
+ for check_dirty in [ false , true ] {
199
+ let status = sm. status_opts ( mode, check_dirty, & mut |platform| platform) ?;
200
+ assert_eq ! (
201
+ status. is_dirty( ) ,
202
+ Some ( true ) ,
203
+ "two files were renamed using `git mv` for an HEAD^{{tree}}-index change"
204
+ ) ;
205
+ assert_eq ! (
206
+ status. changes. expect( "present" ) . len( ) ,
207
+ if check_dirty { 1 } else { 3 } ,
208
+ "in is-dirty mode, we don't collect all changes"
209
+ ) ;
210
+ }
211
+ }
212
+
213
+ assert ! (
214
+ repo. is_dirty( ) ?,
215
+ "superproject should see submodule changes in the index as well"
216
+ ) ;
217
+ Ok ( ( ) )
218
+ }
219
+
189
220
#[ test]
190
221
fn modified_and_untracked ( ) -> crate :: Result {
191
222
let repo = repo ( "modified-and-untracked" ) ?;
@@ -194,7 +225,7 @@ mod open {
194
225
let status = sm. status ( gix:: submodule:: config:: Ignore :: Dirty , false ) ?;
195
226
assert_eq ! ( status. is_dirty( ) , Some ( false ) , "Dirty skips worktree changes entirely" ) ;
196
227
197
- let status = sm. status_opts (
228
+ let mut status = sm. status_opts (
198
229
gix:: submodule:: config:: Ignore :: None ,
199
230
false ,
200
231
& mut |status : gix:: status:: Platform < ' _ , gix:: progress:: Discard > | {
@@ -217,16 +248,18 @@ mod open {
217
248
218
249
let status_with_dirty_check = sm. status_opts (
219
250
gix:: submodule:: config:: Ignore :: None ,
220
- true ,
251
+ true , /* check-dirty */
221
252
& mut |status : gix:: status:: Platform < ' _ , gix:: progress:: Discard > | {
222
253
status. index_worktree_options_mut ( |opts| {
223
254
opts. sorting = Some ( gix_status:: index_as_worktree_with_renames:: Sorting :: ByPathCaseSensitive ) ;
224
255
} )
225
256
} ,
226
257
) ?;
258
+ status. changes . as_mut ( ) . expect ( "two changes" ) . pop ( ) ;
227
259
assert_eq ! (
228
260
status_with_dirty_check, status,
229
- "it cannot abort early as the only change it sees is the modification check"
261
+ "it cannot abort early as the only change it sees is the modification check.\
262
+ However, with check-dirty, it would only gather the changes"
230
263
) ;
231
264
232
265
let status = sm. status ( gix:: submodule:: config:: Ignore :: Untracked , false ) ?;
0 commit comments