From: Jeff King <peff@peff•net>
To: Eric Sunshine <sunshine@sunshineco•com>
Cc: Git List <git@vger•kernel.org>
Subject: Re: [PATCH 04/12] remote.c: provide per-branch pushremote name
Date: Thu, 7 May 2015 05:38:37 -0400 [thread overview]
Message-ID: <20150507093836.GB14524@peff.net> (raw)
In-Reply-To: <CAPig+cQ+AbgTXAWKaN4obdGLWFDxjfr4yAaJZgvnLLzzoqdPRQ@mail.gmail.com>
On Tue, May 05, 2015 at 03:48:29PM -0400, Eric Sunshine wrote:
> > Yeah, it's just that it goes in the opposite direction I was trying for,
> > which is to have as little code as possible in the wrapper functions (in
> > fact, I think after my changes you could even bump the read_config()
> > call into remote_get_1; before my changes, it depended on the pushremote
> > config being set before the call).
>
> I also noticed that read_config() could be moved into remote_get_1().
> In fact, with that change, then the wrappers really do collapse nicely
> to 1-liners, so the "clever" function pointer approach probably is
> cleaner; and it's nicely generalized over the previous round with the
> boolean argument to remote_get_1().
I ended up with this patch, which will go right after the one we're
discussing:
-- >8 --
Subject: remote.c: hoist read_config into remote_get_1
Before the previous commit, we had to make sure that
read_config() was called before entering remote_get_1,
because we needed to pass pushremote_name by value. But now
that we pass a function, we can let remote_get_1 handle
loading the config itself, turning our wrappers into true
one-liners.
Signed-off-by: Jeff King <peff@peff•net>
---
remote.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/remote.c b/remote.c
index a91d063..e6b29b3 100644
--- a/remote.c
+++ b/remote.c
@@ -718,6 +718,8 @@ static struct remote *remote_get_1(const char *name,
struct remote *ret;
int name_given = 0;
+ read_config();
+
if (name)
name_given = 1;
else
@@ -741,13 +743,11 @@ static struct remote *remote_get_1(const char *name,
struct remote *remote_get(const char *name)
{
- read_config();
return remote_get_1(name, remote_for_branch);
}
struct remote *pushremote_get(const char *name)
{
- read_config();
return remote_get_1(name, pushremote_for_branch);
}
--
2.4.0.488.gf55b16a
next prev parent reply other threads:[~2015-05-07 9:38 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-01 22:44 [PATCH v2 0/12] implement @{push} shorthand Jeff King
2015-05-01 22:44 ` [PATCH 01/12] remote.c: drop default_remote_name variable Jeff King
2015-05-01 22:45 ` [PATCH 02/12] remote.c: drop "remote" pointer from "struct branch" Jeff King
2015-05-03 3:34 ` Eric Sunshine
2015-05-05 19:31 ` Jeff King
2015-05-07 9:33 ` Jeff King
2015-05-01 22:45 ` [PATCH 03/12] remote.c: hoist branch.*.remote lookup out of remote_get_1 Jeff King
2015-05-01 22:46 ` [PATCH 04/12] remote.c: provide per-branch pushremote name Jeff King
2015-05-03 4:51 ` Eric Sunshine
2015-05-05 19:33 ` Jeff King
2015-05-05 19:48 ` Eric Sunshine
2015-05-07 9:38 ` Jeff King [this message]
2015-05-08 16:13 ` Eric Sunshine
2015-05-01 22:47 ` [PATCH 05/12] remote.c: introduce branch_get_upstream helper Jeff King
2015-05-01 22:52 ` [PATCH 06/12] remote.c: report specific errors from branch_get_upstream Jeff King
2015-05-01 22:53 ` [PATCH 07/12] remote.c: add branch_get_push Jeff King
2015-05-01 22:53 ` [PATCH 08/12] sha1_name: refactor upstream_mark Jeff King
2015-05-01 22:55 ` [PATCH 09/12] sha1_name: refactor interpret_upstream_mark Jeff King
2015-05-01 22:55 ` [PATCH 10/12] sha1_name: implement @{push} shorthand Jeff King
2015-05-01 22:55 ` [PATCH 11/12] for-each-ref: use skip_prefix instead of starts_with Jeff King
2015-05-01 22:56 ` [PATCH 12/12] for-each-ref: accept "%(push)" format Jeff King
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=20150507093836.GB14524@peff.net \
--to=peff@peff$(echo .)net \
--cc=git@vger$(echo .)kernel.org \
--cc=sunshine@sunshineco$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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