| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 97921e3 commit 8877d09
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -53,6 +53,14 @@ Object queries continue through `object_data()` and the supported | |||
| 53 | 53 | `Repository.try_find_header()`/`find_object()` APIs, with the existing large-object | |
| 54 | 54 | and diagnostic CLI fallbacks. Storage uses the existing `hash_object` dispatch. | |
| 55 | 55 | ||
| 56 | + `Head.tracking_branch()` asks Git's `rev-parse --symbolic-full-name` to resolve | ||
| 57 | + local upstreams configured with `branch.<name>.remote=.`. GixPython does not | ||
| 58 | + expose the corresponding Git-compatible upstream configuration resolver; this | ||
| 59 | + path retains CLI. Without it, both released GitPython 3.2.1 and the initial | ||
| 60 | + adapter return an invalid remote reference, preventing angr 10.0.4.post1 from | ||
| 61 | + reporting a valid local tracking branch. A native replacement must expose Git's | ||
| 62 | + local-upstream resolution, including its validation and diagnostics. | ||
| 63 | + | ||
| 56 | 64 | `IndexFile` queries immutable entry records; it does not retain a parsed index. | |
| 57 | 65 | The compatibility `entries` property projects those queries into a read-only | |
| 58 | 66 | snapshot keyed by path and stage, preserving readers in dlt and Renku. It uses | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -51,6 +51,10 @@ Git executable and safety | |||
| 51 | 51 | API changes | |
| 52 | 52 | ----------- | |
| 53 | 53 | ||
| 54 | + * ``Head.tracking_branch()`` returns a local ``Head`` when Git configures the | ||
| 55 | + current repository (``branch.<name>.remote=.``) as the upstream, instead of | ||
| 56 | + constructing an invalid ``refs/remotes/./...`` reference. Git resolves the | ||
| 57 | + upstream location; remote tracking branches retain their existing behavior. | ||
| 54 | 58 | * ``GitCmdObjectDB`` no longer inherits ``LooseObjectDB``. Its object reads, | |
| 55 | 59 | writes, existence checks, and enumeration use Git, including packed objects. | |
| 56 | 60 | Precompressed input streams and custom object-output writers are unsupported. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -202,16 +202,23 @@ def set_tracking_branch(self, remote_reference: Union["RemoteReference", None]) | |||
| 202 | 202 | ||
| 203 | 203 | return self | |
| 204 | 204 | ||
| 205 | - def tracking_branch(self) -> Union["RemoteReference", None]: | ||
| 205 | + def tracking_branch(self) -> Union["RemoteReference", "Head", None]: | ||
| 206 | 206 | """ | |
| 207 | 207 | :return: | |
| 208 | - The remote reference we are tracking, or ``None`` if we are not a tracking | ||
| 209 | - branch. | ||
| 208 | + The remote reference or local head we are tracking, or ``None`` if we | ||
| 209 | + are not a tracking branch. | ||
| 210 | 210 | """ | |
| 211 | 211 | from .remote import RemoteReference | |
| 212 | 212 | ||
| 213 | 213 | reader = self.config_reader() | |
| 214 | 214 | if reader.has_option(self.k_config_remote) and reader.has_option(self.k_config_remote_ref): | |
| 215 | + if reader.get_value(self.k_config_remote) == ".": | ||
| 216 | + # Git resolves local-upstream configuration; do not construct a | ||
| 217 | + # remote reference for the special local-repository selector. | ||
| 218 | + path = self.repo.git._call_process_safe( | ||
| 219 | + "rev_parse", "--symbolic-full-name", f"{self.name}@{{upstream}}" | ||
| 220 | + ) | ||
| 221 | + return Head(self.repo, path) | ||
| 215 | 222 | ref = Head( | |
| 216 | 223 | self.repo, | |
| 217 | 224 | Head.to_full_path(strip_quotes(reader.get_value(self.k_config_remote_ref))), | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,6 +10,18 @@ | |||
| 10 | 10 | from test.lib.fixtures import fixture_repo | |
| 11 | 11 | ||
| 12 | 12 | ||
| 13 | + @pytest.mark.parametrize("object_format", ["sha1", "sha256"]) | ||
| 14 | + @pytest.mark.parametrize("ref_format", ["files", "reftable"]) | ||
| 15 | + def test_local_tracking_branch_uses_gits_upstream_location(object_format, ref_format): | ||
| 16 | + with fixture_repo("downstream-local-upstream.sh", object_format, ref_format) as repo: | ||
| 17 | + upstream = repo.head.reference.tracking_branch() | ||
| 18 | + assert isinstance(upstream, git.Head) | ||
| 19 | + assert upstream.path == repo.git.rev_parse("--symbolic-full-name", "@{upstream}") | ||
| 20 | + assert upstream.name == "upstream" | ||
| 21 | + assert not upstream.is_remote() | ||
| 22 | + assert upstream.commit == repo.head.commit | ||
| 23 | + | ||
| 24 | + | ||
| 13 | 25 | @pytest.mark.parametrize("object_format", ["sha1", "sha256"]) | |
| 14 | 26 | @pytest.mark.parametrize("ref_format", ["files", "reftable"]) | |
| 15 | 27 | def test_legacy_gitdb_selector_uses_the_managed_object_backend(object_format, ref_format): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,11 @@ | |||
| 1 | + #!/usr/bin/env bash | ||
| 2 | + set -eu | ||
| 3 | + git init -q --object-format="$1" --ref-format="$2" repo | ||
| 4 | + cd repo | ||
| 5 | + printf tracked > tracked | ||
| 6 | + git add tracked | ||
| 7 | + git commit -qm initial | ||
| 8 | + git branch upstream | ||
| 9 | + branch=$(git symbolic-ref --short HEAD) | ||
| 10 | + git config "branch.$branch.remote" . | ||
| 11 | + git config "branch.$branch.merge" refs/heads/upstream | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments