All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>
To: Sverre Rabbelier <srabbelier@gmail.com>
Cc: git@vger.kernel.org, gitster@pobox.com,
	Jeremie Nikaes <jeremie.nikaes@ensimag.imag.fr>,
	Arnaud Lacurie <arnaud.lacurie@ensimag.imag.fr>,
	Claire Fousse <claire.fousse@ensimag.imag.fr>,
	David Amouyal <david.amouyal@ensimag.imag.fr>
Subject: Re: [PATCH v6] Add a remote helper to interact with mediawiki (fetch & push)
Date: Wed, 31 Aug 2011 19:30:25 +0200	[thread overview]
Message-ID: <vpq7h5tbia6.fsf@bauges.imag.fr> (raw)
In-Reply-To: <CAGdFq_gu=SyjUnUS1bcjPrcPPtKVt+UjDBvBmZqosk+OuDFDHw@mail.gmail.com> (Sverre Rabbelier's message of "Wed, 31 Aug 2011 19:03:54 +0200")

Sverre Rabbelier <srabbelier@gmail.com> writes:

> Heya,
>
> 2011/8/31 Matthieu Moy <Matthieu.Moy@imag.fr>:
>> So, after understanding better how import works, here's an updated
>> patch that gets rid of the hacky workaround to terminate and send the
>> "done" command at the right time.
>
> So what do you think of the way the protocol works now? Do you agree
> that (modulo lacking docs) it is better than previously?

I'm not sure I understood exactly how it was before, but the current
protocol seems indeed at least reasonable:

* It's possible to specify a batch of imports, so the remote-helper has
  freedom to optimize the import of multiple refs.

* A batch of import is clearly delimited, both on stdin and stdout, so
  it is possible to alternate import batches and other commands.

I still have a few complaints, because even with a better doc, I still
found the debugging a bit hard. To make it easy for remote-helpers
authors, I think the transport-helper could have an explicit "done"
command, so that the command stream look like

import foo
import bar
\n
done

instead of

import foo
import bar
\n
\n

and to let the remote-helper's code be like

while($cmd = <read command>) {
   if ($cmd eq "command1") {
       do something;
   } elsif ($cmd eq "command2") {
       something else;
   } elsif ($cmd eq "done") {
       exit properly;
   }
}

I'm not sure whether changing this now is worth the trouble though.

I'd have appreciated if the transport-helper had given me an explicit
error message when writting to a broken pipe too. I finally got it with
gdb, but lost some time trying to understand (especially painfull since
there was a race condition between the remote-helper termination and git
writting to it, so the bug wasn't reproducible).

>> Actually, push had the same problem but it just went unnoticed (the
>> remote has just one branch, so it's silly to try to push multiple
>> branches at the same time ...). This version handles push more
>> cleanly, giving accurate error message in cases like
>>
>>  git push origin :master
>>  git push origin foo bar master
>>
>> or perhaps more commonly
>>
>>  git push --all
>>
>> in a repository with branches other than master.
>
> My perl skills are minimal, but I'm curious how/where you implemented
> this?

Here:

+	for my $refspec (@refsspecs) {
+		unless ($refspec =~ m/^(\+?)([^:]*):([^:]*)$/) {
+			die("Invalid refspec for push. Expected <src>:<dst> or +<src>:<dst>");
+		}
+		my ($force, $local, $remote) = ($1 eq "+", $2, $3);

At this point, $force is a boolean saying whether there were a +, and
$local and $remote are as you can guess.

+		if ($force) {
+			print STDERR "Warning: forced push not allowed on a MediaWiki.\n";
+		}
+		if ($local eq "") {
+			print STDERR "Cannot delete remote branch on a MediaWiki\n";
+			print STDOUT "error $remote cannot delete\n";

print STDERR goes to the console (i.e. to the user), and print STDOUT
goes to the Git's transport-helper.

+			next;
+		}
+		if ($remote ne "refs/heads/master") {
+			print STDERR "Only push to the branch 'master' is supported on a MediaWiki\n";
+			print STDOUT "error $remote only master allowed\n";
+			next;
+		}

> Is this something that we can port to remote-testgit to document the
> CPB on handling such things?

CPB = ?

Actually, my case is very particular, since the only thing to do with
branches is to make sure the user doesn't use them. In remote-testgit,
there are actually branches.

And testgit use the undocumented "export" feature, which does not seem
to support branch deletion:

git push origin :branch2
fatal: remote-helpers do not support ref deletion
moy@bauges:/tmp/clone$ Traceback (most recent call last):
  File "/home/moy/local/usr-squeeze/libexec/git-core/git-remote-testgit", line 252, in <module>
    sys.exit(main(sys.argv))
  File "/home/moy/local/usr-squeeze/libexec/git-core/git-remote-testgit", line 249, in main
    more = read_one_line(repo)
  File "/home/moy/local/usr-squeeze/libexec/git-core/git-remote-testgit", line 215, in read_one_line
    sys.stdout.flush()
IOError: [Errno 32] Broken pipe

(This comes from

transport-helper.c:750:                 die("remote-helpers do not support ref deletion");

called before starting the exporter)

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

  reply	other threads:[~2011-08-31 17:31 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-26 17:11 [PATCH 1/2] fast-import: initialize variable require_explicit_termination Matthieu Moy
2011-08-26 17:11 ` [PATCH 2/2] Add a remote helper to interact with mediawiki (fetch & push) Matthieu Moy
2011-08-26 17:53   ` Junio C Hamano
2011-08-29  5:42     ` Sverre Rabbelier
2011-08-29  6:05       ` Junio C Hamano
2011-08-29  6:41         ` Sverre Rabbelier
2011-08-30  3:56           ` Jonathan Nieder
2011-08-30 17:13             ` Junio C Hamano
2011-08-31 11:54             ` Matthieu Moy
2011-09-01 23:44               ` Jonathan Nieder
2011-08-31 12:05           ` done feature in remote-helpers (was Re: [PATCH 2/2] Add a remote helper to interact with mediawiki (fetch & push)) Matthieu Moy
2011-08-31 12:17             ` Sverre Rabbelier
2011-08-31 12:55               ` Matthieu Moy
2011-08-31 12:58                 ` Sverre Rabbelier
2011-08-31 13:12                   ` Matthieu Moy
2011-08-31 13:16                     ` Sverre Rabbelier
2011-08-31 16:47                       ` [PATCH] git-remote-helpers.txt: explain how import works with multiple refs Matthieu Moy
2011-08-31 18:14                         ` [PATCH] (short) documentation for the testgit remote helper Matthieu Moy
2011-09-01 11:27                           ` Sverre Rabbelier
2011-09-01 15:52                             ` Matthieu Moy
2011-09-01 16:49                               ` [PATCH 1/2 v2] Documentation/git-remote-helpers: explain how import works with multiple refs Matthieu Moy
2011-09-01 16:49                                 ` [PATCH 2/2 v2] (short) documentation for the testgit remote helper Matthieu Moy
2011-09-01 16:59                                   ` Sverre Rabbelier
2011-09-01 16:59                                 ` [PATCH 1/2 v2] Documentation/git-remote-helpers: explain how import works with multiple refs Sverre Rabbelier
2011-09-01 11:24                         ` [PATCH] git-remote-helpers.txt: " Sverre Rabbelier
2011-09-01 23:17                         ` Jonathan Nieder
2011-09-03 10:35                           ` Matthieu Moy
2011-08-26 17:55   ` [PATCH v5] Add a remote helper to interact with mediawiki (fetch & push) Matthieu Moy
2011-08-31 16:55     ` [PATCH v6] " Matthieu Moy
2011-08-31 17:03       ` Sverre Rabbelier
2011-08-31 17:30         ` Matthieu Moy [this message]
2011-09-01  0:24           ` Junio C Hamano
2011-09-01  5:26             ` Matthieu Moy
2011-09-01 16:54               ` [PATCH 0/2] Git-MediaWiki Matthieu Moy
2011-09-01 16:54                 ` [PATCH 1/2 v7] Add a remote helper to interact with mediawiki (fetch & push) Matthieu Moy
2011-09-01 16:54                 ` [PATCH 2/2] git-remote-mediawiki: allow push to set MediaWiki metadata Matthieu Moy
2011-08-31 12:33   ` Clean termination of remote-helpers (was Re: [PATCH 2/2] Add a remote helper to interact with mediawiki (fetch & push)) Matthieu Moy
2011-08-31 13:25     ` Sverre Rabbelier
2011-08-31 14:53       ` Matthieu Moy
2011-08-31 15:00         ` Sverre Rabbelier
2011-08-26 17:51 ` [PATCH 1/2] fast-import: initialize variable require_explicit_termination Junio C Hamano
2011-08-26 17:59   ` Matthieu Moy
2011-08-26 18:55     ` Junio C Hamano

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=vpq7h5tbia6.fsf@bauges.imag.fr \
    --to=matthieu.moy@grenoble-inp.fr \
    --cc=arnaud.lacurie@ensimag.imag.fr \
    --cc=claire.fousse@ensimag.imag.fr \
    --cc=david.amouyal@ensimag.imag.fr \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jeremie.nikaes@ensimag.imag.fr \
    --cc=srabbelier@gmail.com \
    /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.