You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
set_tracking_branch fails quietly when .git/config contains an include #1614
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?
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.
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.
Activity
Byron commentedon Jul 14, 2023
A PR with a fix would definitely be welcome. It seems the issue is that configuration that was read with
merge_includescan't write itself back to a single file as that would write too much. Maybe there is a way to letset_tracking_branchread its repository configuration without includes, so the writing will work as expected.bodograumann commentedon Jul 17, 2023
I have looked a bit at git's own config implementation and from what I understand there is a similar option
respect_includesthere akin to whatmerge_includesdoes here.The respective command-line flag is
--includes, but that does not take effect while writing a config setting, leavingrespect_includesdisabled.So what we should do here, is to disable
merge_includesfor theconfig_writereverywhere 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.