@@ -298,31 +298,34 @@ def rsync(
298
298
# --filter
299
299
rsync_command .append (RSYNC_FILTER_OPTION )
300
300
301
- # --exclude-from
302
- resolved_source = pathlib .Path (source ).expanduser ().resolve ()
303
- if (resolved_source / GIT_EXCLUDE ).exists ():
304
- # Ensure file exists; otherwise, rsync will error out.
305
- rsync_command .append (
306
- RSYNC_EXCLUDE_OPTION .format (str (resolved_source / GIT_EXCLUDE )))
307
-
308
- # rsync doesn't support '~' in a quoted target path. need to expand it.
309
- full_source_str = str (resolved_source )
310
- if resolved_source .is_dir ():
311
- full_source_str = os .path .join (full_source_str , '' )
301
+ if up :
302
+ # The source is a local path, so we need to resolve it.
303
+ # --exclude-from
304
+ resolved_source = pathlib .Path (source ).expanduser ().resolve ()
305
+ if (resolved_source / GIT_EXCLUDE ).exists ():
306
+ # Ensure file exists; otherwise, rsync will error out.
307
+ rsync_command .append (
308
+ RSYNC_EXCLUDE_OPTION .format (
309
+ str (resolved_source / GIT_EXCLUDE )))
312
310
313
311
ssh_options = ' ' .join (
314
312
ssh_options_list (self .ssh_private_key , self .ssh_control_name ))
315
313
rsync_command .append (f'-e "ssh { ssh_options } "' )
316
314
# To support spaces in the path, we need to quote source and target.
315
+ # rsync doesn't support '~' in a quoted local path, but it is ok to
316
+ # have '~' in a quoted remote path.
317
317
if up :
318
+ full_source_str = str (resolved_source )
319
+ if resolved_source .is_dir ():
320
+ full_source_str = os .path .join (full_source_str , '' )
318
321
rsync_command .extend ([
319
322
f'{ full_source_str !r} ' ,
320
323
f'{ self .ssh_user } @{ self .ip } :{ target !r} ' ,
321
324
])
322
325
else :
323
326
rsync_command .extend ([
324
- f'{ self .ssh_user } @{ self .ip } :{ full_source_str !r} ' ,
325
- f'{ target !r} ' ,
327
+ f'{ self .ssh_user } @{ self .ip } :{ source !r} ' ,
328
+ f'{ os . path . expanduser ( target ) !r} ' ,
326
329
])
327
330
command = ' ' .join (rsync_command )
328
331
0 commit comments