threads / rfc / 66518

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

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

## tl;dr

7 messages between Oct 13, 2026 and Oct 16, 2026.

replies: 6people: 3as markdown or json

jyotish kumar· Oct 13, 2026, 16:01 UTC · lore
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· Oct 14, 2026, 19:07 UTC · re: jyotish kumar · lore

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

jyotish kumar <jyotishkumar725015@gmail.com> writes:
Show 8 quoted lines
> 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.

jyotish kumar· Oct 15, 2026, 10:46 UTC · re: Harald Nordgren · lore

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

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:

Show 8 quoted lines
>
> 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· Oct 15, 2026, 17:05 UTC · re: Harald Nordgren · lore

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

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· Oct 16, 2026, 10:17 UTC · re: Junio C Hamano · lore

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

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:
Show 14 quoted lines
>
> 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· Oct 16, 2026, 15:02 UTC · re: jyotish kumar · lore

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

jyotish kumar <jyotishkumar725015@gmail.com> writes:
Show 5 quoted lines
> 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 ;-).

← back to recent threads