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

Re: [PATCH 4/6] remote.c: introduce a way to have different remotes for fetch/push

From
Ramkumar Ramachandra <artagnon@gmail.com>
Date
Mar 23, 2013, 13:18 UTC
Message-ID
<CALkWK0npDrfcSDCX2OrUh1yNnKDa--04YT5UjAkbbG9HO4g-Zw@mail.gmail.com>
In-Reply-To
<20130322234108.GL12223@google.com>
Jonathan Nieder wrote:
Show 20 quoted lines
> Junio C Hamano wrote:
>> Jonathan Nieder <jrnieder@gmail.com> writes:
>
>>>> -   struct remote *remote = remote_get(repo);
>>>> +   struct remote *remote = pushremote_get(repo);
>>>
>>> "struct remote" has url and pushurl fields.  What do they mean in the
>>> context of these two accessors?  /me is confused.
>>>
>>> Is the idea that now I should not use pushurl any more, and that I
>>> should use pushremote_get and use url instead?
> [...]
>>               At the programming level, you would still ask what the
>> URL to be pushed to to the remote obtained here, and would use
>> pushurl if defined, or url otherwise.
>
> Ah, I think I see.  It might be more convenient to the caller if
> pushremote_get returned a remote with url set to the pushurl, but
> that would prevent sharing the struct with other callers that want
> that remote for fetching.

We started off with a generic "remote" (for both fetching and pushing), then added .pushurl on top of this remote. Now we've introduced something called a pushremote, a logically distinct remote from "remote"; pushremote_get() is meant to return this logically different remote, falling back to the remote_get() codepath if not present. This is a perfect migration that trivially preserves backward compatibility.

Show 19 quoted lines
> So instead, the idea is something like
>
>         remote: support a different default remote for pushing
>
>         Teach remote_get() to accept an argument FOR_FETCH or FOR_PUSH
>         that determines, when no remote is passed to it, whether to use
>         the default remote for fetching or the default for pushing.
>
>         The default remote for fetching is stored in the static var
>         "default_remote_name", while the default for pushing, if set,
>         is in "default_push_remote_name".
>
>         Currently there is never a different default for pushing set
>         but later patches will change that.
>
> If remote_get() gained a new required parameter, that would force all
> call sites to be examined (even any potential call sites added by new
> patches in flight) and there would no longer be need for the
> remote_get_1() function.

I like this, but let's save it for a future patch as it requires some extensive refactoring.

Previous: Jonathan NiederNext: Ramkumar Ramachandra
Message 18 of 24 in “Support triangular workflows”
  1. 0/6 Support triangular workflowsRamkumar Ramachandra, Mar 22, 2013
  2. 1/6 remote.c: simplify a bit of code using git_config_string()Ramkumar Ramachandra, Mar 22, 2013
  3. Jonathan NiederMar 22, 2013
  4. 2/6 t5516 (fetch-push): update test descriptionRamkumar Ramachandra, Mar 22, 2013
  5. Jonathan NiederMar 22, 2013
  6. 3/6 t5516 (fetch-push): introduce mk_test_with_name()Ramkumar Ramachandra, Mar 22, 2013
  7. Jeff KingMar 22, 2013
  8. Junio C HamanoMar 22, 2013
  9. Jeff KingMar 22, 2013
  10. Jonathan NiederMar 22, 2013
  11. Ramkumar RamachandraMar 28, 2013
  12. Junio C HamanoMar 22, 2013
  13. Jeff KingMar 22, 2013
  14. 4/6 remote.c: introduce a way to have different remotes for fetch/pushRamkumar Ramachandra, Mar 22, 2013
  15. Jonathan NiederMar 22, 2013
  16. Junio C HamanoMar 22, 2013
  17. Jonathan NiederMar 22, 2013
  18. Ramkumar RamachandraMar 23, 2013
  19. Ramkumar RamachandraMar 23, 2013
  20. 5/6 remote.c: introduce remote.pushdefaultRamkumar Ramachandra, Mar 22, 2013
  21. Jeff KingMar 22, 2013
  22. Ramkumar RamachandraMar 27, 2013
  23. 6/6 remote.c: introduce branch.<name>.pushremoteRamkumar Ramachandra, Mar 22, 2013
  24. Junio C HamanoMar 22, 2013

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.