[PATCH 1/2] git svn : hook before 'git svn dcommit'
- From
- Frédéric Heitzmann <frederic.heitzmann@gmail.com>
- Date
- Jul 3, 2011, 20:49 UTC
- Message-ID
- <1309726156-31156-2-git-send-email-frederic.heitzmann@gmail.com>
- In-Reply-To
- <1309726156-31156-1-git-send-email-frederic.heitzmann@gmail.com>
The 'pre-svn-dcommit' hook is called before 'git svn dcommit', which aborts if return value is not zero.
Signed-off-by: Frédéric Heitzmann <frederic.heitzmann@gmail.com> --- git-svn.perl | 21 +++++++++++++++++++++ 1 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/git-svn.perl b/git-svn.perl index 89f83fd..a537858 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -396,6 +396,25 @@ sub init_subdir { $_repository = Git->repository(Repository => $ENV{GIT_DIR}); } +sub pre_svn_dcommit_hook { + my $head = shift; + + my $hook = "$ENV{GIT_DIR}/hooks/pre-svn-dcommit"; + return 0 if ! -e $hook || ! -x $hook; + + system($hook, $head); + if ($? == -1) { + print "[pre_svn_dcommit_hook] failed to execute $hook: $!\n"; + return 1; + } elsif ($? & 127) { + printf "[pre_svn_dcommit_hook] child died with signal %d, %s coredump\n", + ($? & 127), ($? & 128) ? 'with' : 'without'; + return 1; + } else { + return $? >> 8; + } +} + sub cmd_clone { my ($url, $path) = @_; if (!defined $path && @@ -505,6 +524,8 @@ sub cmd_dcommit { . "or stash them with `git stash'.\n"; $head ||= 'HEAD'; + return if pre_svn_dcommit_hook($head); + my $old_head; if ($head ne 'HEAD') { $old_head = eval {
-- 1.7.6.133.gd3b55a