All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Frédéric Heitzmann" <frederic.heitzmann@gmail.com>
To: Git Mailing List <git@vger.kernel.org>
Subject: [PATCH] git svn : hook before 'git svn dcommit'
Date: Sat, 02 Jul 2011 14:48:03 +0200	[thread overview]
Message-ID: <4E0F1383.8080804@gmail.com> (raw)

The 'pre-svn-dcommit' hook si called before 'git svn dcommit', which aborts
if return value is not zero.
---
  git-svn.perl |   19 +++++++++++++++++++
  1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/git-svn.perl b/git-svn.perl
index 89f83fd..e70afae 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -396,6 +396,23 @@ sub init_subdir {
         $_repository = Git->repository(Repository => $ENV{GIT_DIR});
  }

+sub pre_svn_dcommit_hook {
+       my $hook = "$ENV{GIT_DIR}/hooks/pre-svn-dcommit";
+       return 0 if ! -e $hook || ! -x $hook;
+
+       system($hook);
+       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 &&
@@ -518,6 +535,8 @@ sub cmd_dcommit {
                 command(['checkout', $head], STDERR => 0);
         }

+       return if pre_svn_dcommit_hook();
+
         my @refs;
         my ($url, $rev, $uuid, $gs) = working_head_info('HEAD', \@refs);
         unless ($gs) {
-- 

             reply	other threads:[~2011-07-02 12:48 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-02 12:48 Frédéric Heitzmann [this message]
2011-07-02 13:54 ` [PATCH] git svn : hook before 'git svn dcommit' Matthieu Moy
2011-07-02 17:25   ` Frédéric Heitzmann
2011-07-02 21:59     ` Matthieu Moy
2011-07-03 20:49       ` Frédéric Heitzmann
2011-07-03 20:49         ` [PATCH 1/2] " Frédéric Heitzmann
2011-07-03 20:49         ` [PATCH 2/2] git svn : documentation of 'pre-svn-dcommit' Frédéric Heitzmann
2011-07-03 21:00         ` [PATCH] git svn : hook before 'git svn dcommit' Matthieu Moy
2011-07-04  5:54           ` Frédéric Heitzmann
2011-07-05 20:44             ` [PATCH v2] " Frédéric Heitzmann
2011-07-09 12:18               ` Frédéric Heitzmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E0F1383.8080804@gmail.com \
    --to=frederic.heitzmann@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.