git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] git-remote-mediawiki: reset private ref after non-dumb push
@ 2013-08-21  8:10 Matthieu Moy
  2013-08-21  8:10 ` [PATCH 2/2] git-remote-mediawiki: add test and check Makefile targets Matthieu Moy
  2013-08-21 17:59 ` [PATCH 1/2] git-remote-mediawiki: reset private ref after non-dumb push Junio C Hamano
  0 siblings, 2 replies; 4+ messages in thread
From: Matthieu Moy @ 2013-08-21  8:10 UTC (permalink / raw)
  To: git, gitster; +Cc: Matthieu Moy

Git-mediawiki's "dumb push" sends the local revisions to the remote wiki,
but does not update the local metadata to reflect the push (hence, the
next pull will have to re-import the exported revisions).

The previous implementation was simply omitting the update to the private
ref after a dumb push. This was broken by 664059fb62 (Felipe Contreras,
Apr 17 2013, transport-helper: update remote helper namespace), which
does an automatic update of the private ref (not just the
remote-tracking) on push.

This patch fixes git-remote-mediawiki to reset the private ref after the
push is completed, cancelling the automatic update triggered by
664059fb62.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
Just a resend of the RFC
( http://thread.gmane.org/gmane.comp.version-control.git/232224 ),
which received no comment.

 contrib/mw-to-git/git-remote-mediawiki.perl | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl
index f8d7d2c..13919ad 100755
--- a/contrib/mw-to-git/git-remote-mediawiki.perl
+++ b/contrib/mw-to-git/git-remote-mediawiki.perl
@@ -53,6 +53,7 @@ if (@ARGV != 2) {
 
 my $remotename = $ARGV[0];
 my $url = $ARGV[1];
+my $reset_private_ref_to = undef;
 
 # Accept both space-separated and multiple keys in config file.
 # Spaces should be written as _ anyway because we'll use chomp.
@@ -161,6 +162,9 @@ sub parse_command {
 	my ($line) = @_;
 	my @cmd = split(/ /, $line);
 	if (!defined $cmd[0]) {
+		if ($reset_private_ref_to) {
+			run_git("update-ref -m \"Git-MediaWiki non-dumb push\" refs/mediawiki/$remotename/master $reset_private_ref_to");
+		}
 		return 0;
 	}
 	if ($cmd[0] eq 'capabilities') {
@@ -1209,9 +1213,10 @@ sub mw_push_revision {
 				die("Unknown error from mw_push_file()\n");
 			}
 		}
-		if (!$dumb_push) {
+		if ($dumb_push) {
+			$reset_private_ref_to = $remoteorigin_sha1;
+		} else {
 			run_git(qq(notes --ref=${remotename}/mediawiki add -f -m "mediawiki_revision: ${mw_revision}" ${sha1_commit}));
-			run_git(qq(update-ref -m "Git-MediaWiki push" refs/mediawiki/${remotename}/master ${sha1_commit} ${sha1_child}));
 		}
 	}
 
-- 
1.8.4.rc2.18.g030d947

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

* [PATCH 2/2] git-remote-mediawiki: add test and check Makefile targets
  2013-08-21  8:10 [PATCH 1/2] git-remote-mediawiki: reset private ref after non-dumb push Matthieu Moy
@ 2013-08-21  8:10 ` Matthieu Moy
  2013-08-21 17:59 ` [PATCH 1/2] git-remote-mediawiki: reset private ref after non-dumb push Junio C Hamano
  1 sibling, 0 replies; 4+ messages in thread
From: Matthieu Moy @ 2013-08-21  8:10 UTC (permalink / raw)
  To: git, gitster; +Cc: Matthieu Moy

There are a few level 4 and 2 perlcritic issues in the current code.
We make level 5 fatal, and keep level 2 as warnings so that "make
check" pass.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
 contrib/mw-to-git/Makefile | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/contrib/mw-to-git/Makefile b/contrib/mw-to-git/Makefile
index 76fcd4d..f206f96 100644
--- a/contrib/mw-to-git/Makefile
+++ b/contrib/mw-to-git/Makefile
@@ -24,6 +24,11 @@ INSTLIBDIR=$(shell $(MAKE) -C $(GIT_ROOT_DIR)/perl \
 
 all: build
 
+test: all
+	$(MAKE) -C t
+
+check: perlcritic test
+
 install_pm:
 	install $(GIT_MEDIAWIKI_PM) $(INSTLIBDIR)/$(GIT_MEDIAWIKI_PM)
 
@@ -41,4 +46,7 @@ clean:
 	rm $(INSTLIBDIR)/$(GIT_MEDIAWIKI_PM)
 
 perlcritic:
-	perlcritic -2 *.perl
+	perlcritic -5 $(SCRIPT_PERL)
+	-perlcritic -2 $(SCRIPT_PERL)
+
+.PHONY: all test check install_pm install clean perlcritic
-- 
1.8.4.rc2.18.g030d947

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

* Re: [PATCH 1/2] git-remote-mediawiki: reset private ref after non-dumb push
  2013-08-21  8:10 [PATCH 1/2] git-remote-mediawiki: reset private ref after non-dumb push Matthieu Moy
  2013-08-21  8:10 ` [PATCH 2/2] git-remote-mediawiki: add test and check Makefile targets Matthieu Moy
@ 2013-08-21 17:59 ` Junio C Hamano
  2013-08-21 20:26   ` Matthieu Moy
  1 sibling, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2013-08-21 17:59 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: git

Matthieu Moy <Matthieu.Moy@imag.fr> writes:

> Git-mediawiki's "dumb push" sends the local revisions to the remote wiki,
> but does not update the local metadata to reflect the push (hence, the
> next pull will have to re-import the exported revisions).
>
> The previous implementation was simply omitting the update to the private
> ref after a dumb push. This was broken by 664059fb62 (Felipe Contreras,
> Apr 17 2013, transport-helper: update remote helper namespace), which
> does an automatic update of the private ref (not just the
> remote-tracking) on push.
>
> This patch fixes git-remote-mediawiki to reset the private ref after the
> push is completed, cancelling the automatic update triggered by
> 664059fb62.
>
> Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
> ---
> Just a resend of the RFC
> ( http://thread.gmane.org/gmane.comp.version-control.git/232224 ),
> which received no comment.
>
>  contrib/mw-to-git/git-remote-mediawiki.perl | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl
> index f8d7d2c..13919ad 100755
> --- a/contrib/mw-to-git/git-remote-mediawiki.perl
> +++ b/contrib/mw-to-git/git-remote-mediawiki.perl
> @@ -53,6 +53,7 @@ if (@ARGV != 2) {
>  
>  my $remotename = $ARGV[0];
>  my $url = $ARGV[1];
> +my $reset_private_ref_to = undef;
>  
>  # Accept both space-separated and multiple keys in config file.
>  # Spaces should be written as _ anyway because we'll use chomp.
> @@ -161,6 +162,9 @@ sub parse_command {
>  	my ($line) = @_;
>  	my @cmd = split(/ /, $line);
>  	if (!defined $cmd[0]) {
> +		if ($reset_private_ref_to) {
> +			run_git("update-ref -m \"Git-MediaWiki non-dumb push\" refs/mediawiki/$remotename/master $reset_private_ref_to");
> +		}

So reset-private-ref-to is recorded for a non-dumb push, but...

>  		return 0;
>  	}
>  	if ($cmd[0] eq 'capabilities') {
> @@ -1209,9 +1213,10 @@ sub mw_push_revision {
>  				die("Unknown error from mw_push_file()\n");
>  			}
>  		}
> -		if (!$dumb_push) {
> +		if ($dumb_push) {
> +			$reset_private_ref_to = $remoteorigin_sha1;

... it is set for dumb-push?  I am confused.

> +		} else {
>  			run_git(qq(notes --ref=${remotename}/mediawiki add -f -m "mediawiki_revision: ${mw_revision}" ${sha1_commit}));
> -			run_git(qq(update-ref -m "Git-MediaWiki push" refs/mediawiki/${remotename}/master ${sha1_commit} ${sha1_child}));
>  		}
>  	}

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

* Re: [PATCH 1/2] git-remote-mediawiki: reset private ref after non-dumb push
  2013-08-21 17:59 ` [PATCH 1/2] git-remote-mediawiki: reset private ref after non-dumb push Junio C Hamano
@ 2013-08-21 20:26   ` Matthieu Moy
  0 siblings, 0 replies; 4+ messages in thread
From: Matthieu Moy @ 2013-08-21 20:26 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Junio C Hamano <gitster@pobox.com> writes:

>> diff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl
>> index f8d7d2c..13919ad 100755
>> --- a/contrib/mw-to-git/git-remote-mediawiki.perl
>> +++ b/contrib/mw-to-git/git-remote-mediawiki.perl
>> @@ -53,6 +53,7 @@ if (@ARGV != 2) {
>>  
>>  my $remotename = $ARGV[0];
>>  my $url = $ARGV[1];
>> +my $reset_private_ref_to = undef;
>>  
>>  # Accept both space-separated and multiple keys in config file.
>>  # Spaces should be written as _ anyway because we'll use chomp.
>> @@ -161,6 +162,9 @@ sub parse_command {
>>  	my ($line) = @_;
>>  	my @cmd = split(/ /, $line);
>>  	if (!defined $cmd[0]) {
>> +		if ($reset_private_ref_to) {
>> +			run_git("update-ref -m \"Git-MediaWiki non-dumb push\" refs/mediawiki/$remotename/master $reset_private_ref_to");
>> +		}
>
> So reset-private-ref-to is recorded for a non-dumb push, but...

> ... it is set for dumb-push?  I am confused.

Oops, I'm the one who did the confusion indeed. It should be
s/non-dumb/dumb/ here and in the subject line.

Don't merge this one, I've fixed locally and will resend (this or
another fix, depending on the outcome of the discussion).

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

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

end of thread, other threads:[~2013-08-21 20:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-21  8:10 [PATCH 1/2] git-remote-mediawiki: reset private ref after non-dumb push Matthieu Moy
2013-08-21  8:10 ` [PATCH 2/2] git-remote-mediawiki: add test and check Makefile targets Matthieu Moy
2013-08-21 17:59 ` [PATCH 1/2] git-remote-mediawiki: reset private ref after non-dumb push Junio C Hamano
2013-08-21 20:26   ` Matthieu Moy

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 NNTP newsgroup(s).