@@ -30,12 +30,26 @@ def checkout(tmp_path):
3030 root = tmp_path / "checkout space$#"
3131 root .mkdir ()
3232 git (root , "init" )
33+ git (
34+ root ,
35+ "-c" ,
36+ "user.name=Link Test" ,
37+ "-c" ,
38+ 39+ "-c" ,
40+ "commit.gpgsign=false" ,
41+ "commit" ,
42+ "--allow-empty" ,
43+ "-m" ,
44+ "Initial test revision" ,
45+ )
3346 return root
3447
3548
3649def remote (root , alias , url , branch = None ):
3750 git (root , "remote" , "add" , alias , url )
3851 if branch is not None :
52+ git (root , "update-ref" , f"refs/remotes/{ alias } /{ branch } " , "HEAD" )
3953 git (root , "symbolic-ref" , f"refs/remotes/{ alias } /HEAD" , f"refs/remotes/{ alias } /{ branch } " )
4054
4155
@@ -135,6 +149,16 @@ def test_missing_cached_head_gives_matching_remote_refresh_instruction(tmp_path,
135149 links .repository_defaults (root )
136150
137151
152+ @pytest .mark .agent_authored (model = "gpt-6.1-sol" )
153+ def test_dangling_cached_head_requires_refresh_instead_of_using_removed_branch (tmp_path , monkeypatch ):
154+ monkeypatch .delenv (links .METADATA_ENV , raising = False )
155+ root = checkout (tmp_path )
156+ remote (root , "upstream" , "https://github.com/NVIDIA/cuda-python.git" )
157+ git (root , "symbolic-ref" , "refs/remotes/upstream/HEAD" , "refs/remotes/upstream/removed" )
158+ with pytest .raises (ValueError , match = "git remote set-head upstream --auto" ):
159+ links .repository_defaults (root )
160+
161+
138162@pytest .mark .agent_authored (model = "gpt-6.1-sol" )
139163def test_conflicting_cached_heads_fail_instead_of_choosing_arbitrarily (tmp_path , monkeypatch ):
140164 monkeypatch .delenv (links .METADATA_ENV , raising = False )
0 commit comments