Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1c8310d

Browse files
authored
Merge pull request #1618 from bodograumann/fix-set-tracking-branch-with-imports
Disable merge_includes in config writers
2 parents b543c72 + 41ecc6a commit 1c8310d

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

‎git/repo/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ def config_writer(self, config_level: Lit_config_levels = "repository") -> GitCo
600600
system = system wide configuration file
601601
global = user level configuration file
602602
repository = configuration file for this repository only"""
603-
return GitConfigParser(self._get_config_path(config_level), read_only=False, repo=self)
603+
return GitConfigParser(self._get_config_path(config_level), read_only=False, repo=self, merge_includes=False)
604604

605605
def commit(self, rev: Union[str, Commit_ish, None] = None) -> Commit:
606606
"""The Commit object for the specified revision

‎test/test_refs.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
SymbolicReference,
1616
GitCommandError,
1717
RefLog,
18+
GitConfigParser,
1819
)
1920
from git.objects.tag import TagObject
2021
from test.lib import TestBase, with_rw_repo
@@ -172,6 +173,26 @@ def test_heads(self, rwrepo):
172173
assert log[0].oldhexsha == pcommit.NULL_HEX_SHA
173174
assert log[0].newhexsha == pcommit.hexsha
174175

176+
@with_rw_repo("HEAD", bare=False)
177+
def test_set_tracking_branch_with_import(self, rwrepo):
178+
# prepare included config file
179+
included_config = osp.join(rwrepo.git_dir, "config.include")
180+
with GitConfigParser(included_config, read_only=False) as writer:
181+
writer.set_value("test", "value", "test")
182+
assert osp.exists(included_config)
183+
184+
with rwrepo.config_writer() as writer:
185+
writer.set_value("include", "path", included_config)
186+
187+
for head in rwrepo.heads:
188+
head.set_tracking_branch(None)
189+
assert head.tracking_branch() is None
190+
remote_ref = rwrepo.remotes[0].refs[0]
191+
assert head.set_tracking_branch(remote_ref) is head
192+
assert head.tracking_branch() == remote_ref
193+
head.set_tracking_branch(None)
194+
assert head.tracking_branch() is None
195+
175196
def test_refs(self):
176197
types_found = set()
177198
for ref in self.rorepo.refs:

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /