Skip to content

Commit

Permalink
Move ref_prefix default behaviour down (#1418)
Browse files Browse the repository at this point in the history
  • Loading branch information
jelmer authored Nov 5, 2024
2 parents eb6e78f + 12514a6 commit 7f896b4
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions dulwich/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ def from_parsedurl(cls, parsedurl, **kwargs):

def send_pack(
self,
path,
path: str,
update_refs,
generate_pack_data: Callable[
[set[bytes], set[bytes], bool], tuple[int, Iterator[UnpackedObject]]
Expand Down Expand Up @@ -827,7 +827,7 @@ def clone(
branch=None,
progress=None,
depth=None,
ref_prefix=[b"HEAD", b"refs/"],
ref_prefix: Optional[list[Ref]] = None,
filter_spec=None,
protocol_version: Optional[int] = None,
) -> Repo:
Expand Down Expand Up @@ -923,7 +923,7 @@ def fetch(
] = None,
progress: Optional[Callable[[bytes], None]] = None,
depth: Optional[int] = None,
ref_prefix: Optional[list[bytes]] = [b"HEAD", b"refs/"],
ref_prefix: Optional[list[Ref]] = None,
filter_spec: Optional[bytes] = None,
protocol_version: Optional[int] = None,
) -> FetchPackResult:
Expand Down Expand Up @@ -1004,7 +1004,7 @@ def fetch_pack(
*,
progress: Optional[Callable[[bytes], None]] = None,
depth: Optional[int] = None,
ref_prefix=[b"HEAD", b"refs/"],
ref_prefix: Optional[list[Ref]] = None,
filter_spec=None,
protocol_version: Optional[int] = None,
):
Expand Down Expand Up @@ -1306,7 +1306,7 @@ def fetch_pack(
pack_data,
progress=None,
depth=None,
ref_prefix=[b"HEAD", b"refs/"],
ref_prefix: Optional[list[Ref]] = None,
filter_spec=None,
protocol_version: Optional[int] = None,
):
Expand Down Expand Up @@ -1374,6 +1374,11 @@ def fetch_pack(
proto.write(b"0001") # delim-pkt
proto.write_pkt_line(b"symrefs")
proto.write_pkt_line(b"peel")
if ref_prefix is None:
# GitHub defaults to just sending HEAD if no ref-prefix is
# specified, so explicitly request all refs to match
# behaviour with v1 when no ref-prefix is specified.
ref_prefix = [b"HEAD", b"refs/"]
for prefix in ref_prefix:
proto.write_pkt_line(b"ref-prefix " + prefix)
proto.write_pkt_line(None)
Expand Down Expand Up @@ -1785,13 +1790,16 @@ def progress(x):

def fetch(
self,
path,
target,
determine_wants=None,
progress=None,
depth=None,
ref_prefix=[b"HEAD", b"refs/"],
filter_spec=None,
path: str,
target: Repo,
determine_wants: Optional[
Callable[[dict[bytes, bytes], Optional[int]], list[bytes]]
] = None,
progress: Optional[Callable[[bytes], None]] = None,
depth: Optional[int] = None,
ref_prefix: Optional[list[Ref]] = None,
filter_spec: Optional[bytes] = None,
protocol_version: Optional[int] = None,
**kwargs,
):
"""Fetch into a target repository.
Expand Down Expand Up @@ -1835,7 +1843,7 @@ def fetch_pack(
pack_data,
progress=None,
depth=None,
ref_prefix: Optional[list[bytes]] = [b"HEAD", b"refs/"],
ref_prefix: Optional[list[Ref]] = None,
filter_spec: Optional[bytes] = None,
protocol_version: Optional[int] = None,
) -> FetchPackResult:
Expand Down Expand Up @@ -2574,7 +2582,7 @@ def fetch_pack(
pack_data,
progress=None,
depth=None,
ref_prefix=[b"HEAD", b"refs/"],
ref_prefix: Optional[list[Ref]] = None,
filter_spec=None,
protocol_version: Optional[int] = None,
):
Expand Down

0 comments on commit 7f896b4

Please sign in to comment.