Remove multiple stages returned by git.ls_files
authorCatalin Marinas <catalin.marinas@gmail.com>
Wed, 19 Dec 2007 18:00:15 +0000 (18:00 +0000)
committerCatalin Marinas <catalin.marinas@gmail.com>
Wed, 19 Dec 2007 23:13:32 +0000 (23:13 +0000)
This patch uses a set to return unique file names from git.ls_files in
case there are multiple stages in the index.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
stgit/git.py

index 01076c9..8862bb8 100644 (file)
@@ -182,11 +182,13 @@ def ls_files(files, tree = None, full_name = True):
     args.append('--')
     args.extend(files)
     try:
-        return GRun('ls-files', '--error-unmatch', *args).output_lines()
+        # use a set to avoid file names duplication due to different stages
+        fileset = set(GRun('ls-files', '--error-unmatch', *args).output_lines())
     except GitRunException:
         # just hide the details of the 'git ls-files' command we use
         raise GitException, \
             'Some of the given paths are either missing or not known to GIT'
+    return list(fileset)
 
 def tree_status(files = None, tree_id = 'HEAD', unknown = False,
                   noexclude = True, verbose = False, diff_flags = []):