1
1
use std:: collections:: HashMap ;
2
2
use std:: fmt:: Debug ;
3
- use std:: mem:: replace ;
3
+ use std:: mem:: take ;
4
4
use std:: path:: {
5
5
Path ,
6
6
PathBuf ,
@@ -153,7 +153,7 @@ impl SnapshotManager {
153
153
let mut index = self . repo . index ( ) ?;
154
154
let cwd = os. env . current_dir ( ) ?;
155
155
156
- let ignores = RegexSet :: new ( & [ r".git" ] ) ?;
156
+ let ignores = RegexSet :: new ( [ r".git" ] ) ?;
157
157
let comparison = Comparison :: new ( ignores) ;
158
158
let res = comparison. compare ( SHADOW_REPO_DIR , os. env . current_dir ( ) ?. to_str ( ) . unwrap ( ) ) ?;
159
159
@@ -162,11 +162,11 @@ impl SnapshotManager {
162
162
if shadow_path. is_file ( ) {
163
163
let cwd_path = convert_path ( SHADOW_REPO_DIR , shadow_path, & cwd) ?;
164
164
self . modified_map
165
- . insert ( cwd_path. to_path_buf ( ) , get_modified_timestamp ( os, & cwd_path) . await ?) ;
165
+ . insert ( cwd_path. clone ( ) , get_modified_timestamp ( os, & cwd_path) . await ?) ;
166
166
copy_file_to_dir ( os, & cwd, cwd_path, SHADOW_REPO_DIR ) . await ?;
167
167
168
168
// Staging requires relative paths
169
- index. add_path ( & shadow_path. strip_prefix ( SHADOW_REPO_DIR ) ?) ?;
169
+ index. add_path ( shadow_path. strip_prefix ( SHADOW_REPO_DIR ) ?) ?;
170
170
}
171
171
}
172
172
@@ -175,10 +175,10 @@ impl SnapshotManager {
175
175
copy_file_to_dir ( os, & cwd, cwd_path, SHADOW_REPO_DIR ) . await ?;
176
176
if cwd_path. is_file ( ) {
177
177
self . modified_map
178
- . insert ( cwd_path. to_path_buf ( ) , get_modified_timestamp ( os, cwd_path) . await ?) ;
178
+ . insert ( cwd_path. clone ( ) , get_modified_timestamp ( os, cwd_path) . await ?) ;
179
179
180
180
// Staging requires relative paths
181
- index. add_path ( & cwd_path. strip_prefix ( & cwd) ?) ?;
181
+ index. add_path ( cwd_path. strip_prefix ( & cwd) ?) ?;
182
182
}
183
183
}
184
184
@@ -195,7 +195,7 @@ impl SnapshotManager {
195
195
196
196
// Update table and shadow repo if deleted
197
197
// FIX: removing the entry is probably not the best choice?
198
- self . modified_map . remove ( & shadow_path. to_path_buf ( ) ) ;
198
+ self . modified_map . remove ( & shadow_path. clone ( ) ) ;
199
199
os. fs . remove_file ( shadow_path) . await ?;
200
200
201
201
// Staging requires relative paths
@@ -228,21 +228,21 @@ impl SnapshotManager {
228
228
& signature,
229
229
message,
230
230
& tree,
231
- & parents. iter ( ) . map ( |c| c ) . collect :: < Vec < _ > > ( ) ,
231
+ & parents. iter ( ) . collect :: < Vec < _ > > ( ) ,
232
232
) ?;
233
233
234
234
if turn {
235
235
// Assign tool uses to the turn snapshot they belong to
236
236
let tool_snapshots = if !self . tool_use_buffer . is_empty ( ) {
237
- replace ( & mut self . tool_use_buffer , Vec :: new ( ) )
237
+ take ( & mut self . tool_use_buffer )
238
238
} else {
239
239
Vec :: new ( )
240
240
} ;
241
241
242
242
self . snapshot_table . push ( Snapshot {
243
243
timestamp : Local :: now ( ) ,
244
244
message : message. to_string ( ) ,
245
- history_index : history_index ,
245
+ history_index,
246
246
tool_snapshots,
247
247
} ) ;
248
248
self . oid_table . push ( oid) ;
@@ -283,7 +283,7 @@ impl SnapshotManager {
283
283
self . reset_hard ( & oid. to_string ( ) ) . await ?;
284
284
285
285
let cwd = os. env . current_dir ( ) ?;
286
- let ignores = RegexSet :: new ( & [ r".git" ] ) ?;
286
+ let ignores = RegexSet :: new ( [ r".git" ] ) ?;
287
287
let comparison = Comparison :: new ( ignores) ;
288
288
let res = comparison. compare ( SHADOW_REPO_DIR , cwd. to_str ( ) . unwrap ( ) ) ?;
289
289
@@ -293,7 +293,7 @@ impl SnapshotManager {
293
293
let cwd_path = convert_path ( SHADOW_REPO_DIR , shadow_path, & cwd) ?;
294
294
copy_file_to_dir ( os, SHADOW_REPO_DIR , shadow_path, & cwd) . await ?;
295
295
self . modified_map
296
- . insert ( cwd_path. to_path_buf ( ) , get_modified_timestamp ( os, & cwd_path) . await ?) ;
296
+ . insert ( cwd_path. clone ( ) , get_modified_timestamp ( os, & cwd_path) . await ?) ;
297
297
}
298
298
}
299
299
@@ -302,7 +302,7 @@ impl SnapshotManager {
302
302
let cwd_path = convert_path ( SHADOW_REPO_DIR , shadow_path, & cwd) ?;
303
303
copy_file_to_dir ( os, SHADOW_REPO_DIR , shadow_path, & cwd) . await ?;
304
304
self . modified_map
305
- . insert ( cwd_path. to_path_buf ( ) , get_modified_timestamp ( os, & cwd_path) . await ?) ;
305
+ . insert ( cwd_path. clone ( ) , get_modified_timestamp ( os, & cwd_path) . await ?) ;
306
306
}
307
307
308
308
// Delete extra files
@@ -377,7 +377,7 @@ async fn copy_file_to_dir(
377
377
destination : impl AsRef < Path > ,
378
378
) -> Result < ( ) > {
379
379
let path = path. as_ref ( ) ;
380
- let target_path = convert_path ( prefix, & path, destination) ?;
380
+ let target_path = convert_path ( prefix, path, destination) ?;
381
381
if path. is_dir ( ) && !os. fs . exists ( & target_path) {
382
382
os. fs . create_dir_all ( target_path) . await ?;
383
383
} else if path. is_file ( ) {
0 commit comments