All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] git svn : hook before 'git svn dcommit'
@ 2011-07-02 12:48 Frédéric Heitzmann
  2011-07-02 13:54 ` Matthieu Moy
  0 siblings, 1 reply; 11+ messages in thread
From: Frédéric Heitzmann @ 2011-07-02 12:48 UTC (permalink / raw)
  To: Git Mailing List

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

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH] git svn : hook before 'git svn dcommit'
  2011-07-02 12:48 [PATCH] git svn : hook before 'git svn dcommit' Frédéric Heitzmann
@ 2011-07-02 13:54 ` Matthieu Moy
  2011-07-02 17:25   ` Frédéric Heitzmann
  0 siblings, 1 reply; 11+ messages in thread
From: Matthieu Moy @ 2011-07-02 13:54 UTC (permalink / raw)
  To: Frédéric Heitzmann; +Cc: Git Mailing List

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

> The 'pre-svn-dcommit' hook si called before 'git svn dcommit', which aborts
> if return value is not zero.
> ---
>  git-svn.perl |   19 +++++++++++++++++++

What about documentation?

> +       if ($? == -1) {
> +               print "[pre_svn_dcommit_hook] failed to execute $hook:
> $!\n";

whitespace damage (extra newline)

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] git svn : hook before 'git svn dcommit'
  2011-07-02 13:54 ` Matthieu Moy
@ 2011-07-02 17:25   ` Frédéric Heitzmann
  2011-07-02 21:59     ` Matthieu Moy
  0 siblings, 1 reply; 11+ messages in thread
From: Frédéric Heitzmann @ 2011-07-02 17:25 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: Git Mailing List


Le 02/07/2011 15:54, Matthieu Moy a écrit :
> Frédéric Heitzmann<frederic.heitzmann@gmail.com>  writes:
>
>> The 'pre-svn-dcommit' hook si called before 'git svn dcommit', which aborts
>> if return value is not zero.
>> ---
>>   git-svn.perl |   19 +++++++++++++++++++
> What about documentation?
Should documentation be part of githooks or git-svn man page ?
I vote for the latest, in order to avoid
In any case, what do you think of the following help message ?

+HOOKS
+-----
+
+The 'pre-svn-dcommit' hook is called by 'git svn dcommit' and can be 
used to
+prevent some diff to be committed to a SVN repository. It may typically be
+used to filter some intermediate patches, which were committed into git but
+must not find their way to the SVN repository.
+
+If the hook exists with a non zero-status, 'git svn dcommit' will abort.
+
+

[...]

  SEE ALSO
  --------
-linkgit:git-rebase[1]
+linkgit:git-rebase[1], linkgit:githooks[5]

-- 

>> +       if ($? == -1) {
>> +               print "[pre_svn_dcommit_hook] failed to execute $hook:
>> $!\n";
> whitespace damage (extra newline)
>

As for the 'whitespace damage", I do not understand what you mean.
The \n look mandatory to me.
You may look at 'info perlfunc' for the original code snippet (see 
'system' function).

--
Fred

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] git svn : hook before 'git svn dcommit'
  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
  0 siblings, 1 reply; 11+ messages in thread
From: Matthieu Moy @ 2011-07-02 21:59 UTC (permalink / raw)
  To: Frédéric Heitzmann; +Cc: Git Mailing List

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

> Le 02/07/2011 15:54, Matthieu Moy a écrit :
>> Frédéric Heitzmann<frederic.heitzmann@gmail.com>  writes:
>>
>>> The 'pre-svn-dcommit' hook si called before 'git svn dcommit', which aborts
>>> if return value is not zero.
>>> ---
>>>   git-svn.perl |   19 +++++++++++++++++++
>> What about documentation?
> Should documentation be part of githooks or git-svn man page ?
> I vote for the latest, in order to avoid

I'd also put it in the git-svn page, since git-svn is somehow not really
part of Git.

> +prevent some diff to be committed to a SVN repository.

I'd say "an SVN", not "a SVN", but the documentation already use both
forms.

>>> +       if ($? == -1) {
>>> +               print "[pre_svn_dcommit_hook] failed to execute $hook:
>>> $!\n";
>> whitespace damage (extra newline)
>>
>
>As for the 'whitespace damage", I do not understand what you mean.
>The \n look mandatory to me.
>You may look at 'info perlfunc' for the original code snippet (see
>system' function).

I'm not talking about the \n, but the fact that what used to be a single
line of code is broken in two parts in your message.

A patch hunk has lines starting with " ", "+" or "-", yours have a line
starting with $. It won't apply with "patch" or "git apply", hence extra
work for our maintainer.

Try using "git send-email" to avoid that.

And actually, read Documentation/SubmittingPatches, in particular the
part about Signed-off-by.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH] git svn : hook before 'git svn dcommit'
  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
                           ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Frédéric Heitzmann @ 2011-07-03 20:49 UTC (permalink / raw)
  To: Matthieu.Moy, git

The 'pre-svn-dcommit' hook is called by 'git svn dcommit' and can be used to
prevent some diff to be committed to a SVN repository. It may typically be
used to filter some intermediate patches, which were committed into git but
must not find their way to the SVN repository.

It takes a single parameter, the reference given to 'git svn dcommit'. If the
hook exists with a non zero-status, 'git svn dcommit' will abort.

Documentation/git-svn.txt |   14 +++++++++++++-
git-svn.perl              |   21 +++++++++++++++++++++
2 files changed, 34 insertions(+), 1 deletions(-)

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/2] git svn : hook before 'git svn dcommit'
  2011-07-03 20:49       ` Frédéric Heitzmann
@ 2011-07-03 20:49         ` 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
  2 siblings, 0 replies; 11+ messages in thread
From: Frédéric Heitzmann @ 2011-07-03 20:49 UTC (permalink / raw)
  To: Matthieu.Moy, git; +Cc: Frédéric Heitzmann

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

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 2/2] git svn : documentation of 'pre-svn-dcommit'
  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         ` Frédéric Heitzmann
  2011-07-03 21:00         ` [PATCH] git svn : hook before 'git svn dcommit' Matthieu Moy
  2 siblings, 0 replies; 11+ messages in thread
From: Frédéric Heitzmann @ 2011-07-03 20:49 UTC (permalink / raw)
  To: Matthieu.Moy, git; +Cc: Frédéric Heitzmann

Update of the git-svn documentation: 'pre-svn-dcommit' hook.

Signed-off-by: Frédéric Heitzmann <frederic.heitzmann@gmail.com>
---
 Documentation/git-svn.txt |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt
index 713e523..ec87ed3 100644
--- a/Documentation/git-svn.txt
+++ b/Documentation/git-svn.txt
@@ -700,6 +700,18 @@ section because they affect the 'git-svn-id:' metadata line, except
 for rewriteRoot and rewriteUUID which can be used together.
 
 
+HOOKS
+-----
+
+The 'pre-svn-dcommit' hook is called by 'git svn dcommit' and can be used to
+prevent some diff to be committed to a SVN repository. It may typically be
+used to filter some intermediate patches, which were committed into git but
+must not find their way to the SVN repository.
+
+It takes a single parameter, the reference given to 'git svn dcommit'. If the
+hook exists with a non zero-status, 'git svn dcommit' will abort.
+
+
 BASIC EXAMPLES
 --------------
 
@@ -901,7 +913,7 @@ reset) branches-maxRev and/or tags-maxRev as appropriate.
 
 SEE ALSO
 --------
-linkgit:git-rebase[1]
+linkgit:git-rebase[1], linkgit:githooks[5]
 
 GIT
 ---
-- 
1.7.6.133.gd3b55a

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH] git svn : hook before 'git svn dcommit'
  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         ` Matthieu Moy
  2011-07-04  5:54           ` Frédéric Heitzmann
  2 siblings, 1 reply; 11+ messages in thread
From: Matthieu Moy @ 2011-07-03 21:00 UTC (permalink / raw)
  To: Frédéric Heitzmann; +Cc: git

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

> The 'pre-svn-dcommit' hook is called by 'git svn dcommit' and can be used to
> prevent some diff to be committed to a SVN repository. It may typically be
> used to filter some intermediate patches, which were committed into git but
> must not find their way to the SVN repository.

Why 2 patches?

We usually try to have each commit as correct as possible (e.g. when
sending several patches, each commit should still pass the testsuite).
With your 2-patches serie, the first commit has documentation for a
feature which doesn't exist yet.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] git svn : hook before 'git svn dcommit'
  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
  0 siblings, 1 reply; 11+ messages in thread
From: Frédéric Heitzmann @ 2011-07-04  5:54 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: git



Le 03/07/2011 23:00, Matthieu Moy a écrit :
> Frédéric Heitzmann<frederic.heitzmann@gmail.com>  writes:
>
>> The 'pre-svn-dcommit' hook is called by 'git svn dcommit' and can be used to
>> prevent some diff to be committed to a SVN repository. It may typically be
>> used to filter some intermediate patches, which were committed into git but
>> must not find their way to the SVN repository.
> Why 2 patches?
>
> We usually try to have each commit as correct as possible (e.g. when
> sending several patches, each commit should still pass the testsuite).
> With your 2-patches serie, the first commit has documentation for a
> feature which doesn't exist yet.
I find it easier to separate commits on documentation from code patch, 
especially for rereading and dicussing.
However, if it is desirable to get them merged, I could do that easily.

As for the order :
patch 1/2 : perl magic
patch 2/2 : documentation update
=>  the serie looks in the right order to me.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v2] git svn : hook before 'git svn dcommit'
  2011-07-04  5:54           ` Frédéric Heitzmann
@ 2011-07-05 20:44             ` Frédéric Heitzmann
  2011-07-09 12:18               ` Frédéric Heitzmann
  0 siblings, 1 reply; 11+ messages in thread
From: Frédéric Heitzmann @ 2011-07-05 20:44 UTC (permalink / raw)
  To: git; +Cc: Matthieu.Moy, Frédéric Heitzmann

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.

Signed-off-by: Frédéric Heitzmann <frederic.heitzmann@gmail.com>
---

This is the second iteration of the patch.
Previous 2 patches were merged into one. 

 Documentation/git-svn.txt |   14 +++++++++++++-
 git-svn.perl              |   21 +++++++++++++++++++++
 2 files changed, 34 insertions(+), 1 deletions(-)

diff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt
index 713e523..ec87ed3 100644
--- a/Documentation/git-svn.txt
+++ b/Documentation/git-svn.txt
@@ -700,6 +700,18 @@ section because they affect the 'git-svn-id:' metadata line, except
 for rewriteRoot and rewriteUUID which can be used together.
 
 
+HOOKS
+-----
+
+The 'pre-svn-dcommit' hook is called by 'git svn dcommit' and can be used to
+prevent some diff to be committed to a SVN repository. It may typically be
+used to filter some intermediate patches, which were committed into git but
+must not find their way to the SVN repository.
+
+It takes a single parameter, the reference given to 'git svn dcommit'. If the
+hook exists with a non zero-status, 'git svn dcommit' will abort.
+
+
 BASIC EXAMPLES
 --------------
 
@@ -901,7 +913,7 @@ reset) branches-maxRev and/or tags-maxRev as appropriate.
 
 SEE ALSO
 --------
-linkgit:git-rebase[1]
+linkgit:git-rebase[1], linkgit:githooks[5]
 
 GIT
 ---
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

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v2] git svn : hook before 'git svn dcommit'
  2011-07-05 20:44             ` [PATCH v2] " Frédéric Heitzmann
@ 2011-07-09 12:18               ` Frédéric Heitzmann
  0 siblings, 0 replies; 11+ messages in thread
From: Frédéric Heitzmann @ 2011-07-09 12:18 UTC (permalink / raw)
  To: gitster; +Cc: git, Frédéric Heitzmann

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.

Signed-off-by: Frédéric Heitzmann <frederic.heitzmann@gmail.com>
---
There was no remark about patch v2.
I suppose it should be OK for merging upstream.

 Documentation/git-svn.txt |   14 +++++++++++++-
 git-svn.perl              |   21 +++++++++++++++++++++
 2 files changed, 34 insertions(+), 1 deletions(-)

diff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt
index 713e523..ec87ed3 100644
--- a/Documentation/git-svn.txt
+++ b/Documentation/git-svn.txt
@@ -700,6 +700,18 @@ section because they affect the 'git-svn-id:' metadata line, except
 for rewriteRoot and rewriteUUID which can be used together.
 
 
+HOOKS
+-----
+
+The 'pre-svn-dcommit' hook is called by 'git svn dcommit' and can be used to
+prevent some diff to be committed to a SVN repository. It may typically be
+used to filter some intermediate patches, which were committed into git but
+must not find their way to the SVN repository.
+
+It takes a single parameter, the reference given to 'git svn dcommit'. If the
+hook exists with a non zero-status, 'git svn dcommit' will abort.
+
+
 BASIC EXAMPLES
 --------------
 
@@ -901,7 +913,7 @@ reset) branches-maxRev and/or tags-maxRev as appropriate.
 
 SEE ALSO
 --------
-linkgit:git-rebase[1]
+linkgit:git-rebase[1], linkgit:githooks[5]
 
 GIT
 ---
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

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2011-07-09 12:19 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-02 12:48 [PATCH] git svn : hook before 'git svn dcommit' Frédéric Heitzmann
2011-07-02 13:54 ` 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

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.