threads / discuss / 37897

What is the default refspec for fetch?

Subject: What is the default refspec for fetch?

## tl;dr

6 messages between Nov 7, 2014 and Nov 11, 2014.

replies: 5people: 4as markdown or json

Christian Halstrick· Nov 7, 2014, 15:31 UTC · lore
Hi,

In a repo where no remote.<name>.fetch config parameter is set what should a "git fetch" do? My experiments let me think it's "HEAD:FETCH_HEAD". Right?

I came to this question after finding out that when I clone repos in bare mode then they don't have and explicit remote.<name>.fetch in their config. But a "git fetch" sometimes updated "something".

Ciao
  Chris
Jeff King· Nov 8, 2014, 10:52 UTC · re: Christian Halstrick · lore

Re: What is the default refspec for fetch?

On Fri, Nov 07, 2014 at 04:31:08PM +0100, Christian Halstrick wrote:
> In a repo where no remote.<name>.fetch config parameter is set what
> should a "git fetch" do? My experiments let me think it's
> "HEAD:FETCH_HEAD". Right?

Basically, yes. We always write FETCH_HEAD, regardless of the refspec. We choose "HEAD" if no other refspec was provided. So it is really more like

  git fetch $remote HEAD
This is what makes one-off bare-url pulls work, like:
  git pull git://...

It runs fetch under the hood, which writes into FETCH_HEAD, and then we merge that.

-Peff
Jakub Narębski· Nov 8, 2014, 14:35 UTC · re: Jeff King · lore

Re: What is the default refspec for fetch?

W dniu 2014-11-08 11:52, Jeff King pisze:
Show 18 quoted lines
> On Fri, Nov 07, 2014 at 04:31:08PM +0100, Christian Halstrick wrote:
>
>> In a repo where no remote.<name>.fetch config parameter is set what
>> should a "git fetch" do? My experiments let me think it's
>> "HEAD:FETCH_HEAD". Right?
>
> Basically, yes. We always write FETCH_HEAD, regardless of the refspec.
> We choose "HEAD" if no other refspec was provided. So it is really more
> like
>
>    git fetch $remote HEAD
>
> This is what makes one-off bare-url pulls work, like:
>
>    git pull git://...
>
> It runs fetch under the hood, which writes into FETCH_HEAD, and then we
> merge that.

Actually FETCH_HEAD consists of multiple lines, one per ref... but only top ref is merged.

-- 
Jakub Narębski
Junio C Hamano· Nov 9, 2014, 17:23 UTC · re: Jakub Narębski · lore

Re: What is the default refspec for fetch?

Jakub Narębski <jnareb@gmail.com> writes:
Show 22 quoted lines
> W dniu 2014-11-08 11:52, Jeff King pisze:
>> On Fri, Nov 07, 2014 at 04:31:08PM +0100, Christian Halstrick wrote:
>>
>>> In a repo where no remote.<name>.fetch config parameter is set what
>>> should a "git fetch" do? My experiments let me think it's
>>> "HEAD:FETCH_HEAD". Right?
>>
>> Basically, yes. We always write FETCH_HEAD, regardless of the refspec.
>> We choose "HEAD" if no other refspec was provided. So it is really more
>> like
>>
>>    git fetch $remote HEAD
>>
>> This is what makes one-off bare-url pulls work, like:
>>
>>    git pull git://...
>>
>> It runs fetch under the hood, which writes into FETCH_HEAD, and then we
>> merge that.
>
> Actually FETCH_HEAD consists of multiple lines, one per ref...
> but only top ref is merged.

Incorrect in that "only top" is misinformation, and irrelevant in the context of discussing the "what is fetched in a one-off fetch".

Christian Halstrick· Nov 11, 2014, 23:01 UTC · re: Junio C Hamano · lore

Re: What is the default refspec for fetch?

ok, thanks. Then I'll teach JGit to fetch at least "HEAD" if nothing
is configured and nothing explicitly specified as refspec.
Ciao
  Chris
On Sun, Nov 9, 2014 at 6:23 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 27 quoted lines
> Jakub Narębski <jnareb@gmail.com> writes:
>
>> W dniu 2014-11-08 11:52, Jeff King pisze:
>>> On Fri, Nov 07, 2014 at 04:31:08PM +0100, Christian Halstrick wrote:
>>>
>>>> In a repo where no remote.<name>.fetch config parameter is set what
>>>> should a "git fetch" do? My experiments let me think it's
>>>> "HEAD:FETCH_HEAD". Right?
>>>
>>> Basically, yes. We always write FETCH_HEAD, regardless of the refspec.
>>> We choose "HEAD" if no other refspec was provided. So it is really more
>>> like
>>>
>>>    git fetch $remote HEAD
>>>
>>> This is what makes one-off bare-url pulls work, like:
>>>
>>>    git pull git://...
>>>
>>> It runs fetch under the hood, which writes into FETCH_HEAD, and then we
>>> merge that.
>>
>> Actually FETCH_HEAD consists of multiple lines, one per ref...
>> but only top ref is merged.
>
> Incorrect in that "only top" is misinformation, and irrelevant in
> the context of discussing the "what is fetched in a one-off fetch".
Junio C Hamano· Nov 11, 2014, 23:04 UTC · re: Christian Halstrick · lore

Re: What is the default refspec for fetch?

Christian Halstrick <christian.halstrick@gmail.com> writes:
> ok, thanks. Then I'll teach JGit to fetch at least "HEAD" if nothing
> is configured and nothing explicitly specified as refspec.

Sounds like a sensible thing to do to match what JGit does to what we did from the time immemorial ;-)

Thanks.

← back to recent threads