Skip to content

Commit b2c25e7

Browse files
committed
Fix handling of duplicated files in git ls-files output
1 parent b87d15f commit b2c25e7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

gitsearchreplace/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import os
1111
import bisect
1212
import fnmatch
13+
from sets import Set
1314

1415
def run_subprocess(cmd):
1516
pipe = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
@@ -110,8 +111,9 @@ def sub(self, expr, content, stage):
110111

111112
def search_replace_in_files(self):
112113
filenames = run_subprocess(["git", "ls-files"]).splitlines()
114+
unique_filenames = list(Set(filenames))
113115
filtered_filenames = []
114-
for filename in filenames:
116+
for filename in unique_filenames:
115117
excluded = False
116118
for exclude in self.exclude:
117119
if fnmatch.fnmatch(filename, exclude):

0 commit comments

Comments
 (0)