File tree Expand file tree Collapse file tree 4 files changed +45
-0
lines changed Expand file tree Collapse file tree 4 files changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -323,6 +323,9 @@ pub mod status {
323323 /// Return the status of the submodule, just like [`status`](Self::status), but allows to adjust options
324324 /// for more control over how the status is performed.
325325 ///
326+ /// If `check_dirty` is `true`, the computation will stop once the first in a ladder operations
327+ /// ordered from cheap to expensive shows that the submodule is dirty.
328+ ///
326329 /// Use `&mut std::convert::identity` for `adjust_options` if no specific options are desired.
327330 /// A reason to change them might be to enable sorting to enjoy deterministic order of changes.
328331 ///
Original file line number Diff line number Diff line change @@ -21,6 +21,17 @@ git init submodule-head-changed
2121 cd m1 && git checkout @~1
2222)
2323
24+ git init submodule-index-changed
25+ (cd submodule-index-changed
26+ git submodule add ../module1 m1
27+ git commit -m " add submodule"
28+
29+ (cd m1
30+ git mv subdir subdir-renamed
31+ git mv this that
32+ )
33+ )
34+
2435git init submodule-head-changed-no-worktree
2536(cd submodule-head-changed-no-worktree
2637 git submodule add ../module1 m1
Original file line number Diff line number Diff line change @@ -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 { 2 } ,
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" ) ?;
You can’t perform that action at this time.
0 commit comments