From: Jeff King <peff@peff.net>
To: Michal Nazarewicz <mina86@mina86.com>
Cc: Junio C Hamano <gitster@pobox.com>,
Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>,
git@vger.kernel.org
Subject: Re: [PATCHv3 4/5] Git.pm: add interface for git credential command
Date: Mon, 11 Feb 2013 12:36:32 -0500 [thread overview]
Message-ID: <20130211173632.GJ16402@sigill.intra.peff.net> (raw)
In-Reply-To: <xa1tr4kmg4cv.fsf@mina86.com>
On Mon, Feb 11, 2013 at 06:14:24PM +0100, Michal Nazarewicz wrote:
> > Should this return a hash reference? It seems like that is how we end up
> > using and passing it elsewhere (since we have to anyway when passing it
> > as a parameter).
>
> Admittedly I mostly just copied what git-remote-mediawiki did here and
> don't really have any preference either way, even though with this
> function returning a reference the call site would have to become:
>
> %$credential = %{ credential_read $reader };
Oh, right, because Git::credential takes the credential as an in-out
parameter rather than just returning it. Which is a bit unusual in perl,
but keeps the interface reasonably simple. The alternative would be:
$cred = Git::credential $cred, sub {
...
}
which is a little less nice.
> Another alternative would be for it to take a reference as an argument,
> possibly an optional one:
I think that is making things more ugly.
> I'd avoid modifying the hash while reading though since I think it's
> best if it's left intact in case of an error.
Agreed.
> And of course, if we want to get even more crazy, credential_write could
> accept either reference or a hash, like so:
>
> +sub credential_write {
> + my ($self, $writer, @rest) = _maybe_self(@_);
> + my $credential = @rest == 1 ? $rest[0] : { @rest };
> + my ($key, $value);
> + # ...
> +}
Ugh.
> Bottom line is, anything can be coded, but a question is whether it
> makes sense to do so. ;)
Yes, it is probably OK to leave it as-is, then. It is largely a matter
of taste, and I will defer to your judgement on that. :)
-Peff
next prev parent reply other threads:[~2013-02-11 17:36 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-11 16:23 [PATCHv3 0/5] Add git-credential support to git-send-email Michal Nazarewicz
2013-02-11 16:23 ` [PATCHv3 1/5] Git.pm: allow command_close_bidi_pipe to be called as method Michal Nazarewicz
2013-02-11 16:23 ` [PATCHv3 2/5] Git.pm: fix example in command_close_bidi_pipe documentation Michal Nazarewicz
2013-02-11 16:23 ` [PATCHv3 3/5] Git.pm: allow pipes to be closed prior to calling command_close_bidi_pipe Michal Nazarewicz
2013-02-11 16:23 ` [PATCHv3 4/5] Git.pm: add interface for git credential command Michal Nazarewicz
2013-02-11 16:53 ` Jeff King
2013-02-11 17:14 ` Michal Nazarewicz
2013-02-11 17:36 ` Jeff King [this message]
2013-02-11 16:23 ` [PATCHv3 5/5] git-send-email: use git credential to obtain password Michal Nazarewicz
2013-02-11 17:01 ` Jeff King
2013-02-11 17:17 ` Michal Nazarewicz
2013-02-11 17:31 ` Jeff King
2013-02-11 16:51 ` [PATCHv3 0/5] Add git-credential support to git-send-email Jeff King
2013-02-11 17:18 ` Michal Nazarewicz
2013-02-11 17:48 ` Jeff King
2013-02-11 18:40 ` Michal Nazarewicz
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=20130211173632.GJ16402@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=Matthieu.Moy@grenoble-inp.fr \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=mina86@mina86.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 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).