# [RFC] pull: custom fetch refspecs and fork-point lookup

7 messages from 2026-10-13 to 2026-10-16. Participants: jyotish kumar, Junio C Hamano, Harald Nordgren.
Thread: https://gitlist.dev/t/66518

## jyotish kumar, 2026-10-13 16:01

Subject: [RFC] pull: custom fetch refspecs and fork-point lookup
Message-ID: <CAGjZMyTQt2XEF69pJWHA=diRjoidixGs48E1vA0ytGUgZYOZNQ@mail.gmail.com>
URL: https://gitlist.dev/e/CAGjZMyTQt2XEF69pJWHA%3DdiRjoidixGs48E1vA0ytGUgZYOZNQ%40mail.gmail.com

```
Hi,

While reading `builtin/pull.c`, I came across a FIXME in
`get_tracking_branch()` concerning the assumption that remote branches
follow the default mapping from `refs/heads/<branch>` to
`refs/remotes/<remote>/<branch>`.

I investigated how this assumption relates to custom fetch refspecs
and noticed a potentially subtle issue.

For example, a remote can be configured with the following fetch refspec:

`+refs/heads/*:refs/remotes/origin/custom/*`

With this configuration, the remote-tracking ref for the `main` branch
is `refs/remotes/origin/custom/main`, rather than
`refs/remotes/origin/main`.

Since `get_tracking_branch()` is used by `get_rebase_fork_point()`
when determining the fork point for `git pull --rebase`, I am
wondering whether this assumption could cause the fork-point lookup to
use an incorrect or nonexistent remote-tracking ref when a custom
fetch refspec is configured.

From my investigation of Git's remote and refspec APIs, it seems that
resolving the configured fetch mapping may be a more reliable approach
than assuming the default remote-tracking ref layout.

Does this analysis sound correct? I would appreciate feedback on
whether this is a real issue and whether resolving the configured
fetch mapping would be the right direction to address it.

Thanks!


```

## Junio C Hamano, 2026-10-14 19:07

Subject: Re: [RFC] pull: custom fetch refspecs and fork-point lookup
Message-ID: <xmqq5wz4rthd.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqq5wz4rthd.fsf%40gitster.g
In-Reply-To: <CAGjZMyTQt2XEF69pJWHA=diRjoidixGs48E1vA0ytGUgZYOZNQ@mail.gmail.com>

```
jyotish kumar <jyotishkumar725015@gmail.com> writes:

> While reading `builtin/pull.c`, I came across a FIXME in
> `get_tracking_branch()` concerning the assumption that remote branches
> follow the default mapping from `refs/heads/<branch>` to
> `refs/remotes/<remote>/<branch>`.
> ...
> Does this analysis sound correct? I would appreciate feedback on
> whether this is a real issue and whether resolving the configured
> fetch mapping would be the right direction to address it.

The reason the "FIXME" you noticed exists is that the assumption the
code makes is broken.  Assuming that refs/remotes/<remote>/<branch>
tracks <branch> from <remote> would break when a customized fetch
refspec is used.

I vaguely recall mentioning a similar "map between a remote-tracking
branch and a branch at the remote" issue while discussing a recent
work by Harald to narrow a "git fetch" that does not specify what to
fetch, but I cannot find a mailing list archive reference, sorry.



```

## Harald Nordgren, 2026-10-15 07:17

Subject: Re: [RFC] pull: custom fetch refspecs and fork-point lookup
Message-ID: <CAHwyqnVX+FBbihdXA2jxDoweKv6wnqr_rtb110uqLrzNVRAZfw@mail.gmail.com>
URL: https://gitlist.dev/e/CAHwyqnVX%2BFBbihdXA2jxDoweKv6wnqr_rtb110uqLrzNVRAZfw%40mail.gmail.com
In-Reply-To: <xmqq5wz4rthd.fsf@gitster.g>

```
Yes, seems like a hardcoding bug.

Is this for an in-flight topic that Jyotish is working on, or
something already in master?


Harald


```

## jyotish kumar, 2026-10-15 10:46

Subject: Re: [RFC] pull: custom fetch refspecs and fork-point lookup
Message-ID: <CAGjZMyT=RPJSbJoq=RbdBXNiK1Tn4p8VnyeyzkZ46F=p43i6Pw@mail.gmail.com>
URL: https://gitlist.dev/e/CAGjZMyT%3DRPJSbJoq%3DRbdBXNiK1Tn4p8VnyeyzkZ46F%3Dp43i6Pw%40mail.gmail.com
In-Reply-To: <CAHwyqnVX+FBbihdXA2jxDoweKv6wnqr_rtb110uqLrzNVRAZfw@mail.gmail.com>

```
Hi Harald, Junio,

Thanks for the feedback.

This is an issue I came across while investigating
`get_tracking_branch()` in `builtin/pull.c`. I haven't started working
on a patch yet, and I'm not aware of anyone currently addressing this
issue.

Junio, thanks for pointing out the potentially related discussion. If
you happen to recall any additional details that could help locate it,
that would be helpful.

I will look into the existing discussions and code further before
proceeding with a fix.

Thanks!

On Thu, Oct 15, 2026 at 12:47 PM Harald Nordgren
<haraldnordgren@gmail.com> wrote:
>
> Yes, seems like a hardcoding bug.
>
> Is this for an in-flight topic that Jyotish is working on, or
> something already in master?
>
>
> Harald


```

## Junio C Hamano, 2026-10-15 17:05

Subject: Re: [RFC] pull: custom fetch refspecs and fork-point lookup
Message-ID: <xmqq4iemq4gy.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqq4iemq4gy.fsf%40gitster.g
In-Reply-To: <CAHwyqnVX+FBbihdXA2jxDoweKv6wnqr_rtb110uqLrzNVRAZfw@mail.gmail.com>

```
Harald Nordgren <haraldnordgren@gmail.com> writes:

> Yes, seems like a hardcoding bug.
>
> Is this for an in-flight topic that Jyotish is working on, or
> something already in master?

The former.  You can see the thread in all its glory at

https://lore.kernel.org/git/CAGjZMyTQt2XEF69pJWHA=diRjoidixGs48E1vA0ytGUgZYOZNQ@mail.gmail.com/

which is (still) quite short.



```

## jyotish kumar, 2026-10-16 10:17

Subject: Re: [RFC] pull: custom fetch refspecs and fork-point lookup
Message-ID: <CAGjZMyR7-_T+maSibej8cHn3wdWcYzbuQ94pmHj=MAdp9g-2OQ@mail.gmail.com>
URL: https://gitlist.dev/e/CAGjZMyR7-_T%2BmaSibej8cHn3wdWcYzbuQ94pmHj%3DMAdp9g-2OQ%40mail.gmail.com
In-Reply-To: <xmqq4iemq4gy.fsf@gitster.g>

```
Hi Junio,

Thanks for the follow-up.

I followed the link, but it appears to open this same RFC thread. I
may be missing something, but I couldn't locate the related discussion
you mentioned about mapping remote-tracking branches to branches on
the remote.

Could you point me to the relevant message or provide a few more
details about that discussion? I'd like to understand the existing
context before proceeding with a patch.

Thanks!

On Thu, Oct 15, 2026 at 10:35 PM Junio C Hamano <gitster@pobox.com> wrote:
>
> Harald Nordgren <haraldnordgren@gmail.com> writes:
>
> > Yes, seems like a hardcoding bug.
> >
> > Is this for an in-flight topic that Jyotish is working on, or
> > something already in master?
>
> The former.  You can see the thread in all its glory at
>
> https://lore.kernel.org/git/CAGjZMyTQt2XEF69pJWHA=diRjoidixGs48E1vA0ytGUgZYOZNQ@mail.gmail.com/
>
> which is (still) quite short.
>


```

## Junio C Hamano, 2026-10-16 15:02

Subject: Re: [RFC] pull: custom fetch refspecs and fork-point lookup
Message-ID: <xmqqv771it93.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqqv771it93.fsf%40gitster.g
In-Reply-To: <CAGjZMyR7-_T+maSibej8cHn3wdWcYzbuQ94pmHj=MAdp9g-2OQ@mail.gmail.com>

```
jyotish kumar <jyotishkumar725015@gmail.com> writes:

> Hi Junio,
>
> Thanks for the follow-up.
>
> I followed the link, but it appears to open this same RFC thread.

What you are missing is the recipient of the message you are looking
at.  It was answering question by Harald, who asked if the issue
(which I asked him to take a look to see if earlier discussion with
him was relevant) is a topic you are working on or something else,
and the URL was part of answering that it is the former.  Of course,
it would link back to this thread ;-).



```
