@@ -186,6 +186,37 @@ mod open {
186186 Ok ( ( ) )
187187 }
188188
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+
189220 #[ test]
190221 fn modified_and_untracked ( ) -> crate :: Result {
191222 let repo = repo ( "modified-and-untracked" ) ?;
@@ -194,7 +225,7 @@ mod open {
194225 let status = sm. status ( gix:: submodule:: config:: Ignore :: Dirty , false ) ?;
195226 assert_eq ! ( status. is_dirty( ) , Some ( false ) , "Dirty skips worktree changes entirely" ) ;
196227
197- let status = sm. status_opts (
228+ let mut status = sm. status_opts (
198229 gix:: submodule:: config:: Ignore :: None ,
199230 false ,
200231 & mut |status : gix:: status:: Platform < ' _ , gix:: progress:: Discard > | {
@@ -217,16 +248,18 @@ mod open {
217248
218249 let status_with_dirty_check = sm. status_opts (
219250 gix:: submodule:: config:: Ignore :: None ,
220- true ,
251+ true , /* check-dirty */
221252 & mut |status : gix:: status:: Platform < ' _ , gix:: progress:: Discard > | {
222253 status. index_worktree_options_mut ( |opts| {
223254 opts. sorting = Some ( gix_status:: index_as_worktree_with_renames:: Sorting :: ByPathCaseSensitive ) ;
224255 } )
225256 } ,
226257 ) ?;
258+ status. changes . as_mut ( ) . expect ( "two changes" ) . pop ( ) ;
227259 assert_eq ! (
228260 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"
230263 ) ;
231264
232265 let status = sm. status ( gix:: submodule:: config:: Ignore :: Untracked , false ) ?;
0 commit comments