Re: [PATCH 2/4] remote.c: introduce a way to have different remotes for fetch/ push
- From
Ramkumar Ramachandra <artagnon@gmail.com>
- Date
- Mar 18, 2013, 14:56 UTC
- Message-ID
- <CALkWK0mc3HN4jT24QKP2Bt49fPtSd4=3wO0xFA7-4gt2n7ih-g@mail.gmail.com>
- In-Reply-To
- <20130318143121.GB23075@sigill.intra.peff.net>
Jeff King wrote:
Show 49 quoted lines
> On Mon, Mar 18, 2013 at 06:46:13PM +0530, Ramkumar Ramachandra wrote:
>
>> +struct remote *remote_get(const char *name)
>> +{
>> + int name_given = 0;
>> +
>> + read_config();
>> + if (name)
>> + name_given = 1;
>> + else {
>> + name = default_remote_name;
>> + name_given = explicit_default_remote_name;
>> + }
>> + return remote_get_1(name, name_given);
>> +}
>> +
>> +struct remote *pushremote_get(const char *name)
>> +{
>> + int name_given = 0;
>> +
>> + read_config();
>> + if (name)
>> + name_given = 1;
>> + else {
>> + if (pushremote_name) {
>> + name = pushremote_name;
>> + name_given = 1;
>> + } else {
>> + name = default_remote_name;
>> + name_given = explicit_default_remote_name;
>> + }
>> + }
>> + return remote_get_1(name, name_given);
>> +}
>
> Can we get rid of this duplication by having remote_get_1 take a
> service-specific default argument? And then each service calls it like:
>
> struct remote *remote_get(const char *name)
> {
> read_config();
> return remote_get_1(name, NULL);
> }
>
> struct remote *pushremote_get(const char *name)
> {
> read_config();
> return remote_get_1(name, pushremote_name);
> }Thanks for the dose of sanity. While at it, why not move read_config() to remote_get_1() as well?