git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 04/12] remote.c: provide per-branch pushremote name

From
Eric Sunshine <sunshine@sunshineco.com>
Date
May 8, 2015, 16:13 UTC
Message-ID
<CAPig+cTZsUYAY_1f+0ieBuaRw9A-wSAKmpJ9Wj1kUuo=QBCNNw@mail.gmail.com>
In-Reply-To
<20150507093836.GB14524@peff.net>
On Thu, May 7, 2015 at 5:38 AM, Jeff King <peff@peff.net> wrote:
Show 16 quoted lines
> 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:
Nice, I like it.
Show 44 quoted lines
> -- >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
Previous: Jeff KingNext: Jeff King
Message 13 of 21 in “implement @{push} shorthand”
  1. 0/12 implement @{push} shorthandJeff King, May 1, 2015
  2. 01/12 remote.c: drop default_remote_name variableJeff King, May 1, 2015
  3. 02/12 remote.c: drop "remote" pointer from "struct branch"Jeff King, May 1, 2015
  4. Eric SunshineMay 3, 2015
  5. Jeff KingMay 5, 2015
  6. Jeff KingMay 7, 2015
  7. 03/12 remote.c: hoist branch.*.remote lookup out of remote_get_1Jeff King, May 1, 2015
  8. 04/12 remote.c: provide per-branch pushremote nameJeff King, May 1, 2015
  9. Eric SunshineMay 3, 2015
  10. Jeff KingMay 5, 2015
  11. Eric SunshineMay 5, 2015
  12. Jeff KingMay 7, 2015
  13. Eric SunshineMay 8, 2015
  14. 05/12 remote.c: introduce branch_get_upstream helperJeff King, May 1, 2015
  15. 06/12 remote.c: report specific errors from branch_get_upstreamJeff King, May 1, 2015
  16. 07/12 remote.c: add branch_get_pushJeff King, May 1, 2015
  17. 08/12 sha1_name: refactor upstream_markJeff King, May 1, 2015
  18. 09/12 sha1_name: refactor interpret_upstream_markJeff King, May 1, 2015
  19. 10/12 sha1_name: implement @{push} shorthandJeff King, May 1, 2015
  20. 11/12 for-each-ref: use skip_prefix instead of starts_withJeff King, May 1, 2015
  21. 12/12 for-each-ref: accept "%(push)" formatJeff King, May 1, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.