@@ -52,6 +52,36 @@ def _patch_git_config(name, value):
5252 yield
5353
5454
55+ @pytest .mark .parametrize (
56+ "name" , ["module" , "$GITPYTHON_TEST_SECRET" , "prefix-${GITPYTHON_TEST_SECRET}-suffix" , "%GITPYTHON_TEST_SECRET%" ]
57+ )
58+ def test_submodule_update_preserves_literal_name (tmp_path , monkeypatch , caplog , name ):
59+ monkeypatch .setenv ("GITPYTHON_TEST_SECRET" , "sensitive-value" )
60+ caplog .set_level ("DEBUG" , logger = "git.cmd" )
61+ with git .Repo .init (tmp_path / "source" ) as source , git .Repo .init (tmp_path / "parent" ) as parent :
62+ source .git .symbolic_ref ("HEAD" , "refs/heads/master" )
63+ source .index .commit ("Initial commit" )
64+ with _patch_git_config ("protocol.file.allow" , "always" ):
65+ parent .git .submodule ("add" , "--name" , name , source .working_tree_dir , "module" )
66+ parent .index .commit ("Add submodule" )
67+
68+ with git .Repo .clone_from (parent .working_tree_dir , tmp_path / "clone" ) as clone :
69+ clone .submodule_update (init = True , recursive = True )
70+
71+ modules_dir = Path (clone .git_dir , "modules" )
72+ assert {path .name for path in modules_dir .iterdir ()} == {name }
73+ # Exercise relative gitfile conversion on every platform.
74+ with mock .patch .object (Git , "is_cygwin" , return_value = True ):
75+ resolved_git_dir = find_submodule_git_dir (Path (clone .working_tree_dir , "module" , ".git" ))
76+ assert resolved_git_dir is not None
77+ assert (modules_dir / name ).samefile (resolved_git_dir )
78+ with clone .submodules [0 ].module () as module :
79+ assert (modules_dir / name ).samefile (module .git_dir )
80+ assert module .head .commit == source .head .commit
81+
82+ assert "sensitive-value" not in caplog .text
83+
84+
5585@pytest .fixture
5686def movable_submodule (tmp_path ):
5787 """Create a committed local submodule whose logical name stays fixed when moved."""
0 commit comments