Skip to content

set_tracking_branch fails quietly when .git/config contains an include #1614

Closed
@bodograumann

Description

@bodograumann

I have git-branchless setup in this repository and for the longest time I was confounded, why set_tracking_branch did not work (anymore).
Turns out, git-branchless adds an [include] section to the .git/config file and this causes GitPython to quietly skip writing the config changes back that are necessary for set_tracking_branch to have any effect.

Could we maybe set merge_includes=False for the config_writer; at least in the Head class?

Activity

Byron

Byron commented on Jul 14, 2023

@Byron
Member

A PR with a fix would definitely be welcome. It seems the issue is that configuration that was read with merge_includes can't write itself back to a single file as that would write too much. Maybe there is a way to let set_tracking_branch read its repository configuration without includes, so the writing will work as expected.

bodograumann

bodograumann commented on Jul 17, 2023

@bodograumann
ContributorAuthor

I have looked a bit at git's own config implementation and from what I understand there is a similar option respect_includes there akin to what merge_includes does here.
The respective command-line flag is --includes, but that does not take effect while writing a config setting, leaving respect_includes disabled.

So what we should do here, is to disable merge_includes for the config_writer everywhere as well.
That seems easy enough. It means a slight change to the public API, because in principle a config_writer could have been used to read as well, but I think the upside of following the official git implementation is well worth it.
I'll try sending a PR later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @Byron@bodograumann

      Issue actions

        set_tracking_branch fails quietly when .git/config contains an include · Issue #1614 · gitpython-developers/GitPython