Subject: Re: [PATCH v2 9/9] fetch: allow explicit --refmap to override configuration

From: Michael Haggerty <[email-masked]>
Date: Wed, 18 Jun 2014 14:21:25 +0200

On 06/05/2014 08:36 PM, Junio C Hamano wrote:
> Marc Branchaud <[email-masked]> writes:
> 
>> I don't have any objection to the option per se.  But I do wonder if there's
>> a need to add yet another knob to git just for completeness.  Has anyone ever
>> needed this?
> 
> It is not a good yardstick, as everybody has survived without it
> since Git's inception.  The right question to ask is: would it help
> new use patterns, or improve existing use patterns?

I agree that this feature is pretty esoteric and probably more cognitive
load than it's worth.  One of your use cases has workarounds shown below.

> Two possible scenarios I can think of offhand are
> 
>  * using an empty refmap to ensure that your "fetch" this time is
>    really ephemeral without affecting the longer-term configured
>    remote-tracking branches

Doesn't specifying an explicit URL get around the refspecs configured
for the remote?  E.g.,

    git fetch $(git config remote.github.url) master

Or if we had a way to temporarily unset multivalued configuration values
(which we may have soon thanks to the GSoC project of Tanay Abhra), one
could use

    git --unset=remote.github.fetch fetch github master

>  * grabbing only a few selected branches out of hundreds, e.g.
> 
>    $ git fetch https://github.com/gitster/git \
>        --refmap=refs/heads/*:refs/remotes/jch/* maint master next +pu
> 
>    instead of having to spell its long-hand
> 
>    $ git fetch https://github.com/gitster/git \
>        refs/heads/maint:refs/remotes/jch/maint \
>        refs/heads/master:refs/remotes/jch/master \
>        refs/heads/next:refs/remotes/jch/next \
>        +refs/heads/pu:refs/remotes/jch/pu

I'm not quite sure what your goal is here, but if you want to fetch some
branches on the fly without setting up a remote, then

    git -c remote.github.fetch='refs/heads/*:refs/remotes/jch/*' \
             fetch https://github.com/gitster/git maint master next +pu

should work, no?

> but there may be more useful scenarios other people can come up
> with ;-).

Michael

-- 
Michael Haggerty
[email-masked]