File tree Expand file tree Collapse file tree 5 files changed +57
-4
lines changed Expand file tree Collapse file tree 5 files changed +57
-4
lines changed Original file line number Diff line number Diff line change @@ -213,13 +213,21 @@ mod submodule_status {
213213 mode : Submodule ,
214214 ) -> Result < Self , crate :: submodule:: modules:: Error > {
215215 let local_repo = repo. to_thread_local ( ) ;
216- let submodule_paths = match local_repo. submodules ( ) ? {
217- Some ( sm) => {
216+ let submodule_paths = match local_repo. submodules ( ) {
217+ Ok ( Some ( sm) ) => {
218218 let mut v: Vec < _ > = sm. filter_map ( |sm| sm. path ( ) . ok ( ) . map ( Cow :: into_owned) ) . collect ( ) ;
219219 v. sort ( ) ;
220220 v
221221 }
222- None => Vec :: new ( ) ,
222+ Ok ( None ) => Vec :: new ( ) ,
223+ Err ( crate :: submodule:: modules:: Error :: FindHeadCommit (
224+ crate :: reference:: head_commit:: Error :: PeelToCommit (
225+ crate :: head:: peel:: to_commit:: Error :: PeelToObject (
226+ crate :: head:: peel:: to_object:: Error :: Unborn { .. } ,
227+ ) ,
228+ ) ,
229+ ) ) => Vec :: new ( ) ,
230+ Err ( err) => return Err ( err) ,
223231 } ;
224232 Ok ( Self {
225233 mode,
Original file line number Diff line number Diff line change 4545
4646 let obtain_tree_id = || -> Result < Option < gix_hash:: ObjectId > , crate :: status:: into_iter:: Error > {
4747 Ok ( match self . head_tree {
48- Some ( None ) => Some ( self . repo . head_tree_id ( ) ?. into ( ) ) ,
48+ Some ( None ) => match self . repo . head_tree_id ( ) {
49+ Ok ( id) => Some ( id. into ( ) ) ,
50+ Err ( crate :: reference:: head_tree_id:: Error :: HeadCommit (
51+ crate :: reference:: head_commit:: Error :: PeelToCommit (
52+ crate :: head:: peel:: to_commit:: Error :: PeelToObject (
53+ crate :: head:: peel:: to_object:: Error :: Unborn { .. } ,
54+ ) ,
55+ ) ,
56+ ) ) => None ,
57+ Err ( err) => return Err ( err. into ( ) ) ,
58+ } ,
4959 Some ( Some ( tree_id) ) => Some ( tree_id) ,
5060 None => None ,
5161 } )
Original file line number Diff line number Diff line change @@ -29,4 +29,9 @@ git init racy-git
2929
3030 echo ho > file && git add file
3131 echo ha > file
32+ )
33+
34+ git init untracked-unborn
35+ (cd untracked-unborn
36+ touch untracked
3237)
Original file line number Diff line number Diff line change @@ -83,6 +83,36 @@ mod into_iter {
8383 Ok ( ( ) )
8484 }
8585
86+ #[ test]
87+ fn untracked_unborn ( ) -> crate :: Result {
88+ let repo = repo ( "untracked-unborn" ) ?;
89+ let mut status = repo. status ( gix:: progress:: Discard ) ?. into_iter ( None ) ?;
90+ let mut items: Vec < _ > = status. by_ref ( ) . filter_map ( Result :: ok) . collect ( ) ;
91+ items. sort_by ( |a, b| a. location ( ) . cmp ( b. location ( ) ) ) ;
92+ insta:: assert_debug_snapshot!( items, @r#"
93+ [
94+ IndexWorktree(
95+ DirectoryContents {
96+ entry: Entry {
97+ rela_path: "untracked",
98+ status: Untracked,
99+ property: None,
100+ disk_kind: Some(
101+ File,
102+ ),
103+ index_kind: None,
104+ pathspec_match: Some(
105+ Always,
106+ ),
107+ },
108+ collapsed_directory_status: None,
109+ },
110+ ),
111+ ]
112+ "# ) ;
113+ Ok ( ( ) )
114+ }
115+
86116 #[ test]
87117 fn error_during_tree_traversal_causes_failure ( ) -> crate :: Result {
88118 let repo = repo ( "untracked-only" ) ?;
You can’t perform that action at this time.
0 commit comments