| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b4613e6 commit 9ab1e02
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -183,7 +183,12 @@ def _for_each_ref(repo: Any, args: List[str], kwargs: Dict[str, Any]) -> bytes: | |||
| 183 | 183 | if any(char in prefix for char in b"*?["): | |
| 184 | 184 | raise _Unsupported("reference glob patterns") | |
| 185 | 185 | with repo.references().all() as refs: | |
| 186 | - names = [ref.name() for ref in refs] | ||
| 186 | + names = [] | ||
| 187 | + for ref in refs: | ||
| 188 | + names.append(ref.name()) | ||
| 189 | + if ref.target().try_name() is not None: | ||
| 190 | + # Git omits dangling symbolic refs; defer their diagnostics to it. | ||
| 191 | + ref.follow_to_object() | ||
| 187 | 192 | return b"".join( | |
| 188 | 193 | name + b"\n" | |
| 189 | 194 | for name in sorted(names) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -110,6 +110,19 @@ def test_native_command_queries_match_cli(repo): | |||
| 110 | 110 | assert native == repo.git._call_process_safe(method, *args, stdout_as_string=False) | |
| 111 | 111 | ||
| 112 | 112 | ||
| 113 | + def test_reference_enumeration_preserves_aliases_and_skips_dangling_refs(repo): | ||
| 114 | + repo.index.commit("initial", skip_hooks=True) | ||
| 115 | + repo.git.symbolic_ref("refs/heads/alias", "refs/heads/main") | ||
| 116 | + with patch.object(Git, "execute", side_effect=AssertionError("unexpected CLI call")): | ||
| 117 | + assert repo.git._call_process_safe("for_each_ref", "--format=%(refname)", "--", "refs/heads") == ( | ||
| 118 | + "refs/heads/alias\nrefs/heads/main" | ||
| 119 | + ) | ||
| 120 | + repo.git.symbolic_ref("refs/heads/dangling", "refs/heads/missing") | ||
| 121 | + with patch.object(_backend, "gix", None): | ||
| 122 | + expected = [ref.path for ref in repo.heads] | ||
| 123 | + assert [ref.path for ref in repo.heads] == expected == ["refs/heads/alias", "refs/heads/main"] | ||
| 124 | + | ||
| 125 | + | ||
| 113 | 126 | def test_a_native_write_failure_is_not_retried(repo, monkeypatch): | |
| 114 | 127 | attempts = [] | |
| 115 | 128 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments