From 6f1f0d65ba3899805c5d8124633b6d2c088fc2fb Mon Sep 17 00:00:00 2001 From: Arnaud Gelas Date: Mon, 28 Jan 2013 16:41:02 +0100 Subject: add options rsync.sshuser and rsync.sshport --- git-fat | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'git-fat') diff --git a/git-fat b/git-fat index e177ce8..17b2de4 100755 --- a/git-fat +++ b/git-fat @@ -102,11 +102,13 @@ class GitFat(object): def setup(self): mkdir_p(self.objdir) def get_rsync(self): - cfgpath = os.path.join(self.gitroot,'.gitfat') - remote = gitconfig_get('rsync.remote', file=cfgpath) + cfgpath = os.path.join(self.gitroot,'.gitfat') + remote = gitconfig_get('rsync.remote', file=cfgpath) + ssh_port = gitconfig_get('rsync.sshport', file=cfgpath) + ssh_user = gitconfig_get('rsync.sshuser', file=cfgpath) if remote is None: raise RuntimeError('No rsync.remote in %s' % cfgpath) - return remote + return remote, ssh_port, ssh_user def revparse(self, revname): return subprocess.check_output(['git', 'rev-parse', revname]).strip() def encode_v1(self, digest, bytes): @@ -275,10 +277,19 @@ class GitFat(object): # (includes history). Finer-grained pushing would be useful. pushall = '--all' in args files = self.referenced_objects(all=pushall) & self.catalog_objects() - remote = self.get_rsync() + (remote, ssh_port, ssh_user) = self.get_rsync() self.verbose('Pushing to %s' % (remote)) - cmd = ['rsync', '--progress', '--ignore-existing', '--from0', '--files-from=-', self.objdir + '/', remote + '/'] - p = subprocess.Popen(cmd, stdin=subprocess.PIPE) + + if ssh_port == None and ssh_user == None: + cmd = ['rsync', '--progress', '--ignore-existing', '--from0', '--files-from=-', self.objdir + '/', remote + '/'] + else: + if ssh_user == None: + cmd = ['rsync', '--progress', '--ignore-existing', '--from0', '--files-from=-', self.objdir + '/', '--rsh=ssh -p' + ssh_port, remote + '/'] + else: + cmd = ['rsync', '--progress', '--ignore-existing', '--from0', '--files-from=-', self.objdir + '/', '--rsh=ssh -l ' + ssh_user + '-p ' + ssh_port, remote + '/'] + + print( cmd ) + p = subprocess.Popen(cmd, subprocess.PIPE) p.communicate(input='\x00'.join(files)) def checkout(self, show_orphans=False): 'Update any stale files in the present working tree' -- cgit v1.2.1