@@ -245,6 +245,67 @@ fn root_may_be_a_symlink_if_it_is_the_worktree() -> crate::Result {
245245 Ok ( ( ) )
246246}
247247
248+ #[ test]
249+ #[ cfg( unix) ]
250+ fn assume_unchanged_submodule_replaced_with_symlink_is_hidden ( ) -> crate :: Result {
251+ let root = fixture_in ( "many-symlinks" , "submodule-assume-unchanged-symlink" ) ;
252+ let ( ( out, _root) , entries) = try_collect_filtered_opts_collect (
253+ & root,
254+ None ,
255+ |keep, ctx| walk ( & root, ctx, options ( ) , keep) ,
256+ None :: < & str > ,
257+ Options {
258+ fresh_index : false ,
259+ ..Default :: default ( )
260+ } ,
261+ ) ?;
262+
263+ assert_eq ! (
264+ out,
265+ walk:: Outcome {
266+ read_dir_calls: 1 ,
267+ returned_entries: entries. len( ) ,
268+ seen_entries: 3 ,
269+ }
270+ ) ;
271+ assert ! (
272+ entries. is_empty( ) ,
273+ "assume-unchanged entries should use index type information and stay hidden"
274+ ) ;
275+ Ok ( ( ) )
276+ }
277+
278+ #[ test]
279+ #[ cfg( unix) ]
280+ fn submodule_replaced_with_symlink_without_assume_unchanged_is_untracked ( ) -> crate :: Result {
281+ let root = fixture_in ( "many-symlinks" , "submodule-symlink" ) ;
282+ let ( ( out, _root) , entries) = try_collect_filtered_opts_collect (
283+ & root,
284+ None ,
285+ |keep, ctx| walk ( & root, ctx, options ( ) , keep) ,
286+ None :: < & str > ,
287+ Options {
288+ fresh_index : false ,
289+ ..Default :: default ( )
290+ } ,
291+ ) ?;
292+
293+ assert_eq ! (
294+ out,
295+ walk:: Outcome {
296+ read_dir_calls: 1 ,
297+ returned_entries: entries. len( ) ,
298+ seen_entries: 3 ,
299+ }
300+ ) ;
301+ assert_eq ! (
302+ entries,
303+ [ entry( "sub" , Untracked , Symlink ) . with_index_kind( Repository ) ] ,
304+ "without assume-unchanged, the replaced submodule appears as an untracked symlink"
305+ ) ;
306+ Ok ( ( ) )
307+ }
308+
248309#[ test]
249310fn should_interrupt_works_even_in_empty_directories ( ) {
250311 let root = fixture ( "empty" ) ;
0 commit comments