@@ -68,57 +68,45 @@ pub fn commit(repo_path: &str, msg: &str) -> Result<Oid> {
68
68
}
69
69
70
70
/// 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 < ( ) > {
72
72
scope_time ! ( "stage_add_file" ) ;
73
73
74
74
let repo = repo ( repo_path) ?;
75
75
76
76
let mut index = repo. index ( ) ?;
77
77
78
- if index. add_path ( path) . is_ok ( ) {
79
- index. write ( ) ?;
80
- return Ok ( true ) ;
81
- }
78
+ index. add_path ( path) ?;
79
+ index. write ( ) ?;
82
80
83
- Ok ( false )
81
+ Ok ( ( ) )
84
82
}
85
83
86
84
/// 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 < ( ) > {
88
86
scope_time ! ( "stage_add_all" ) ;
89
87
90
88
let repo = repo ( repo_path) ?;
91
89
92
90
let mut index = repo. index ( ) ?;
93
91
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 ( ) ?;
101
94
102
- Ok ( false )
95
+ Ok ( ( ) )
103
96
}
104
97
105
98
/// 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 < ( ) > {
110
100
scope_time ! ( "stage_addremoved" ) ;
111
101
112
102
let repo = repo ( repo_path) ?;
113
103
114
104
let mut index = repo. index ( ) ?;
115
105
116
- if index. remove_path ( path) . is_ok ( ) {
117
- index. write ( ) ?;
118
- return Ok ( true ) ;
119
- }
106
+ index. remove_path ( path) ?;
107
+ index. write ( ) ?;
120
108
121
- Ok ( false )
109
+ Ok ( ( ) )
122
110
}
123
111
124
112
#[ cfg( test) ]
@@ -148,10 +136,7 @@ mod tests {
148
136
149
137
assert_eq ! ( get_statuses( repo_path) , ( 1 , 0 ) ) ;
150
138
151
- assert_eq ! (
152
- stage_add_file( repo_path, file_path) . unwrap( ) ,
153
- true
154
- ) ;
139
+ stage_add_file ( repo_path, file_path) . unwrap ( ) ;
155
140
156
141
assert_eq ! ( get_statuses( repo_path) , ( 0 , 1 ) ) ;
157
142
@@ -176,10 +161,7 @@ mod tests {
176
161
177
162
assert_eq ! ( get_statuses( repo_path) , ( 1 , 0 ) ) ;
178
163
179
- assert_eq ! (
180
- stage_add_file( repo_path, file_path) . unwrap( ) ,
181
- true
182
- ) ;
164
+ stage_add_file ( repo_path, file_path) . unwrap ( ) ;
183
165
184
166
assert_eq ! ( get_statuses( repo_path) , ( 0 , 1 ) ) ;
185
167
@@ -196,7 +178,7 @@ mod tests {
196
178
let repo_path = root. as_os_str ( ) . to_str ( ) . unwrap ( ) ;
197
179
198
180
assert_eq ! (
199
- stage_add_file( repo_path, file_path) . unwrap ( ) ,
181
+ stage_add_file( repo_path, file_path) . is_ok ( ) ,
200
182
false
201
183
) ;
202
184
}
@@ -220,10 +202,7 @@ mod tests {
220
202
221
203
assert_eq ! ( get_statuses( repo_path) , ( 2 , 0 ) ) ;
222
204
223
- assert_eq ! (
224
- stage_add_file( repo_path, file_path) . unwrap( ) ,
225
- true
226
- ) ;
205
+ stage_add_file ( repo_path, file_path) . unwrap ( ) ;
227
206
228
207
assert_eq ! ( get_statuses( repo_path) , ( 1 , 1 ) ) ;
229
208
}
@@ -248,7 +227,7 @@ mod tests {
248
227
249
228
assert_eq ! ( status_count( StatusType :: WorkingDir ) , 3 ) ;
250
229
251
- assert_eq ! ( stage_add_all( repo_path, "a/d" ) . unwrap( ) , true ) ;
230
+ stage_add_all ( repo_path, "a/d" ) . unwrap ( ) ;
252
231
253
232
assert_eq ! ( status_count( StatusType :: WorkingDir ) , 1 ) ;
254
233
assert_eq ! ( status_count( StatusType :: Stage ) , 2 ) ;
@@ -274,10 +253,7 @@ mod tests {
274
253
. write_all ( b"test file1 content" )
275
254
. unwrap ( ) ;
276
255
277
- assert_eq ! (
278
- stage_add_file( repo_path, file_path) . unwrap( ) ,
279
- true
280
- ) ;
256
+ stage_add_file ( repo_path, file_path) . unwrap ( ) ;
281
257
282
258
commit ( repo_path, "commit msg" ) . unwrap ( ) ;
283
259
@@ -287,10 +263,7 @@ mod tests {
287
263
// deleted file in diff now
288
264
assert_eq ! ( status_count( StatusType :: WorkingDir ) , 1 ) ;
289
265
290
- assert_eq ! (
291
- stage_addremoved( repo_path, file_path) . unwrap( ) ,
292
- true
293
- ) ;
266
+ stage_addremoved ( repo_path, file_path) . unwrap ( ) ;
294
267
295
268
assert_eq ! ( status_count( StatusType :: WorkingDir ) , 0 ) ;
296
269
assert_eq ! ( status_count( StatusType :: Stage ) , 1 ) ;
0 commit comments