File tree 5 files changed +57
-4
lines changed
5 files changed +57
-4
lines changed Original file line number Diff line number Diff line change @@ -213,13 +213,21 @@ mod submodule_status {
213
213
mode : Submodule ,
214
214
) -> Result < Self , crate :: submodule:: modules:: Error > {
215
215
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) ) => {
218
218
let mut v: Vec < _ > = sm. filter_map ( |sm| sm. path ( ) . ok ( ) . map ( Cow :: into_owned) ) . collect ( ) ;
219
219
v. sort ( ) ;
220
220
v
221
221
}
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) ,
223
231
} ;
224
232
Ok ( Self {
225
233
mode,
Original file line number Diff line number Diff line change 45
45
46
46
let obtain_tree_id = || -> Result < Option < gix_hash:: ObjectId > , crate :: status:: into_iter:: Error > {
47
47
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
+ } ,
49
59
Some ( Some ( tree_id) ) => Some ( tree_id) ,
50
60
None => None ,
51
61
} )
Original file line number Diff line number Diff line change @@ -29,4 +29,9 @@ git init racy-git
29
29
30
30
echo ho > file && git add file
31
31
echo ha > file
32
+ )
33
+
34
+ git init untracked-unborn
35
+ (cd untracked-unborn
36
+ touch untracked
32
37
)
Original file line number Diff line number Diff line change @@ -83,6 +83,36 @@ mod into_iter {
83
83
Ok ( ( ) )
84
84
}
85
85
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
+
86
116
#[ test]
87
117
fn error_during_tree_traversal_causes_failure ( ) -> crate :: Result {
88
118
let repo = repo ( "untracked-only" ) ?;
You can’t perform that action at this time.
0 commit comments