From: Eric Wong Date: Sat, 26 Apr 2014 03:16:06 +0000 (+0000) Subject: ssoma: lock against concurrent fetch/remote add X-Git-Tag: v0.1.0~3 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=dd1186fba508abf690f4d2dd4692081aa4272c95;p=ssoma-mda.git ssoma: lock against concurrent fetch/remote add A user may manually run ssoma while cron is running, so avoid any potential synchronization problems in this case. --- diff --git a/ssoma b/ssoma index ef99a00..9f71aa3 100755 --- a/ssoma +++ b/ssoma @@ -178,8 +178,10 @@ sub cmd_add { x(qw/git config/, "target.$target.$cfg", $path); } - $git->tmp_git_do(sub { - x(qw/git remote add --mirror=fetch origin/, $url); + $git->sync_do(sub { + $git->tmp_git_do(sub { + x(qw/git remote add --mirror=fetch origin/, $url); + }); }); } @@ -245,11 +247,13 @@ sub do_sync { @$targets = keys %t; } - $git->tmp_git_do(sub { - my @cmd = qw/git fetch/; - push @cmd, '-q' if $opts{quiet}; - push @cmd, '-f' if $opts{force}; - x(@cmd); + $git->sync_do(sub { + $git->tmp_git_do(sub { + my @cmd = qw/git fetch/; + push @cmd, '-q' if $opts{quiet}; + push @cmd, '-f' if $opts{force}; + x(@cmd); + }); }); foreach my $target (@$targets) {