@@ -68,57 +68,45 @@ pub fn commit(repo_path: &str, msg: &str) -> Result<Oid> {
6868}
6969
7070/// add a file diff from workingdir to stage (will not add removed files see `stage_addremoved`)
71- pub fn stage_add_file ( repo_path : & str , path : & Path ) -> Result < bool > {
71+ pub fn stage_add_file ( repo_path : & str , path : & Path ) -> Result < ( ) > {
7272 scope_time ! ( "stage_add_file" ) ;
7373
7474 let repo = repo ( repo_path) ?;
7575
7676 let mut index = repo. index ( ) ?;
7777
78- if index. add_path ( path) . is_ok ( ) {
79- index. write ( ) ?;
80- return Ok ( true ) ;
81- }
78+ index. add_path ( path) ?;
79+ index. write ( ) ?;
8280
83- Ok ( false )
81+ Ok ( ( ) )
8482}
8583
8684/// like `stage_add_file` but uses a pattern to match/glob multiple files/folders
87- pub fn stage_add_all ( repo_path : & str , pattern : & str ) -> Result < bool > {
85+ pub fn stage_add_all ( repo_path : & str , pattern : & str ) -> Result < ( ) > {
8886 scope_time ! ( "stage_add_all" ) ;
8987
9088 let repo = repo ( repo_path) ?;
9189
9290 let mut index = repo. index ( ) ?;
9391
94- if index
95- . add_all ( vec ! [ pattern] , IndexAddOption :: DEFAULT , None )
96- . is_ok ( )
97- {
98- index. write ( ) ?;
99- return Ok ( true ) ;
100- }
92+ index. add_all ( vec ! [ pattern] , IndexAddOption :: DEFAULT , None ) ?;
93+ index. write ( ) ?;
10194
102- Ok ( false )
95+ Ok ( ( ) )
10396}
10497
10598/// stage a removed file
106- pub fn stage_addremoved (
107- repo_path : & str ,
108- path : & Path ,
109- ) -> Result < bool > {
99+ pub fn stage_addremoved ( repo_path : & str , path : & Path ) -> Result < ( ) > {
110100 scope_time ! ( "stage_addremoved" ) ;
111101
112102 let repo = repo ( repo_path) ?;
113103
114104 let mut index = repo. index ( ) ?;
115105
116- if index. remove_path ( path) . is_ok ( ) {
117- index. write ( ) ?;
118- return Ok ( true ) ;
119- }
106+ index. remove_path ( path) ?;
107+ index. write ( ) ?;
120108
121- Ok ( false )
109+ Ok ( ( ) )
122110}
123111
124112#[ cfg( test) ]
@@ -148,10 +136,7 @@ mod tests {
148136
149137 assert_eq ! ( get_statuses( repo_path) , ( 1 , 0 ) ) ;
150138
151- assert_eq ! (
152- stage_add_file( repo_path, file_path) . unwrap( ) ,
153- true
154- ) ;
139+ stage_add_file ( repo_path, file_path) . unwrap ( ) ;
155140
156141 assert_eq ! ( get_statuses( repo_path) , ( 0 , 1 ) ) ;
157142
@@ -176,10 +161,7 @@ mod tests {
176161
177162 assert_eq ! ( get_statuses( repo_path) , ( 1 , 0 ) ) ;
178163
179- assert_eq ! (
180- stage_add_file( repo_path, file_path) . unwrap( ) ,
181- true
182- ) ;
164+ stage_add_file ( repo_path, file_path) . unwrap ( ) ;
183165
184166 assert_eq ! ( get_statuses( repo_path) , ( 0 , 1 ) ) ;
185167
@@ -196,7 +178,7 @@ mod tests {
196178 let repo_path = root. as_os_str ( ) . to_str ( ) . unwrap ( ) ;
197179
198180 assert_eq ! (
199- stage_add_file( repo_path, file_path) . unwrap ( ) ,
181+ stage_add_file( repo_path, file_path) . is_ok ( ) ,
200182 false
201183 ) ;
202184 }
@@ -220,10 +202,7 @@ mod tests {
220202
221203 assert_eq ! ( get_statuses( repo_path) , ( 2 , 0 ) ) ;
222204
223- assert_eq ! (
224- stage_add_file( repo_path, file_path) . unwrap( ) ,
225- true
226- ) ;
205+ stage_add_file ( repo_path, file_path) . unwrap ( ) ;
227206
228207 assert_eq ! ( get_statuses( repo_path) , ( 1 , 1 ) ) ;
229208 }
@@ -248,7 +227,7 @@ mod tests {
248227
249228 assert_eq ! ( status_count( StatusType :: WorkingDir ) , 3 ) ;
250229
251- assert_eq ! ( stage_add_all( repo_path, "a/d" ) . unwrap( ) , true ) ;
230+ stage_add_all ( repo_path, "a/d" ) . unwrap ( ) ;
252231
253232 assert_eq ! ( status_count( StatusType :: WorkingDir ) , 1 ) ;
254233 assert_eq ! ( status_count( StatusType :: Stage ) , 2 ) ;
@@ -274,10 +253,7 @@ mod tests {
274253 . write_all ( b"test file1 content" )
275254 . unwrap ( ) ;
276255
277- assert_eq ! (
278- stage_add_file( repo_path, file_path) . unwrap( ) ,
279- true
280- ) ;
256+ stage_add_file ( repo_path, file_path) . unwrap ( ) ;
281257
282258 commit ( repo_path, "commit msg" ) . unwrap ( ) ;
283259
@@ -287,10 +263,7 @@ mod tests {
287263 // deleted file in diff now
288264 assert_eq ! ( status_count( StatusType :: WorkingDir ) , 1 ) ;
289265
290- assert_eq ! (
291- stage_addremoved( repo_path, file_path) . unwrap( ) ,
292- true
293- ) ;
266+ stage_addremoved ( repo_path, file_path) . unwrap ( ) ;
294267
295268 assert_eq ! ( status_count( StatusType :: WorkingDir ) , 0 ) ;
296269 assert_eq ! ( status_count( StatusType :: Stage ) , 1 ) ;
0 commit comments