Improved the python code, eliminating temporary variables and using
destructuring binds. And use NUL-separation instead of newlines.
Signed-off-by: David Kågedal <davidk@lysator.liu.se>
Signed-off-by: Karl Hasselström <kha@treskal.com>
"""Show the patches modifying a file
"""
if not args:
"""Show the patches modifying a file
"""
if not args:
- files = [stat[1] for stat in git.tree_status(verbose = True)]
+ files = [path for (stat,path) in git.tree_status(verbose = True)]
- files = [x[1] for x in git.tree_status(verbose = True)]
+ files = [path for (stat,path) in git.tree_status(verbose = True)]
if args:
files = [f for f in files if f in args]
if args:
files = [f for f in files if f in args]
def tree_status(files = None, tree_id = 'HEAD', unknown = False,
noexclude = True, verbose = False, diff_flags = []):
def tree_status(files = None, tree_id = 'HEAD', unknown = False,
noexclude = True, verbose = False, diff_flags = []):
- """Returns a list of pairs - [status, filename]
+ """Returns a list of pairs - (status, filename)
"""
if verbose:
out.start('Checking for changes in the working directory')
"""
if verbose:
out.start('Checking for changes in the working directory')
# unknown files
if unknown:
# unknown files
if unknown:
- if noexclude:
- exclude = []
- else:
- exclude = (['--exclude=%s' % s for s in
- ['*.[ao]', '*.pyc', '.*', '*~', '#*', 'TAGS', 'tags']]
- + ['--exclude-per-directory=.gitignore']
- + ['--exclude-from=%s' % fn for fn in exclude_files()
- if os.path.exists(fn)])
- lines = GRun('git-ls-files', '--others', '--directory', *exclude
- ).output_lines()
+ cmd = ['git-ls-files', '-z', '--others', '--directory']
+ if not noexclude:
+ cmd += ['--exclude=%s' % s for s in
+ ['*.[ao]', '*.pyc', '.*', '*~', '#*', 'TAGS', 'tags']]
+ cmd += ['--exclude-per-directory=.gitignore']
+ cmd += ['--exclude-from=%s' % fn
+ for fn in exclude_files()
+ if os.path.exists(fn)]
+
+ lines = GRun(*cmd).raw_output().split('\0')
cache_files += [('?', line) for line in lines]
# conflicted files
cache_files += [('?', line) for line in lines]
# conflicted files