git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Frédéric Heitzmann" <frederic.heitzmann@gmail.com>
Cc: git@vger.kernel.org, Eric Wong <normalperson@yhbt.net>
Subject: Re: [PATCH v2] git svn : hook before 'git svn dcommit'
Date: Mon, 15 Aug 2011 14:14:49 -0700	[thread overview]
Message-ID: <7vty9ijs1i.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <1313438699-9926-1-git-send-email-frederic.heitzmann@gmail.com> ("Frédéric Heitzmann"'s message of "Mon, 15 Aug 2011 22:04:59 +0200")

Frédéric Heitzmann  <frederic.heitzmann@gmail.com> writes:

> The 'pre-svn-dcommit' hook is called before 'git svn dcommit', which aborts
> if return value is not zero. The only parameter given to the hook is the
> reference given to 'git svn dcommit'. If no paramter was used, hook gets HEAD
> as its only parameter.

It appears that this is in the same spirit as the pre-commit hook used in
"git commit", so it may not hurt but I do not know if having a separate
hook is the optimal approach to achieve what it wants to do.

I notice that git-svn users have been happily using the subsystem without
need for any hook (not just pre-commit). Does "git svn" need an equivalent
of pre-commit hook? If so, does it need equivalents to other hooks as
well? I am not suggesting you to add support for a boatload of other hooks
in this patch---I am trying to see if this is really a necessary change to
begin with.

Eric, do you want this one?

> 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;

Why force two stat(), instead of just "if ! -x $hook"?  Doesn't it respond
to a non-existing $hook with "there is nothing executable there" just fine?

> +	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;
> +	}
> +}

Should these messages go to the standard output?

>  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 {

  reply	other threads:[~2011-08-15 21:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-15 20:04 [PATCH v2] git svn : hook before 'git svn dcommit' Frédéric Heitzmann
2011-08-15 21:14 ` Junio C Hamano [this message]
2011-08-17  0:30   ` Eric Wong
     [not found]     ` <CALeToSWJNK=q4iPwxNvgGin0T61oLKJd=b9F3cSSo0vVebrhhQ@mail.gmail.com>
2011-08-17 14:35       ` Frédéric Heitzmann
2011-08-17 20:37         ` Eric Wong
2011-08-18 13:43           ` Frédéric Heitzmann
2011-08-20 18:41             ` Eric Wong
2011-08-18  9:12         ` Peter Baumann
2011-09-01 16:58           ` Paul Young
  -- strict thread matches above, loose matches on Subject: below --
2011-07-04  5:54 [PATCH] " 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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=7vty9ijs1i.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=frederic.heitzmann@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=normalperson@yhbt.net \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).