Re: [PATCH 4/4] mw-to-git: use git-credential's URL parser
On Wed, Jul 18, 2012 at 02:24:13PM +0200, Matthieu Moy wrote:
Show 31 quoted lines
> Jeff King <peff@peff.net> writes:
>
> > @@ -216,7 +190,9 @@ sub credential_write {
> > sub credential_run {
> > my $op = shift;
> > my $credential = shift;
> > + my $url = shift;
> > my $pid = open2(my $reader, my $writer, "git credential $op");
> > + print $writer "url=$url\n" if defined $url;
> > credential_write($credential, $writer);
> > print $writer "\n";
> > close($writer);
> > @@ -246,10 +222,10 @@ sub mw_connect_maybe {
> > $mediawiki = MediaWiki::API->new;
> > $mediawiki->{config}->{api_url} = "$url/api.php";
> > if ($wiki_login) {
> > - my %credential = credential_from_url($url);
> > + my %credential;
> > $credential{username} = $wiki_login;
> > $credential{password} = $wiki_passwd;
> > - credential_run("fill", \%credential);
> > + credential_run("fill", \%credential, $url);
> > my $request = {lgname => $credential{username},
> > lgpassword => $credential{password},
> > lgdomain => $wiki_domain};
>
> I would find it more elegant not to special-case the URL field, and just
>
> my %credential = ('url' => $url);
>
> but I'm fine with your version too.I started with a version that did that, but there are two complications:
1. credential_write needs to know that the 'url' field must come
first, as it overwrites the other fields. So we end up
special-casing it either way. 2. Git hands us back the broken-down version, which we add to the
credential. So it is superfluous to keep sending 'url' for the
other, non-fill interactions. I don't think it's technically wrong,
but it also seemed inelegant. Having "credential_write" delete the
'url' field seemed even more inelegant.> Other than that, and for the 4 patches of the serie:
>
> Reviewed-by: Matthieu Moy <Matthieu.Moy@imag.fr>