File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -36,6 +36,14 @@ git init untracked-unborn
3636 touch untracked
3737)
3838
39+ git init added-unborn
40+ (cd added-unborn
41+ echo content > added
42+ mkdir dir
43+ echo content > dir/nested
44+ git add added dir/nested
45+ )
46+
3947git init untracked-added
4048(cd untracked-added
4149 echo content > added
Original file line number Diff line number Diff line change @@ -241,6 +241,40 @@ mod into_iter {
241241 Ok ( ( ) )
242242 }
243243
244+ #[ test]
245+ fn added_unborn ( ) -> crate :: Result {
246+ let repo = repo ( "added-unborn" ) ?;
247+ let mut status = repo. status ( gix:: progress:: Discard ) ?. into_iter ( None ) ?;
248+ let mut items: Vec < _ > = status. by_ref ( ) . filter_map ( Result :: ok) . collect ( ) ;
249+ items. sort_by ( |a, b| a. location ( ) . cmp ( b. location ( ) ) ) ;
250+ let snapshot = gix_testtools:: normalize_debug_snapshot ( & items) . 0 ;
251+ insta:: assert_snapshot!( snapshot, @r#"
252+ [
253+ TreeIndex(
254+ Addition {
255+ location: "added",
256+ index: 0,
257+ entry_mode: Mode(
258+ FILE,
259+ ),
260+ id: Oid(1),
261+ },
262+ ),
263+ TreeIndex(
264+ Addition {
265+ location: "dir/nested",
266+ index: 1,
267+ entry_mode: Mode(
268+ FILE,
269+ ),
270+ id: Oid(1),
271+ },
272+ ),
273+ ]
274+ "# ) ;
275+ Ok ( ( ) )
276+ }
277+
244278 #[ test]
245279 fn untracked_added ( ) -> crate :: Result {
246280 let repo = repo ( "untracked-added" ) ?;
@@ -529,6 +563,17 @@ mod is_dirty {
529563 Ok ( ( ) )
530564 }
531565
566+ #[ test]
567+ fn added_files_in_unborn_head_are_dirty ( ) -> crate :: Result {
568+ let repo = repo ( "added-unborn" ) ?;
569+
570+ assert ! (
571+ repo. is_dirty( ) ?,
572+ "files added to the index make an unborn repository dirty"
573+ ) ;
574+ Ok ( ( ) )
575+ }
576+
532577 #[ test]
533578 fn index_changed ( ) -> crate :: Result {
534579 let repo = repo ( "git-mv" ) ?;
You can’t perform that action at this time.
0 commit comments