File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -198,9 +198,17 @@ fn handle(
198
198
destination. display( )
199
199
) ) ,
200
200
Mode :: Execute => {
201
- std:: fs:: create_dir_all ( destination. parent ( ) . expect ( "repo destination is not the root" ) ) ?;
201
+ if destination. starts_with ( git_workdir) {
202
+ let tempdir = tempfile:: tempdir_in ( canonicalized_destination) ?;
203
+ let tempdest = tempdir. path ( ) . join ( destination. file_name ( ) . expect ( "repo destination is not the root" ) ) ;
204
+ std:: fs:: rename ( git_workdir, & tempdest) ?;
205
+ std:: fs:: create_dir_all ( destination. parent ( ) . expect ( "repo destination is not the root" ) ) ?;
206
+ std:: fs:: rename ( & tempdest, & destination) ?;
207
+ } else {
208
+ std:: fs:: create_dir_all ( destination. parent ( ) . expect ( "repo destination is not the root" ) ) ?;
209
+ std:: fs:: rename ( git_workdir, & destination) ?;
210
+ }
202
211
progress. done ( format ! ( "Moving {} to {}" , git_workdir. display( ) , destination. display( ) ) ) ;
203
- std:: fs:: rename ( git_workdir, & destination) ?;
204
212
}
205
213
}
206
214
Ok ( ( ) )
You can’t perform that action at this time.
0 commit comments