git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] fetch.c: defer fetch.followRemoteHEAD validation

From
Colin Hinton <colinlewishinton@gmail.com>
Date
Sep 25, 2026, 20:30 UTC
Message-ID
<CAHeTm9Pb-fb-ZS_m4UVNZxfp+ENQwBUGDvP1E24dEDTZy5RFFw@mail.gmail.com>
In-Reply-To
<xmqqo6dlt906.fsf@gitster.g>
On Fri, Sep 25, 2026 at 12:40 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 32 quoted lines
>
> Colin Hinton <colinlewishinton@gmail.com> writes:
>
> >  struct fetch_config {
> >       enum display_format display_format;
> > -     enum follow_remote_head_settings follow_remote_head;
> > +     char *follow_remote_head_raw;
> >       int all;
> >       int prune;
> >       int prune_tags;
> > @@ -176,24 +176,31 @@ static int git_fetch_config(const char *k, const char *v,
> >       }
> >
> >       if (!strcmp(k, "fetch.followremotehead")) {
> > -             if (!v)
> > -                     return config_error_nonbool(k);
> > -             else if (!strcmp(v, "never"))
> > -                     fetch_config->follow_remote_head = FOLLOW_REMOTE_NEVER;
> > -             else if (!strcmp(v, "create"))
> > -                     fetch_config->follow_remote_head = FOLLOW_REMOTE_CREATE;
> > -             else if (!strcmp(v, "warn"))
> > -                     fetch_config->follow_remote_head = FOLLOW_REMOTE_WARN;
> > -             else if (!strcmp(v, "always"))
> > -                     fetch_config->follow_remote_head = FOLLOW_REMOTE_ALWAYS;
> > -             else
> > -                     warning(_("unrecognized fetch.followRemoteHEAD value '%s' ignored"), v);
> > +             free(fetch_config->follow_remote_head_raw);
> > +             fetch_config->follow_remote_head_raw = xstrdup(v);
>
> This will segfault when !v, so
>
>         fetch_config->follow_remote_head_raw = xstrdup_or_null(v);
Will change shortly.
Show 26 quoted lines
>
> With that change,
>
> > +static enum follow_remote_head_settings get_follow_remote_head(const char *setting)
> > +{
> > +     if (!setting)
> > +             die(_("missing value for 'fetch.followRemoteHEAD'"));
> > +     else if (!strcmp(setting, "never"))
> > +             return FOLLOW_REMOTE_NEVER;
> > +     else if (!strcmp(setting, "create"))
> > +             return FOLLOW_REMOTE_CREATE;
> > +     else if (!strcmp(setting, "warn"))
> > +             return FOLLOW_REMOTE_WARN;
> > +     else if (!strcmp(setting, "always"))
> > +             return FOLLOW_REMOTE_ALWAYS;
> > +     warning(_("unrecognized fetch.followRemoteHEAD value '%s' ignored"), setting);
> > +     return FOLLOW_REMOTE_UNCONFIGURED;
> > +}
>
> This would do a reasonable job.
>
> We should do something similar to what remote.c parses for
> consistency, but other than that, it seems this topic is moving in
> the right direction.
>
> Thanks.

The only critical difference I see in the configuration parse between remote.c and fetch.c is the case for "warn-if-not-$branch". From reading the git-config manpage, this is only a setting for a remote and not for fetch directly so I do not see a reason to check this in fetch.c. Perhaps I am missing something else to make this more consistent, or perhaps there is an argument to support the configuration for fetch to "warn-if-not-$branch" in which case can be added to this patch.

-Colin Hinton
Previous: Junio C HamanoNext: Matt Hunter
Message 9 of 22 in “fetch.c: defer fetch.followRemoteHEAD validation”
  1. fetch.c: defer fetch.followRemoteHEAD validationColin Hinton, Sep 22, 2026
  2. Junio C HamanoSep 22, 2026
  3. Colin HintonSep 23, 2026
  4. Matt HunterSep 24, 2026
  5. Colin HintonSep 25, 2026
  6. Matt HunterSep 24, 2026
  7. fetch.c: defer fetch.followRemoteHEAD validationColin Hinton, Sep 25, 2026
  8. Junio C HamanoSep 25, 2026
  9. Colin HintonSep 25, 2026
  10. Matt HunterSep 30, 2026
  11. Junio C HamanoSep 30, 2026
  12. Colin HintonOct 3, 2026
  13. fetch.c: defer fetch.followRemoteHEAD validationColin Hinton, Sep 25, 2026
  14. fetch.c: defer fetch.followRemoteHEAD validationColin Hinton, Oct 3, 2026
  15. Junio C HamanoOct 4, 2026
  16. Colin HintonOct 4, 2026
  17. Junio C HamanoOct 4, 2026
  18. fetch.c: defer fetch.followRemoteHEAD validationColin Hinton, Oct 4, 2026
  19. Matt HunterOct 5, 2026
  20. Junio C HamanoOct 5, 2026
  21. fetch.c: defer fetch.followRemoteHEAD validationColin Hinton, Oct 6, 2026
  22. Junio C HamanoOct 7, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.