Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package python-dulwich for openSUSE:Factory 
checked in at 2026-12-01 16:59:23
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-dulwich (Old)
 and      /work/SRC/openSUSE:Factory/.python-dulwich.new.1340718 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-dulwich"

Tue Dec  1 16:59:23 2026 rev:81 rq:1401782 version:1.2.22

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-dulwich/python-dulwich.changes    
2026-11-18 18:31:16.137126558 +0100
+++ 
/work/SRC/openSUSE:Factory/.python-dulwich.new.1340718/python-dulwich.changes   
    2026-12-01 17:02:40.960443295 +0100
@@ -1,0 +2,28 @@
+Mon Nov 30 20:21:14 UTC 2026 - Lukas Müller <[email protected]>
+
+- Update to version 1.2.22.
+  Changelog: https://github.com/jelmer/dulwich/releases/tag/dulwich-1.2.22
+  * HARDEN: Pass -- before the host in SubprocessSSHVendor so an
+    argument split by MSYS2's runtime on Windows cannot be parsed as an
+    ssh option. Reported by EZO Labs Security. (Jelmer Vernooij)
+  * Fix PanicException from the Rust sorted_tree_items on trees
+    whose entry names contain '/'. (Jelmer Vernooij)
+  * Reject pack indexes whose fanout claims more than 2**31-1 objects on
+    32-bit platforms with AssertionError rather than OverflowError.
+    Reported by @lenix123. (Jelmer Vernooij, #2574)
+  * Add a timeout argument to TCPGitClient and
+    get_transport_and_path, so a git:// server that stops
+    answering no longer blocks a fetch or push forever.
+    (Zainab Mehmut)
+  * HARDEN: Reject pack bitmaps that declare more bits than the pack has
+    objects. A 20-byte EWAH run could otherwise expand into billions of set
+    entries and exhaust memory. (Jelmer Vernooij)
+  * Speed up adding received packs in DiskObjectStore.add_thin_pack and
+    add_pack by resolving each object once. A rejected pack no longer
+    leaves its temporary file behind. (Zainab Mehmut)
+  * Avoid AttributeError in __del__ of Pack, Protocol,
+    Bundle and other classes when their constructor failed before
+    setting any attributes. (Jelmer Vernooij)
+
+
+-------------------------------------------------------------------

Old:
----
  dulwich-1.2.21.tar.gz

New:
----
  dulwich-1.2.22.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-dulwich.spec ++++++
--- /var/tmp/diff_new_pack.LMaYpE/_old  2026-12-01 17:02:41.729476870 +0100
+++ /var/tmp/diff_new_pack.LMaYpE/_new  2026-12-01 17:02:41.731476957 +0100
@@ -29,7 +29,7 @@
 %endif
 %{?sle15_python_module_pythons}
 Name:           python-dulwich
-Version:        1.2.21
+Version:        1.2.22
 Release:        0
 Summary:        Pure-Python Git Library
 License:        Apache-2.0 OR GPL-2.0-or-later

++++++ dulwich-1.2.21.tar.gz -> dulwich-1.2.22.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/dulwich-dulwich-1.2.21/.github/workflows/disperse.yml 
new/dulwich-dulwich-1.2.22/.github/workflows/disperse.yml
--- old/dulwich-dulwich-1.2.21/.github/workflows/disperse.yml   2026-11-05 
00:54:34.000000000 +0100
+++ new/dulwich-dulwich-1.2.22/.github/workflows/disperse.yml   1970-01-01 
01:00:00.000000000 +0100
@@ -1,18 +0,0 @@
----
-name: Disperse configuration
-
-"on":
-  push:
-    branches: [ main, master ]
-
-permissions:
-  contents: read
-
-jobs:
-  build:
-
-    runs-on: ubuntu-latest
-
-    steps:
-      - uses: actions/[email protected]
-      - uses: jelmer/[email protected]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/dulwich-dulwich-1.2.21/Cargo.lock 
new/dulwich-dulwich-1.2.22/Cargo.lock
--- old/dulwich-dulwich-1.2.21/Cargo.lock       2026-11-05 00:54:34.000000000 
+0100
+++ new/dulwich-dulwich-1.2.22/Cargo.lock       2026-11-25 00:28:20.000000000 
+0100
@@ -14,7 +14,7 @@
 
 [[package]]
 name = "diff-tree-py"
-version = "1.2.21"
+version = "1.2.22"
 dependencies = [
  "pyo3",
 ]
@@ -39,7 +39,7 @@
 
 [[package]]
 name = "objects-py"
-version = "1.2.21"
+version = "1.2.22"
 dependencies = [
  "memchr",
  "pyo3",
@@ -53,7 +53,7 @@
 
 [[package]]
 name = "pack-py"
-version = "1.2.21"
+version = "1.2.22"
 dependencies = [
  "memchr",
  "pyo3",
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/dulwich-dulwich-1.2.21/Cargo.toml 
new/dulwich-dulwich-1.2.22/Cargo.toml
--- old/dulwich-dulwich-1.2.21/Cargo.toml       2026-11-05 00:54:34.000000000 
+0100
+++ new/dulwich-dulwich-1.2.22/Cargo.toml       2026-11-25 00:28:20.000000000 
+0100
@@ -6,4 +6,4 @@
 pyo3 = ">=0.25, <0.31"
 
 [workspace.package]
-version = "1.2.21"
+version = "1.2.22"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/dulwich-dulwich-1.2.21/NEWS 
new/dulwich-dulwich-1.2.22/NEWS
--- old/dulwich-dulwich-1.2.21/NEWS     2026-11-05 00:54:34.000000000 +0100
+++ new/dulwich-dulwich-1.2.22/NEWS     2026-11-25 00:28:20.000000000 +0100
@@ -1,3 +1,33 @@
+1.2.22 2026-11-24
+
+ * HARDEN: Pass ``--`` before the host in ``SubprocessSSHVendor`` so an
+   argument split by MSYS2's runtime on Windows cannot be parsed as an
+   ``ssh`` option. Reported by EZO Labs Security. (Jelmer Vernooij)
+
+ * Fix ``PanicException`` from the Rust ``sorted_tree_items`` on trees
+   whose entry names contain '/'. (Jelmer Vernooij)
+
+ * Reject pack indexes whose fanout claims more than 2**31-1 objects on
+   32-bit platforms with AssertionError rather than OverflowError.
+   Reported by @lenix123. (Jelmer Vernooij, #2574)
+
+ * Add a ``timeout`` argument to ``TCPGitClient`` and
+   ``get_transport_and_path``, so a ``git://`` server that stops
+   answering no longer blocks a fetch or push forever.
+   (Zainab Mehmut)
+
+ * HARDEN: Reject pack bitmaps that declare more bits than the pack has
+   objects. A 20-byte EWAH run could otherwise expand into billions of set
+   entries and exhaust memory. (Jelmer Vernooij)
+
+ * Speed up adding received packs in ``DiskObjectStore.add_thin_pack`` and
+   ``add_pack`` by resolving each object once. A rejected pack no longer
+   leaves its temporary file behind. (Zainab Mehmut)
+
+ * Avoid ``AttributeError`` in ``__del__`` of ``Pack``, ``Protocol``,
+   ``Bundle`` and other classes when their constructor failed before
+   setting any attributes. (Jelmer Vernooij)
+
 1.2.21 2026-11-04
 
  * SECURITY: Refuse ``porcelain.submodule_update`` when the submodule path
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/dulwich-dulwich-1.2.21/crates/objects/src/lib.rs 
new/dulwich-dulwich-1.2.22/crates/objects/src/lib.rs
--- old/dulwich-dulwich-1.2.21/crates/objects/src/lib.rs        2026-11-05 
00:54:34.000000000 +0100
+++ new/dulwich-dulwich-1.2.22/crates/objects/src/lib.rs        2026-11-25 
00:28:20.000000000 +0100
@@ -96,19 +96,16 @@
 }
 
 fn cmp_with_suffix(a: (u32, &[u8]), b: (u32, &[u8])) -> std::cmp::Ordering {
-    let len = std::cmp::min(a.1.len(), b.1.len());
-    let cmp = a.1[..len].cmp(&b.1[..len]);
-    if cmp != std::cmp::Ordering::Equal {
-        return cmp;
+    // Compare as if directory names had '/' appended.
+    fn key((mode, name): (u32, &[u8])) -> impl Iterator<Item = &u8> {
+        let suffix: &[u8] = if (mode & S_IFMT) == S_IFDIR {
+            b"/"
+        } else {
+            b""
+        };
+        name.iter().chain(suffix)
     }
-
-    let c1 =
-        a.1.get(len)
-            .map_or_else(|| if (a.0 & S_IFMT) == S_IFDIR { b'/' } else { 0 }, 
|&c| c);
-    let c2 =
-        b.1.get(len)
-            .map_or_else(|| if (b.0 & S_IFMT) == S_IFDIR { b'/' } else { 0 }, 
|&c| c);
-    c1.cmp(&c2)
+    key(a).cmp(key(b))
 }
 
 /// Iterate over a tree entries dictionary.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/dulwich-dulwich-1.2.21/disperse.toml 
new/dulwich-dulwich-1.2.22/disperse.toml
--- old/dulwich-dulwich-1.2.21/disperse.toml    2026-11-05 00:54:34.000000000 
+0100
+++ new/dulwich-dulwich-1.2.22/disperse.toml    1970-01-01 01:00:00.000000000 
+0100
@@ -1,17 +0,0 @@
-tag-name = "dulwich-$VERSION"
-news-file = "NEWS"
-verify-command = "make check"
-twine-upload = false
-tarball-location = []
-release-timeout = 5
-ci-timeout = 7200
-
-[[update_version]]
-path = "dulwich/__init__.py"
-match = "^__version__ = ((.*))$"
-new-line = "__version__ = $TUPLED_VERSION"
-
-[[update_version]]
-path = "Cargo.toml"
-match = '^version = "(.*)"$'
-new-line = 'version = "$VERSION"'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/dulwich-dulwich-1.2.21/dulwich/__init__.py 
new/dulwich-dulwich-1.2.22/dulwich/__init__.py
--- old/dulwich-dulwich-1.2.21/dulwich/__init__.py      2026-11-05 
00:54:34.000000000 +0100
+++ new/dulwich-dulwich-1.2.22/dulwich/__init__.py      2026-11-25 
00:28:20.000000000 +0100
@@ -25,7 +25,7 @@
 from collections.abc import Callable
 from typing import TYPE_CHECKING, Any, ParamSpec, TypeVar
 
-__version__ = (1, 2, 21)
+__version__ = (1, 2, 22)
 
 __all__ = ["__version__", "replace_me"]
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/dulwich-dulwich-1.2.21/dulwich/bitmap.py 
new/dulwich-dulwich-1.2.22/dulwich/bitmap.py
--- old/dulwich-dulwich-1.2.21/dulwich/bitmap.py        2026-11-05 
00:54:34.000000000 +0100
+++ new/dulwich-dulwich-1.2.22/dulwich/bitmap.py        2026-11-25 
00:28:20.000000000 +0100
@@ -168,24 +168,36 @@
     - Bits 33-63: literal_words (31 bits) - count of literal words following 
this RLW
     """
 
-    def __init__(self, data: bytes | None = None) -> None:
+    def __init__(
+        self, data: bytes | None = None, max_bit_count: int | None = None
+    ) -> None:
         """Initialize EWAH bitmap.
 
         Args:
             data: Optional compressed bitmap data to decode
+            max_bit_count: Optional upper bound on the declared bit count of
+                data; see _decode
         """
         self.bits: set[int] = set()
         self.bit_count = 0
 
         if data:
-            self._decode(data)
+            self._decode(data, max_bit_count=max_bit_count)
 
-    def _decode(self, data: bytes) -> None:
+    def _decode(self, data: bytes, max_bit_count: int | None = None) -> None:
         """Decode EWAH compressed bitmap data.
 
         Args:
             data: Compressed bitmap data (EWAH format with header + words +
                 RLW position)
+            max_bit_count: Optional upper bound on the declared bit count,
+                rounded up to the next 64-bit word boundary. Runs are
+                expanded into one set entry per bit, so without a bound a
+                few bytes of input can claim billions of set bits.
+
+        Raises:
+            ValueError: If the data is corrupt or declares more than
+                max_bit_count bits
         """
         f = BytesIO(data)
 
@@ -199,6 +211,15 @@
         bit_count = struct.unpack(">I", bit_count_bytes)[0]
         word_count = struct.unpack(">I", word_count_bytes)[0]
 
+        if max_bit_count is not None:
+            # Bitmaps are stored as whole 64-bit words, so round the bound up
+            # to the next word boundary before comparing.
+            rounded_max = ((max_bit_count + 63) // 64) * 64
+            if bit_count > rounded_max:
+                raise ValueError(
+                    f"EWAH bit count {bit_count} exceeds maximum 
{max_bit_count}"
+                )
+
         self.bit_count = bit_count
         current_bit = 0
 
@@ -524,6 +545,7 @@
     filename: str | os.PathLike[str],
     pack_index: "PackIndex | None" = None,
     pack_checksum: bytes | None = None,
+    num_objects: int | None = None,
 ) -> PackBitmap:
     """Read a bitmap index file.
 
@@ -532,6 +554,10 @@
         pack_index: Optional PackIndex to resolve object positions to SHAs
         pack_checksum: Optional checksum of the pack this bitmap belongs to.
             When given, the checksum stored in the bitmap header must match it.
+        num_objects: Number of objects in the pack. Bitmaps that declare more
+            bits than this, rounded up to a whole 64-bit word, are rejected.
+            Defaults to the size of pack_index;
+            when neither is given, bitmap sizes are not bounded.
 
     Returns:
         Loaded PackBitmap
@@ -542,13 +568,25 @@
             checksum recorded in the bitmap header
     """
     with GitFile(filename, "rb") as f:
-        return read_bitmap_file(f, pack_index=pack_index, 
pack_checksum=pack_checksum)
+        return read_bitmap_file(
+            f,
+            pack_index=pack_index,
+            pack_checksum=pack_checksum,
+            num_objects=num_objects,
+        )
+
+
+def _max_bit_count(num_objects: int) -> int:
+    # git pads bitmaps to whole 64-bit words and writes at least one word,
+    # even for an empty bitmap.
+    return max(1, (num_objects + 63) // 64) * 64
 
 
 def read_bitmap_file(
     f: IO[bytes],
     pack_index: "PackIndex | None" = None,
     pack_checksum: bytes | None = None,
+    num_objects: int | None = None,
 ) -> PackBitmap:
     """Read bitmap data from a file object.
 
@@ -557,6 +595,10 @@
         pack_index: Optional PackIndex to resolve object positions to SHAs
         pack_checksum: Optional checksum of the pack this bitmap belongs to.
             When given, the checksum stored in the bitmap header must match it.
+        num_objects: Number of objects in the pack. Bitmaps that declare more
+            bits than this, rounded up to a whole 64-bit word, are rejected.
+            Defaults to the size of pack_index;
+            when neither is given, bitmap sizes are not bounded.
 
     Returns:
         Loaded PackBitmap
@@ -598,6 +640,10 @@
     if pack_checksum is not None and stored_pack_checksum != pack_checksum:
         raise ChecksumMismatch(pack_checksum, stored_pack_checksum)
 
+    if num_objects is None and pack_index is not None:
+        num_objects = len(pack_index)
+    max_bit_count = None if num_objects is None else 
_max_bit_count(num_objects)
+
     bitmap = PackBitmap(version=version, flags=flags)
     bitmap.pack_checksum = stored_pack_checksum
 
@@ -637,7 +683,7 @@
 
         # Reconstruct the full EWAH data to pass to _decode
         ewah_data = bit_count_bytes + word_count_bytes + words_data + 
rlw_pos_bytes
-        type_bitmap._decode(ewah_data)
+        type_bitmap._decode(ewah_data, max_bit_count=max_bit_count)
 
     # Read bitmap entries
     for _ in range(entry_count):
@@ -683,7 +729,11 @@
         bitmap_data = bit_count_bytes + word_count_bytes + words_data + 
rlw_pos_bytes
 
         # Create bitmap entry
-        ewah_bitmap = EWAHBitmap(bitmap_data) if word_count > 0 else 
EWAHBitmap()
+        ewah_bitmap = (
+            EWAHBitmap(bitmap_data, max_bit_count=max_bit_count)
+            if word_count > 0
+            else EWAHBitmap()
+        )
         entry = BitmapEntry(
             object_pos=obj_pos,
             xor_offset=xor_offset,
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/dulwich-dulwich-1.2.21/dulwich/bundle.py 
new/dulwich-dulwich-1.2.22/dulwich/bundle.py
--- old/dulwich-dulwich-1.2.21/dulwich/bundle.py        2026-11-05 
00:54:34.000000000 +0100
+++ new/dulwich-dulwich-1.2.22/dulwich/bundle.py        2026-11-25 
00:28:20.000000000 +0100
@@ -86,7 +86,7 @@
     capabilities: dict[str, str | None]
     prerequisites: list[tuple[ObjectID, bytes]]
     references: dict[Ref, ObjectID]
-    pack_data: PackDataLike | None
+    pack_data: PackDataLike | None = None
 
     def __repr__(self) -> str:
         """Return string representation of Bundle."""
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/dulwich-dulwich-1.2.21/dulwich/client.py 
new/dulwich-dulwich-1.2.22/dulwich/client.py
--- old/dulwich-dulwich-1.2.21/dulwich/client.py        2026-11-05 
00:54:34.000000000 +0100
+++ new/dulwich-dulwich-1.2.22/dulwich/client.py        2026-11-25 
00:28:20.000000000 +0100
@@ -2603,6 +2603,7 @@
         quiet: bool = False,
         include_tags: bool = False,
         proxy_command: str | None = None,
+        timeout: float | None = None,
     ) -> None:
         """Initialize a TCPGitClient.
 
@@ -2616,12 +2617,16 @@
           proxy_command: Optional proxy command (core.gitProxy).
             The command is run with host and port as arguments and
             communicates over stdin/stdout.
+          timeout: Optional timeout in seconds for connecting and for
+            each socket read or write (None waits forever). Not used
+            with proxy_command.
         """
         if port is None:
             port = TCP_GIT_PORT
         self._host = host
         self._port = port
         self._proxy_command = proxy_command
+        self._timeout = timeout
         super().__init__(
             thin_packs=thin_packs,
             report_activity=report_activity,
@@ -2641,6 +2646,7 @@
         username: str | None = None,
         password: str | None = None,
         config: Config | None = None,
+        timeout: float | None = None,
     ) -> "TCPGitClient":
         """Create an instance of TCPGitClient from a parsed URL.
 
@@ -2654,6 +2660,7 @@
           username: Username for authentication (not used for TCPGitClient)
           password: Password for authentication (not used for TCPGitClient)
           config: Configuration object
+          timeout: Optional timeout in seconds for socket operations
 
         Returns:
           A TCPGitClient instance
@@ -2670,6 +2677,7 @@
             quiet=quiet,
             include_tags=include_tags,
             proxy_command=proxy_command,
+            timeout=timeout,
         )
 
     def get_url(self, path: str) -> str:
@@ -2713,6 +2721,7 @@
         for family, socktype, protof, canonname, sockaddr in sockaddrs:
             s = socket.socket(family, socktype, protof)
             s.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
+            s.settimeout(self._timeout)
             try:
                 s.connect(sockaddr)
                 break
@@ -2740,7 +2749,7 @@
 
         proto = Protocol(
             rfile.read,
-            wfile.write,
+            s.sendall,
             close,
             report_activity=self._report_activity,
             shutdown_write=shutdown_write,
@@ -3877,7 +3886,7 @@
             host = f"{username}@{host}"
         if host.startswith("-"):
             raise StrangeHostname(hostname=host)
-        args.append(host)
+        args.extend(["--", host])
 
         proc = subprocess.Popen(
             [*args, command],
@@ -5573,6 +5582,7 @@
     key_filename: str | None = None,
     ssh_command: str | None = None,
     pool_manager: "urllib3.PoolManager | None" = None,
+    timeout: float | None = None,
 ) -> tuple[GitClient, str]:
     """Obtain a git client from a URL.
 
@@ -5589,6 +5599,7 @@
       key_filename: Optional SSH key file
       ssh_command: Optional custom SSH command
       pool_manager: Optional urllib3 PoolManager for HTTP(S) connections
+      timeout: Optional timeout in seconds for git:// connections
 
     Returns:
       Tuple with client instance and relative path.
@@ -5610,6 +5621,7 @@
         key_filename=key_filename,
         ssh_command=ssh_command,
         pool_manager=pool_manager,
+        timeout=timeout,
     )
 
 
@@ -5626,6 +5638,7 @@
     key_filename: str | None = None,
     ssh_command: str | None = None,
     pool_manager: "urllib3.PoolManager | None" = None,
+    timeout: float | None = None,
 ) -> tuple[GitClient, str]:
     parsed = urlparse(url)
     match parsed.scheme:
@@ -5638,6 +5651,7 @@
                     quiet=quiet,
                     include_tags=include_tags,
                     config=config,
+                    timeout=timeout,
                 ),
                 parsed.path,
             )
@@ -5723,6 +5737,7 @@
     key_filename: str | None = None,
     ssh_command: str | None = None,
     pool_manager: "urllib3.PoolManager | None" = None,
+    timeout: float | None = None,
 ) -> tuple[GitClient, str]:
     """Obtain a git client from a URL.
 
@@ -5739,6 +5754,7 @@
       key_filename: Optional SSH key file
       ssh_command: Optional custom SSH command
       pool_manager: Optional urllib3 PoolManager for HTTP(S) connections
+      timeout: Optional timeout in seconds for git:// connections
 
     Returns:
       Tuple with client instance and relative path.
@@ -5762,6 +5778,7 @@
             key_filename=key_filename,
             ssh_command=ssh_command,
             pool_manager=pool_manager,
+            timeout=timeout,
         )
     except ValueError:
         pass
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/dulwich-dulwich-1.2.21/dulwich/dumb.py 
new/dulwich-dulwich-1.2.22/dulwich/dumb.py
--- old/dulwich-dulwich-1.2.21/dulwich/dumb.py  2026-11-05 00:54:34.000000000 
+0100
+++ new/dulwich-dulwich-1.2.22/dulwich/dumb.py  2026-11-25 00:28:20.000000000 
+0100
@@ -65,6 +65,8 @@
 class DumbHTTPObjectStore(BaseObjectStore):
     """Object store implementation that fetches objects over dumb HTTP."""
 
+    _temp_pack_dir: str | None = None
+
     def __init__(
         self,
         base_url: str,
@@ -86,7 +88,6 @@
         self._http_request = http_request_func
         self._packs: list[tuple[str, PackIndex | None]] | None = None
         self._cached_objects: dict[bytes, tuple[int, bytes]] = {}
-        self._temp_pack_dir: str | None = None
 
     def _ensure_temp_pack_dir(self) -> None:
         """Ensure we have a temporary directory for storing pack files."""
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/dulwich-dulwich-1.2.21/dulwich/filters.py 
new/dulwich-dulwich-1.2.22/dulwich/filters.py
--- old/dulwich-dulwich-1.2.21/dulwich/filters.py       2026-11-05 
00:54:34.000000000 +0100
+++ new/dulwich-dulwich-1.2.22/dulwich/filters.py       2026-11-25 
00:28:20.000000000 +0100
@@ -134,6 +134,8 @@
 class ProcessFilterDriver:
     """Filter driver that executes external processes."""
 
+    _process: subprocess.Popen[bytes] | None = None
+
     def __init__(
         self,
         clean_cmd: str | None = None,
@@ -156,7 +158,6 @@
         self.required = required
         self.cwd = cwd
         self.process_cmd = process_cmd
-        self._process: subprocess.Popen[bytes] | None = None
         self._protocol: Protocol | None = None
         self._capabilities: set[bytes] = set()
         self._process_lock = threading.Lock()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/dulwich-dulwich-1.2.21/dulwich/object_store.py 
new/dulwich-dulwich-1.2.22/dulwich/object_store.py
--- old/dulwich-dulwich-1.2.21/dulwich/object_store.py  2026-11-05 
00:54:34.000000000 +0100
+++ new/dulwich-dulwich-1.2.22/dulwich/object_store.py  2026-11-25 
00:28:20.000000000 +0100
@@ -320,6 +320,24 @@
     return wrapped_read_all, wrapped_read_some
 
 
+class _ParsingPackIndexer(PackIndexer):
+    """PackIndexer that also parses each object while it is resolved.
+
+    Payloads that fail to parse (e.g. tree entries with garbage modes) are
+    rejected before the pack is moved in, without a second walk over it.
+    """
+
+    def _result(self, unpacked: UnpackedObject) -> PackIndexEntry:
+        assert unpacked.obj_type_num is not None and unpacked.obj_chunks is 
not None
+        # Parsed only to reject a malformed object; the result is not kept.
+        ShaFile.from_raw_chunks(
+            unpacked.obj_type_num,
+            unpacked.obj_chunks,
+            object_format=self._object_format,
+        )
+        return super()._result(unpacked)
+
+
 def find_shallow(
     store: ObjectContainer, heads: Iterable[ObjectID], depth: int
 ) -> tuple[set[ObjectID], set[ObjectID]]:
@@ -2377,15 +2395,6 @@
         )
         try:
             final_pack.check_length_and_checksum()
-            # Materialise every object so payloads that fail to parse
-            # (e.g. tree entries with garbage modes) are rejected rather
-            # than silently landed on disk. MemoryObjectStore already
-            # validates ingested objects this way via PackInflater; without
-            # the same check DiskObjectStore was strictly weaker.
-            for _obj in PackInflater.for_pack_data(
-                final_pack.data, resolve_ext_ref=self.get_raw
-            ):
-                pass
         except BaseException:
             final_pack.close()
             with suppress(FileNotFoundError):
@@ -2436,30 +2445,39 @@
             )
 
         fd, path = tempfile.mkstemp(dir=self.path, prefix="tmp_pack_")
-        with os.fdopen(fd, "w+b") as f:
-            os.chmod(path, PACK_MODE)
-            indexer = PackIndexer(
-                f,
-                self.object_format.hash_func,
-                resolve_ext_ref=self.get_raw,
-            )
-            copier = PackStreamCopier(
-                self.object_format.hash_func,
-                read_all,
-                read_some,
-                f,
-                delta_iter=indexer,  # type: ignore[arg-type]
-            )
-            copier.verify(progress=progress)
-            f.flush()
-            f.seek(0)
-            # Index from a mapping as add_pack does. Unmapped before 
completion.
-            with PackData(path, file=f, object_format=self.object_format) as 
pd:
-                indexer.set_pack_data(pd)
-                entries, ext_refs = self._index_pack(
-                    indexer, len(copier), progress=progress
+        try:
+            with os.fdopen(fd, "w+b") as f:
+                os.chmod(path, PACK_MODE)
+                indexer = _ParsingPackIndexer(
+                    f,
+                    self.object_format.hash_func,
+                    resolve_ext_ref=self.get_raw,
+                    object_format=self.object_format,
+                )
+                copier = PackStreamCopier(
+                    self.object_format.hash_func,
+                    read_all,
+                    read_some,
+                    f,
+                    delta_iter=indexer,  # type: ignore[arg-type]
                 )
-            return self._complete_pack(f, path, entries, ext_refs, 
progress=progress)
+                copier.verify(progress=progress)
+                f.flush()
+                f.seek(0)
+                # Index from a mapping as add_pack does. Unmapped before 
completion.
+                with PackData(path, file=f, object_format=self.object_format) 
as pd:
+                    indexer.set_pack_data(pd)
+                    entries, ext_refs = self._index_pack(
+                        indexer, len(copier), progress=progress
+                    )
+                return self._complete_pack(
+                    f, path, entries, ext_refs, progress=progress
+                )
+        except BaseException:
+            # Do not leave the temporary pack behind when the pack is rejected.
+            with suppress(FileNotFoundError):
+                _remove_readonly(path)
+            raise
 
     def add_pack(
         self,
@@ -2484,13 +2502,20 @@
                 # Scope the mapping to indexing: _complete_pack writes to and
                 # renames this same file, which a live mapping blocks on
                 # Windows. PackData.close() leaves f open for it to finish.
-                with PackData(path, file=f, object_format=self.object_format) 
as pd:
-                    indexer = PackIndexer.for_pack_data(
-                        pd,
-                        resolve_ext_ref=self.get_raw,
-                    )
-                    entries, ext_refs = self._index_pack(indexer, len(pd))  # 
type: ignore[arg-type]
-                return self._complete_pack(f, path, entries, ext_refs)
+                try:
+                    with PackData(path, file=f, 
object_format=self.object_format) as pd:
+                        indexer = _ParsingPackIndexer.for_pack_data(
+                            pd,
+                            resolve_ext_ref=self.get_raw,
+                        )
+                        entries, ext_refs = self._index_pack(indexer, len(pd)) 
 # type: ignore[arg-type]
+                    return self._complete_pack(f, path, entries, ext_refs)
+                except BaseException:
+                    # Do not leave the temporary pack behind when the pack is 
rejected.
+                    f.close()
+                    with suppress(FileNotFoundError):
+                        _remove_readonly(path)
+                    raise
             else:
                 f.close()
                 os.remove(path)
@@ -2498,7 +2523,8 @@
 
         def abort() -> None:
             f.close()
-            os.remove(path)
+            with suppress(FileNotFoundError):
+                os.remove(path)
 
         return f, commit, abort  # type: ignore[return-value]
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/dulwich-dulwich-1.2.21/dulwich/pack.py 
new/dulwich-dulwich-1.2.22/dulwich/pack.py
--- old/dulwich-dulwich-1.2.21/dulwich/pack.py  2026-11-05 00:54:34.000000000 
+0100
+++ new/dulwich-dulwich-1.2.22/dulwich/pack.py  2026-11-25 00:28:20.000000000 
+0100
@@ -1120,7 +1120,7 @@
     """
 
     _fan_out_table: list[int]
-    _file: IO[bytes] | _GitFile
+    _file: IO[bytes] | _GitFile | None = None
 
     def __init__(
         self,
@@ -1166,11 +1166,12 @@
     def close(self) -> None:
         """Close the underlying file and any mmap."""
         _close_file_contents(self._contents)
-        self._file.close()
+        if self._file is not None:
+            self._file.close()
 
     def __del__(self) -> None:
         """Ensure the file and mmap are closed when GCed."""
-        if not getattr(self._file, "closed", True):
+        if self._file is not None and not getattr(self._file, "closed", True):
             import warnings
 
             warnings.warn(
@@ -1385,11 +1386,14 @@
         self._fan_out_table = self._read_fan_out_table(0)
         self.hash_size = self.object_format.oid_length
         self._entry_size = 4 + self.hash_size
+        # Avoid len(self) here: on 32-bit platforms a __len__ return above
+        # 2**31-1 raises OverflowError before we can reject the index.
+        num_objects = self._fan_out_table[-1]
         file_size = len(self._contents)
-        minimum_size = 0x100 * 4 + len(self) * self._entry_size
+        minimum_size = 0x100 * 4 + num_objects * self._entry_size
         if file_size < minimum_size:
             raise AssertionError(
-                f"pack index claims {len(self)} objects but file is only "
+                f"pack index claims {num_objects} objects but file is only "
                 f"{file_size} bytes (needs at least {minimum_size})"
             )
 
@@ -1444,10 +1448,15 @@
         self._fan_out_table = self._read_fan_out_table(8)
         self.hash_size = self.object_format.oid_length
         self._name_table_offset = 8 + 0x100 * 4
-        self._crc32_table_offset = self._name_table_offset + self.hash_size * 
len(self)
-        self._pack_offset_table_offset = self._crc32_table_offset + 4 * 
len(self)
-        self._pack_offset_largetable_offset = self._pack_offset_table_offset + 
4 * len(
-            self
+        # Avoid len(self) here: on 32-bit platforms a __len__ return above
+        # 2**31-1 raises OverflowError before we can reject the index.
+        num_objects = self._fan_out_table[-1]
+        self._crc32_table_offset = (
+            self._name_table_offset + self.hash_size * num_objects
+        )
+        self._pack_offset_table_offset = self._crc32_table_offset + 4 * 
num_objects
+        self._pack_offset_largetable_offset = (
+            self._pack_offset_table_offset + 4 * num_objects
         )
         # Reject claims the file is obviously too small to back. A corrupt
         # (or hostile) ``.idx`` with fanout[-1] = 0xFFFFFFFF would otherwise
@@ -1460,7 +1469,7 @@
         minimum_size = self._pack_offset_largetable_offset
         if file_size < minimum_size:
             raise AssertionError(
-                f"pack index claims {len(self)} objects but file is only "
+                f"pack index claims {num_objects} objects but file is only "
                 f"{file_size} bytes (needs at least {minimum_size})"
             )
 
@@ -1576,16 +1585,21 @@
             16
         )  # After header (4 + 4 + 4 + 4)
         self._name_table_offset = 16 + 0x100 * 4
-        self._crc32_table_offset = self._name_table_offset + self.hash_size * 
len(self)
-        self._pack_offset_table_offset = self._crc32_table_offset + 4 * 
len(self)
-        self._pack_offset_largetable_offset = self._pack_offset_table_offset + 
4 * len(
-            self
+        # Avoid len(self) here: on 32-bit platforms a __len__ return above
+        # 2**31-1 raises OverflowError before we can reject the index.
+        num_objects = self._fan_out_table[-1]
+        self._crc32_table_offset = (
+            self._name_table_offset + self.hash_size * num_objects
+        )
+        self._pack_offset_table_offset = self._crc32_table_offset + 4 * 
num_objects
+        self._pack_offset_largetable_offset = (
+            self._pack_offset_table_offset + 4 * num_objects
         )
         file_size = len(self._contents)
         minimum_size = self._pack_offset_largetable_offset
         if file_size < minimum_size:
             raise AssertionError(
-                f"pack index claims {len(self)} objects but file is only "
+                f"pack index claims {num_objects} objects but file is only "
                 f"{file_size} bytes (needs at least {minimum_size})"
             )
 
@@ -4499,8 +4513,8 @@
     _data_load: Callable[[], PackData] | None
     _idx_load: Callable[[], PackIndex] | None
 
-    _data: PackData | None
-    _idx: PackIndex | None
+    _data: PackData | None = None
+    _idx: PackIndex | None = None
     _bitmap: "PackBitmap | None"
 
     def __init__(
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/dulwich-dulwich-1.2.21/dulwich/porcelain/__init__.py 
new/dulwich-dulwich-1.2.22/dulwich/porcelain/__init__.py
--- old/dulwich-dulwich-1.2.21/dulwich/porcelain/__init__.py    2026-11-05 
00:54:34.000000000 +0100
+++ new/dulwich-dulwich-1.2.22/dulwich/porcelain/__init__.py    2026-11-25 
00:28:20.000000000 +0100
@@ -527,6 +527,7 @@
     key_filename: str | None
     ssh_command: str | None
     pool_manager: "urllib3.PoolManager | None"
+    timeout: float | None
 
 
 @dataclass
@@ -1833,6 +1834,7 @@
         "key_filename",
         "ssh_command",
         "pool_manager",
+        "timeout",
     }
     return cast(TransportKwargs, {k: v for k, v in kwargs.items() if k in 
valid_params})
 
@@ -5531,42 +5533,28 @@
         # Build commit history for visualization
         # Collect all commits reachable from any branch
         all_commits: dict[
-            bytes, tuple[int, list[ObjectID], str]
+            ObjectID, tuple[int, list[ObjectID], str]
         ] = {}  # sha -> (timestamp, parents, message)
 
-        def collect_commits(sha: bytes, branch_idx: int, visited: set[bytes]) 
-> None:
-            """Recursively collect commits."""
-            if sha in visited:
-                return
-            visited.add(sha)
-
-            try:
-                commit = r[sha]
-            except KeyError:
-                # Commit not found, stop traversal
-                pass
-            else:
+        # Collect commits from all branches
+        for _, root in sorted_branches:
+            stack = [root]
+            while stack:
+                sha = stack.pop()
+                if sha in all_commits:
+                    continue
+                try:
+                    commit = r[sha]
+                except KeyError:
+                    continue
                 if not isinstance(commit, Commit):
-                    return
-
+                    continue
                 timestamp = commit.commit_time
-                parents = commit.parents if isinstance(commit, Commit) else []
-                message = (
-                    commit.message.decode("utf-8", 
errors="replace").split("\n")[0]
-                    if isinstance(commit, Commit)
-                    else ""
-                )
-
-                if sha not in all_commits:
-                    all_commits[sha] = (timestamp, parents, message)
-
-                # Recurse to parents
-                for parent in parents:
-                    collect_commits(parent, branch_idx, visited)
-
-        # Collect commits from all branches
-        for i, (_, sha) in enumerate(sorted_branches):
-            collect_commits(sha, i, set())
+                message = commit.message.decode("utf-8", 
errors="replace").split("\n")[
+                    0
+                ]
+                all_commits[sha] = (timestamp, commit.parents, message)
+                stack.extend(commit.parents)
 
         # Find common ancestor
         common_ancestor_sha = None
@@ -5604,20 +5592,19 @@
                     sorted_commits = sorted_commits[: ancestor_idx + 1 + more]
 
         # Determine which branches contain which commits
-        branch_contains: list[set[bytes]] = []
+        branch_contains: list[set[ObjectID]] = []
         for ref_name, sha in sorted_branches:
-            reachable = set()
-
-            def mark_reachable(commit_sha: bytes) -> None:
+            reachable: set[ObjectID] = set()
+            stack = [sha]
+            while stack:
+                commit_sha = stack.pop()
                 if commit_sha in reachable:
-                    return
+                    continue
                 reachable.add(commit_sha)
                 if commit_sha in all_commits:
                     _, parents, _ = all_commits[commit_sha]
-                    for parent in parents:
-                        mark_reachable(parent)
+                    stack.extend(parents)
 
-            mark_reachable(sha)
             branch_contains.append(reachable)
 
         # Output branch headers
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/dulwich-dulwich-1.2.21/dulwich/protocol.py 
new/dulwich-dulwich-1.2.22/dulwich/protocol.py
--- old/dulwich-dulwich-1.2.21/dulwich/protocol.py      2026-11-05 
00:54:34.000000000 +0100
+++ new/dulwich-dulwich-1.2.22/dulwich/protocol.py      2026-11-25 
00:28:20.000000000 +0100
@@ -419,6 +419,8 @@
         Documentation/technical/protocol-common.txt
     """
 
+    _close: Callable[[], None] | None = None
+
     def __init__(
         self,
         read: Callable[[int], bytes],
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/dulwich-dulwich-1.2.21/fuzzing/fuzz-targets/fuzz_bitmap.py 
new/dulwich-dulwich-1.2.22/fuzzing/fuzz-targets/fuzz_bitmap.py
--- old/dulwich-dulwich-1.2.21/fuzzing/fuzz-targets/fuzz_bitmap.py      
2026-11-05 00:54:34.000000000 +0100
+++ new/dulwich-dulwich-1.2.22/fuzzing/fuzz-targets/fuzz_bitmap.py      
2026-11-25 00:28:20.000000000 +0100
@@ -9,16 +9,21 @@
     from dulwich.bitmap import EWAHBitmap, read_bitmap_file
 
 
+# There is no pack to bound bitmap sizes against, so pick a limit that keeps
+# memory use well below the fuzzer's RSS limit.
+MAX_BIT_COUNT = 1 << 20
+
+
 def TestOneInput(data) -> int | None:
     # Exercise the standalone EWAH decoder as well as the full bitmap file
     # reader, both of which parse untrusted input.
     try:
-        EWAHBitmap(data)
+        EWAHBitmap(data, max_bit_count=MAX_BIT_COUNT)
     except ValueError:
         pass
 
     try:
-        read_bitmap_file(BytesIO(data))
+        read_bitmap_file(BytesIO(data), num_objects=MAX_BIT_COUNT)
     except ValueError:
         pass
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/dulwich-dulwich-1.2.21/fuzzing/fuzz-targets/fuzz_bundle.py 
new/dulwich-dulwich-1.2.22/fuzzing/fuzz-targets/fuzz_bundle.py
--- old/dulwich-dulwich-1.2.21/fuzzing/fuzz-targets/fuzz_bundle.py      
2026-11-05 00:54:34.000000000 +0100
+++ new/dulwich-dulwich-1.2.22/fuzzing/fuzz-targets/fuzz_bundle.py      
2026-11-25 00:28:20.000000000 +0100
@@ -10,6 +10,7 @@
     from test_utils import EnhancedFuzzedDataProvider, is_expected_exception
 
     from dulwich.bundle import Bundle, read_bundle, write_bundle
+    from dulwich.object_format import DEFAULT_OBJECT_FORMAT
     from dulwich.pack import PackData, write_pack_objects
 
 
@@ -17,16 +18,16 @@
     fdp = EnhancedFuzzedDataProvider(data)
     bundle = Bundle()
     bundle.version = fdp.PickValueInList([2, 3, None])
-    bundle.references = {fdp.ConsumeRandomString(): fdp.ConsumeBytes(20)}
+    bundle.references = {fdp.ConsumeRandomBytes(): fdp.ConsumeBytes(20)}
     bundle.prerequisites = [(fdp.ConsumeBytes(20), fdp.ConsumeRandomBytes())]
     bundle.capabilities = {
         fdp.ConsumeRandomString(): fdp.ConsumeRandomString(),
     }
 
     b = BytesIO()
-    write_pack_objects(b.write, [])
+    write_pack_objects(b.write, [], DEFAULT_OBJECT_FORMAT)
     b.seek(0)
-    bundle.pack_data = PackData.from_file(b)
+    bundle.pack_data = PackData.from_file(b, DEFAULT_OBJECT_FORMAT)
 
     # Test __repr__ method
     _ = repr(bundle)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/dulwich-dulwich-1.2.21/fuzzing/fuzz-targets/fuzz_configfile.py 
new/dulwich-dulwich-1.2.22/fuzzing/fuzz-targets/fuzz_configfile.py
--- old/dulwich-dulwich-1.2.21/fuzzing/fuzz-targets/fuzz_configfile.py  
2026-11-05 00:54:34.000000000 +0100
+++ new/dulwich-dulwich-1.2.22/fuzzing/fuzz-targets/fuzz_configfile.py  
2026-11-25 00:28:20.000000000 +0100
@@ -22,6 +22,7 @@
             "Invalid subsection",
             "escape character",
             "missing end quote",
+            "embedded null byte",
         ]
         if is_expected_exception(expected_exceptions, e):
             return -1
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/dulwich-dulwich-1.2.21/tests/test_bitmap.py 
new/dulwich-dulwich-1.2.22/tests/test_bitmap.py
--- old/dulwich-dulwich-1.2.21/tests/test_bitmap.py     2026-11-05 
00:54:34.000000000 +0100
+++ new/dulwich-dulwich-1.2.22/tests/test_bitmap.py     2026-11-25 
00:28:20.000000000 +0100
@@ -857,6 +857,82 @@
             read_bitmap_file(BytesIO(data))
         self.assertIn("running length", str(ctx.exception).lower())
 
+    def test_decode_bit_count_exceeds_max(self):
+        """A declared bit count above max_bit_count is rejected."""
+        # bit_count=2**32-1 with a single run of 2**26 set words would expand
+        # to billions of set entries.
+        rlw = ((1 << 26) << 1) | 1
+        data = struct.pack(">II", 0xFFFFFFFF, 1)
+        data += struct.pack(">Q", rlw)
+        data += struct.pack(">I", 0)
+
+        with self.assertRaises(ValueError) as ctx:
+            EWAHBitmap(data, max_bit_count=128)
+        self.assertEqual(
+            "EWAH bit count 4294967295 exceeds maximum 128", str(ctx.exception)
+        )
+
+    def test_decode_bit_count_at_max(self):
+        rlw = (2 << 1) | 1
+        data = struct.pack(">II", 128, 1)
+        data += struct.pack(">Q", rlw)
+        data += struct.pack(">I", 0)
+
+        decoded = EWAHBitmap(data, max_bit_count=128)
+        self.assertEqual(set(range(128)), decoded.bits)
+
+    def test_decode_bit_count_max_rounded_up_to_word(self):
+        # max_bit_count is rounded up to a whole 64-bit word.
+        rlw = (1 << 1) | 1
+        data = struct.pack(">II", 64, 1)
+        data += struct.pack(">Q", rlw)
+        data += struct.pack(">I", 0)
+
+        decoded = EWAHBitmap(data, max_bit_count=10)
+        self.assertEqual(set(range(64)), decoded.bits)
+
+    def _bitmap_file_with_type_bitmap_bit_count(self, bit_count):
+        data = BITMAP_SIGNATURE
+        data += BITMAP_VERSION.to_bytes(2, "big")
+        data += b"\x00\x00"  # Flags
+        data += b"\x00\x00\x00\x00"  # Entry count
+        data += b"\x00" * 20  # Pack checksum
+        # Commit type bitmap: one RLW with running_bit=0 covering bit_count.
+        data += struct.pack(">II", bit_count, 1)
+        data += struct.pack(">Q", ((bit_count + 63) // 64) << 1)
+        data += struct.pack(">I", 0)
+        for _ in range(3):
+            data += struct.pack(">III", 0, 0, 0)
+        return data
+
+    def test_read_bitmap_file_bit_count_exceeds_pack(self):
+        """Bitmaps larger than the pack's object count are rejected."""
+        data = self._bitmap_file_with_type_bitmap_bit_count(0xFFFFFFC0)
+        with self.assertRaises(ValueError) as ctx:
+            read_bitmap_file(BytesIO(data), num_objects=5)
+        self.assertEqual(
+            "EWAH bit count 4294967232 exceeds maximum 64", str(ctx.exception)
+        )
+
+    def test_read_bitmap_file_bit_count_from_pack_index(self):
+        shas = sorted(bytes([i]) + b"\x00" * 19 for i in range(65))
+        pack_index = MemoryPackIndex(
+            [(sha, i, i) for i, sha in enumerate(shas)], DEFAULT_OBJECT_FORMAT
+        )
+        # git pads to whole words: 65 objects allow up to 128 bits.
+        data = self._bitmap_file_with_type_bitmap_bit_count(128)
+        read_bitmap_file(BytesIO(data), pack_index=pack_index)
+        data = self._bitmap_file_with_type_bitmap_bit_count(192)
+        with self.assertRaises(ValueError) as ctx:
+            read_bitmap_file(BytesIO(data), pack_index=pack_index)
+        self.assertEqual("EWAH bit count 192 exceeds maximum 128", 
str(ctx.exception))
+
+    def test_read_bitmap_file_empty_pack(self):
+        """git writes empty bitmaps as one word, even for an empty pack."""
+        data = self._bitmap_file_with_type_bitmap_bit_count(64)
+        bitmap = read_bitmap_file(BytesIO(data), num_objects=0)
+        self.assertEqual(64, bitmap.commit_bitmap.bit_count)
+
     def test_empty_bitmap_file(self):
         """Test reading completely empty file."""
         with self.assertRaises(ValueError):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/dulwich-dulwich-1.2.21/tests/test_client.py 
new/dulwich-dulwich-1.2.22/tests/test_client.py
--- old/dulwich-dulwich-1.2.21/tests/test_client.py     2026-11-05 
00:54:34.000000000 +0100
+++ new/dulwich-dulwich-1.2.22/tests/test_client.py     2026-11-25 
00:28:20.000000000 +0100
@@ -24,6 +24,7 @@
 import logging
 import os
 import shutil
+import socket
 import stat
 import sys
 import tempfile
@@ -2851,6 +2852,18 @@
 
 
 class TCPGitClientTests(TestCase):
+    def test_timeout(self) -> None:
+        server = socket.socket()
+        self.addCleanup(server.close)
+        server.bind(("127.0.0.1", 0))
+        server.listen(1)
+        c, path = get_transport_and_path_from_url(
+            f"git://127.0.0.1:{server.getsockname()[1]}/repo", timeout=1
+        )
+        with self.assertRaises(GitProtocolError) as cm:
+            c.get_refs(path)
+        self.assertEqual("timed out", str(cm.exception))
+
     def test_get_url(self) -> None:
         host = "github.com"
         path = "/jelmer/dulwich"
@@ -3491,6 +3504,7 @@
                 f"SetEnv 
GIT_PROTOCOL=version={DEFAULT_GIT_PROTOCOL_VERSION_FETCH}",
             ]
         expected += [
+            "--",
             "user@host",
             "git-clone-url",
         ]
@@ -3521,6 +3535,7 @@
                 f"SetEnv 
GIT_PROTOCOL=version={DEFAULT_GIT_PROTOCOL_VERSION_FETCH}",
             ]
         expected += [
+            "--",
             "host",
             "git-clone-url",
         ]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/dulwich-dulwich-1.2.21/tests/test_object_store.py 
new/dulwich-dulwich-1.2.22/tests/test_object_store.py
--- old/dulwich-dulwich-1.2.21/tests/test_object_store.py       2026-11-05 
00:54:34.000000000 +0100
+++ new/dulwich-dulwich-1.2.22/tests/test_object_store.py       2026-11-25 
00:28:20.000000000 +0100
@@ -34,12 +34,17 @@
 
 import dulwich.pack
 from dulwich.config import ConfigDict
-from dulwich.errors import ChecksumMismatch, NotTreeError, 
ObjectFormatException
+from dulwich.errors import (
+    ApplyDeltaError,
+    ChecksumMismatch,
+    NotTreeError,
+    ObjectFormatException,
+)
 from dulwich.file import GitFile
 from dulwich.gc import garbage_collect
 from dulwich.index import commit_tree
 from dulwich.midx import write_midx_file
-from dulwich.object_format import DEFAULT_OBJECT_FORMAT
+from dulwich.object_format import DEFAULT_OBJECT_FORMAT, SHA256
 from dulwich.object_store import (
     DEFAULT_TEMPFILE_GRACE_PERIOD,
     DiskObjectStore,
@@ -67,9 +72,16 @@
 )
 from dulwich.pack import (
     DEFAULT_DELTA_BASE_CACHE_LIMIT,
+    OFS_DELTA,
     REF_DELTA,
+    HashWriter,
     Pack,
+    SHA1Writer,
+    UnresolvedDeltas,
+    create_delta,
     load_pack_index,
+    write_pack_header,
+    write_pack_object,
     write_pack_objects,
 )
 from dulwich.repo import Repo
@@ -569,6 +581,166 @@
             self.assertEqual([], entries)
             o.add_thin_pack(f.read, None)
 
+    def _assert_nothing_left_behind(self, o: DiskObjectStore) -> None:
+        self.assertEqual([], os.listdir(o.pack_dir))
+        self.assertEqual(
+            [], [n for n in os.listdir(o.path) if n.startswith("tmp_pack_")]
+        )
+
+    def test_add_thin_pack_delta_chain(self) -> None:
+        # A chain of depth 3 that starts at a base outside the pack: a ref
+        # delta to the external blob, an ofs delta on that, and an in-pack
+        # ref delta on the ofs delta, plus a full object.
+        o = DiskObjectStore(self.store_dir)
+        self.addCleanup(o.close)
+        blob = make_object(Blob, data=b"yummy data")
+        o.add_object(blob)
+
+        f = BytesIO()
+        entries = build_pack(
+            f,
+            [
+                (REF_DELTA, (blob.id, b"yummy data, one")),
+                (OFS_DELTA, (0, b"yummy data, one, two")),
+                (REF_DELTA, (1, b"yummy data, one, two, three")),
+                (Blob.type_num, b"standalone"),
+            ],
+            store=o,
+        )
+
+        with o.add_thin_pack(f.read, None) as pack:
+            pack.check()
+            shas = [sha_to_hex(e[3]) for e in entries]
+            self.assertEqual(sorted([blob.id, *shas]), sorted(pack))
+            for (_, type_num, data, _, _), sha in zip(entries, shas):
+                self.assertEqual((type_num, data), o.get_raw(sha))
+            # The external base is appended to complete the pack.
+            self.assertEqual((Blob.type_num, b"yummy data"), 
pack.get_raw(blob.id))
+
+    def test_add_thin_pack_tree_delta(self) -> None:
+        o = DiskObjectStore(self.store_dir)
+        self.addCleanup(o.close)
+        blob = make_object(Blob, data=b"yummy data")
+        tree = Tree()
+        tree.add(b"a", 0o100644, blob.id)
+        o.add_objects([(blob, None), (tree, None)])
+        new_tree = Tree()
+        new_tree.add(b"a", 0o100644, blob.id)
+        new_tree.add(b"b", 0o100644, blob.id)
+
+        f = BytesIO()
+        build_pack(f, [(REF_DELTA, (tree.id, new_tree.as_raw_string()))], 
store=o)
+
+        with o.add_thin_pack(f.read, None) as pack:
+            self.assertIn(new_tree.id, pack)
+            self.assertEqual(new_tree, o[new_tree.id])
+
+    def test_add_thin_pack_walks_pack_once(self) -> None:
+        o = DiskObjectStore(self.store_dir)
+        self.addCleanup(o.close)
+        blob = make_object(Blob, data=b"yummy data")
+        o.add_object(blob)
+
+        f = BytesIO()
+        build_pack(
+            f,
+            [
+                (REF_DELTA, (blob.id, b"yummy data, one")),
+                (OFS_DELTA, (0, b"yummy data, one, two")),
+                (Blob.type_num, b"standalone"),
+            ],
+            store=o,
+        )
+
+        with patch.object(dulwich.pack.PackInflater, "for_pack_data") as 
inflate:
+            o.add_thin_pack(f.read, None).close()
+        inflate.assert_not_called()
+
+    def test_add_thin_pack_sha256_tree_delta(self) -> None:
+        store_dir = tempfile.mkdtemp()
+        self.addCleanup(shutil.rmtree, store_dir)
+        o = DiskObjectStore.init(store_dir, object_format=SHA256)
+        self.addCleanup(o.close)
+        blob = make_object(Blob, data=b"yummy data")
+        o.add_object(blob)
+        blob_id = blob.get_id(SHA256)
+        tree = Tree()
+        tree.add(b"a", 0o100644, blob_id)
+        o.add_object(tree)
+        new_tree = Tree()
+        new_tree.add(b"a", 0o100644, blob_id)
+        new_tree.add(b"b", 0o100644, blob_id)
+
+        f = BytesIO()
+        sf = HashWriter(f, SHA256.hash_func)
+        write_pack_header(sf.write, 1)
+        delta = list(create_delta(tree.as_raw_string(), 
new_tree.as_raw_string()))
+        write_pack_object(
+            sf.write,
+            REF_DELTA,
+            (hex_to_sha(tree.get_id(SHA256)), delta),
+            object_format=SHA256,
+        )
+        sf.write_hash()
+        f.seek(0)
+
+        new_id = new_tree.get_id(SHA256)
+        with o.add_thin_pack(f.read, None) as pack:
+            self.assertIn(new_id, pack)
+            self.assertEqual(new_tree.items(), o[new_id].items())
+
+    def test_add_thin_pack_rejects_malformed_tree_delta(self) -> None:
+        # A delta that resolves to a tree which cannot be parsed must not be
+        # ingested, as for a full object in 
test_add_pack_rejects_malformed_tree.
+        o = DiskObjectStore(self.store_dir)
+        self.addCleanup(o.close)
+        tree = Tree()
+        tree.add(b"a", 0o100644, make_object(Blob, data=b"yummy data").id)
+        o.add_object(tree)
+
+        f = BytesIO()
+        build_pack(f, [(REF_DELTA, (tree.id, b"this is not a tree at all"))], 
store=o)
+
+        self.assertRaises(ObjectFormatException, o.add_thin_pack, f.read, None)
+        self._assert_nothing_left_behind(o)
+
+    def test_add_thin_pack_rejects_corrupt_delta(self) -> None:
+        o = DiskObjectStore(self.store_dir)
+        self.addCleanup(o.close)
+        blob = make_object(Blob, data=b"yummy data")
+        o.add_object(blob)
+
+        # A delta made against a different base: its source size does not
+        # match the blob it claims to apply to.
+        f = BytesIO()
+        sf = SHA1Writer(f)
+        write_pack_header(sf.write, 1)
+        delta = list(create_delta(b"some other base data", b"more yummy data"))
+        write_pack_object(
+            sf.write,
+            REF_DELTA,
+            (hex_to_sha(blob.id), delta),
+            object_format=DEFAULT_OBJECT_FORMAT,
+        )
+        sf.write_sha()
+        f.seek(0)
+
+        self.assertRaises(ApplyDeltaError, o.add_thin_pack, f.read, None)
+        self._assert_nothing_left_behind(o)
+
+    def test_add_thin_pack_missing_external_base(self) -> None:
+        o = DiskObjectStore(self.store_dir)
+        self.addCleanup(o.close)
+        other = MemoryObjectStore()
+        blob = make_object(Blob, data=b"yummy data")
+        other.add_object(blob)
+
+        f = BytesIO()
+        build_pack(f, [(REF_DELTA, (blob.id, b"more yummy data"))], 
store=other)
+
+        self.assertRaises(UnresolvedDeltas, o.add_thin_pack, f.read, None)
+        self._assert_nothing_left_behind(o)
+
     def test_add_pack_rejects_malformed_tree(self) -> None:
         # A pack containing a "tree" whose body cannot be parsed must not
         # be ingested: MemoryObjectStore and ``git fsck`` already reject
@@ -609,6 +781,7 @@
 
         with self.assertRaises(PackInputTooLarge):
             o.add_thin_pack(f.read, None, max_input_size=8)
+        self._assert_nothing_left_behind(o)
 
     def test_big_file_threshold_config(self) -> None:
         # core.bigFileThreshold caps single-object decompression to guard
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/dulwich-dulwich-1.2.21/tests/test_objects.py 
new/dulwich-dulwich-1.2.22/tests/test_objects.py
--- old/dulwich-dulwich-1.2.21/tests/test_objects.py    2026-11-05 
00:54:34.000000000 +0100
+++ new/dulwich-dulwich-1.2.22/tests/test_objects.py    2026-11-25 
00:28:20.000000000 +0100
@@ -1485,6 +1485,34 @@
             _do_test_sorted_tree_items, _sorted_tree_items_rs
         )
 
+    def _do_test_sorted_tree_items_slash_in_names(self, sorted_tree_items) -> 
None:
+        # Names containing '/' are invalid, but must still sort consistently
+        # rather than tripping up the sort implementation.
+        names = [
+            b"a/aa/", b"a", b"aaa/a", b"a/a//a", b"a//", b"aaa", b"a//a/a",
+            b"a/a/a", b"a/aa/a", b"a/a//", b"a//a", b"a//aa", b"aa/a", 
b"a///a",
+            b"a/a/a/a", b"a/a/", b"a/a/aa", b"a///", b"aa/", b"a/a/a/", 
b"a/aaa",
+        ]  # fmt: skip
+        dirs = {
+            b"a", b"aaa/a", b"a/a//a", b"a//", b"a//a/a", b"a/a/a", b"a/aa/a",
+            b"aa/a", b"a///a", b"a///", b"a/aaa",
+        }  # fmt: skip
+        sha = b"0" * 40
+        entries = {n: (stat.S_IFDIR if n in dirs else 0o100644, sha) for n in 
names}
+        expected = [
+            TreeEntry(n, entries[n][0], sha)
+            for n in sorted(names, key=lambda n: n + b"/" if n in dirs else n)
+        ]
+        self.assertEqual(expected, list(sorted_tree_items(entries, False)))
+
+    test_sorted_tree_items_slash_in_names = functest_builder(
+        _do_test_sorted_tree_items_slash_in_names, _sorted_tree_items_py
+    )
+    if _sorted_tree_items_rs is not None:
+        test_sorted_tree_items_slash_in_names_extension = ext_functest_builder(
+            _do_test_sorted_tree_items_slash_in_names, _sorted_tree_items_rs
+        )
+
     def _do_test_sorted_tree_items_name_order(self, sorted_tree_items) -> None:
         self.assertEqual(
             [

Reply via email to