Browse Source

Apply filters during checkout operations (#1661)

Git applies clean/smudge filters by default during checkout operations
to ensure files in the working tree have the expected format (e.g.,
proper line endings). This change makes Dulwich's checkout behavior
consistent with Git's.

The checkout() function now gets the blob normalizer from the repository
and passes it to update_working_tree() to ensure filters are applied
when materializing files.
Jelmer Vernooij 1 month ago
parent
commit
7ebb28dc97
1 changed files with 4 additions and 0 deletions
  1. 4 0
      dulwich/porcelain.py

+ 4 - 0
dulwich/porcelain.py

@@ -3030,6 +3030,9 @@ def checkout(
                 with open(target, mode) as f:
                     f.write(source)
 
+        # Get blob normalizer for line ending conversion
+        blob_normalizer = r.get_blob_normalizer()
+
         # Update working tree
         update_working_tree(
             r,
@@ -3039,6 +3042,7 @@ def checkout(
             validate_path_element=validate_path_element,
             symlink_fn=symlink_fn,
             force_remove_untracked=force,
+            blob_normalizer=blob_normalizer,
         )
 
         # Update HEAD