Преглед изворни кода

change to is not None

Spelling

less assert

no 1

kick cI

ruff
Eli Fine пре 1 месец
родитељ
комит
f73810ffcd
2 измењених фајлова са 13 додато и 1 уклоњено
  1. 1 1
      dulwich/porcelain.py
  2. 12 0
      tests/test_porcelain.py

+ 1 - 1
dulwich/porcelain.py

@@ -1485,7 +1485,7 @@ def add(
             get_unstaged_changes(index, r.path, filter_callback, preload_index)
         )
 
-        if not paths:
+        if paths is None:
             # When no paths specified, add all untracked and modified files from repo root
             paths = [str(repo_path)]
         relpaths = []

+ 12 - 0
tests/test_porcelain.py

@@ -2139,6 +2139,18 @@ class AddTests(PorcelainTestCase):
         self.assertIn(b"existing.txt", index)
         self.assertIn(b"new.txt", index)
 
+    def test_add_empty_paths_list(self) -> None:
+        """Test that passing paths=[] does not add any files."""
+        # Create an untracked file
+        with open(os.path.join(self.repo.path, "file.txt"), "w") as f:
+            f.write("content")
+
+        # Add with empty paths list
+        added, _ignored = porcelain.add(self.repo.path, paths=[])
+
+        # Should not add any files
+        self.assertEqual(len(added), 0)
+
 
 class RemoveTests(PorcelainTestCase):
     def test_remove_file(self) -> None: