This new flag allows to pass arbitrary flags to the git-diff calls
underlying several StGIT commands. It can be used to pass flags
affecting both diff- and status-generating commands (eg. -M or -C), or
flags only affecting diff-generating ones (eg. --color, --binary).
It supercedes --binary for commands where it was allowed,
'-O --binary' is now available for the same functionality.
Signed-off-by: Yann Dirson <ydirson@altern.org>
options = [make_option('-r', '--range',
metavar = 'rev1[..[rev2]]', dest = 'revs',
help = 'show the diff between revisions'),
options = [make_option('-r', '--range',
metavar = 'rev1[..[rev2]]', dest = 'revs',
help = 'show the diff between revisions'),
- make_option('--binary',
- help = 'output a diff even for binary files',
- action = 'store_true'),
+ make_option('-O', '--diff-opts',
+ help = 'options to pass to git-diff'),
make_option('-s', '--stat',
help = 'show the stat instead of the diff',
action = 'store_true')]
make_option('-s', '--stat',
help = 'show the stat instead of the diff',
action = 'store_true')]
rev1 = 'HEAD'
rev2 = None
rev1 = 'HEAD'
rev2 = None
- if options.binary:
- diff_flags = [ '--binary' ]
+ if options.diff_opts:
+ diff_flags = options.diff_opts.split()
help = 'Use FILE as a template'),
make_option('-b', '--branch',
help = 'use BRANCH instead of the default one'),
help = 'Use FILE as a template'),
make_option('-b', '--branch',
help = 'use BRANCH instead of the default one'),
- make_option('--binary',
- help = 'output a diff even for binary files',
- action = 'store_true'),
+ make_option('-O', '--diff-opts',
+ help = 'options to pass to git-diff'),
make_option('-s', '--stdout',
help = 'dump the patches to the standard output',
action = 'store_true')]
make_option('-s', '--stdout',
help = 'dump the patches to the standard output',
action = 'store_true')]
os.makedirs(dirname)
series = file(os.path.join(dirname, 'series'), 'w+')
os.makedirs(dirname)
series = file(os.path.join(dirname, 'series'), 'w+')
- if options.binary:
- diff_flags = [ '--binary' ]
+ if options.diff_opts:
+ diff_flags = options.diff_opts.split()
action = 'store_true'),
make_option('-b', '--branch',
help = 'use BRANCH instead of the default one'),
action = 'store_true'),
make_option('-b', '--branch',
help = 'use BRANCH instead of the default one'),
+ make_option('-O', '--diff-opts',
+ help = 'options to pass to git-diff'),
make_option('--bare',
help = 'bare file names (useful for scripting)',
action = 'store_true')]
make_option('--bare',
help = 'bare file names (useful for scripting)',
action = 'store_true')]
elif options.bare:
out.stdout_raw(git.barefiles(rev1, rev2) + '\n')
else:
elif options.bare:
out.stdout_raw(git.barefiles(rev1, rev2) + '\n')
else:
- out.stdout_raw(git.files(rev1, rev2) + '\n')
+ if options.diff_opts:
+ diff_flags = options.diff_opts.split()
+ else:
+ diff_flags = []
+
+ out.stdout_raw(git.files(rev1, rev2, diff_flags = diff_flags) + '\n')
help = 'username for SMTP authentication'),
make_option('-b', '--branch',
help = 'use BRANCH instead of the default one'),
help = 'username for SMTP authentication'),
make_option('-b', '--branch',
help = 'use BRANCH instead of the default one'),
- make_option('--binary',
- help = 'output a diff even for binary files',
- action = 'store_true'),
+ make_option('-O', '--diff-opts',
+ help = 'options to pass to git-diff'),
make_option('-m', '--mbox',
help = 'generate an mbox file instead of sending',
action = 'store_true')]
make_option('-m', '--mbox',
help = 'generate an mbox file instead of sending',
action = 'store_true')]
- if options.binary:
- diff_flags = [ '--binary' ]
+ if options.diff_opts:
+ diff_flags = options.diff_opts.split()
action = 'store_true'),
make_option('-u', '--unapplied',
help = 'show the unapplied patches',
action = 'store_true'),
make_option('-u', '--unapplied',
help = 'show the unapplied patches',
- action = 'store_true')]
+ action = 'store_true'),
+ make_option('-O', '--diff-opts',
+ help = 'options to pass to git-diff')]
def func(parser, options, args):
def func(parser, options, args):
else:
patches = parse_patches(args, applied + unapplied, len(applied))
else:
patches = parse_patches(args, applied + unapplied, len(applied))
+ if options.diff_opts:
+ diff_flags = options.diff_opts.split()
+ else:
+ diff_flags = []
+
commit_ids = [git_id(patch) for patch in patches]
commit_ids = [git_id(patch) for patch in patches]
- commit_str = '\n'.join([git.pretty_commit(commit_id)
+ commit_str = '\n'.join([git.pretty_commit(commit_id, diff_flags=diff_flags)
for commit_id in commit_ids])
if commit_str:
pager(commit_str)
for commit_id in commit_ids])
if commit_str:
pager(commit_str)
make_option('-x', '--noexclude',
help = 'do not exclude any files from listing',
action = 'store_true'),
make_option('-x', '--noexclude',
help = 'do not exclude any files from listing',
action = 'store_true'),
+ make_option('-O', '--diff-opts',
+ help = 'options to pass to git-diff'),
make_option('--reset',
help = 'reset the current tree changes',
action = 'store_true')]
make_option('--reset',
help = 'reset the current tree changes',
action = 'store_true')]
resolved_all()
git.reset()
else:
resolved_all()
git.reset()
else:
+ if options.diff_opts:
+ diff_flags = options.diff_opts.split()
+ else:
+ diff_flags = []
+
git.status(args, options.modified, options.new, options.deleted,
git.status(args, options.modified, options.new, options.deleted,
- options.conflict, options.unknown, options.noexclude)
+ options.conflict, options.unknown, options.noexclude,
+ diff_flags = diff_flags)
return 0
def __tree_status(files = None, tree_id = 'HEAD', unknown = False,
return 0
def __tree_status(files = None, tree_id = 'HEAD', unknown = False,
- noexclude = True, verbose = False):
+ noexclude = True, verbose = False, diff_flags = []):
"""Returns a list of pairs - [status, filename]
"""
if verbose:
"""Returns a list of pairs - [status, filename]
"""
if verbose:
cache_files += [('C', filename) for filename in conflicts]
# the rest
cache_files += [('C', filename) for filename in conflicts]
# the rest
- for line in _output_lines(['git-diff-index', tree_id, '--'] + files):
+ for line in _output_lines(['git-diff-index'] + diff_flags +
+ [ tree_id, '--'] + files):
fs = tuple(line.rstrip().split(' ',4)[-1].split('\t',1))
if fs[1] not in conflicts:
cache_files.append(fs)
fs = tuple(line.rstrip().split(' ',4)[-1].split('\t',1))
if fs[1] not in conflicts:
cache_files.append(fs)
raise GitException, 'GIT index merging failed (possible conflicts)'
def status(files = None, modified = False, new = False, deleted = False,
raise GitException, 'GIT index merging failed (possible conflicts)'
def status(files = None, modified = False, new = False, deleted = False,
- conflict = False, unknown = False, noexclude = False):
+ conflict = False, unknown = False, noexclude = False,
+ diff_flags = []):
"""Show the tree status
"""
if not files:
files = []
"""Show the tree status
"""
if not files:
files = []
- cache_files = __tree_status(files, unknown = True, noexclude = noexclude)
+ cache_files = __tree_status(files, unknown = True, noexclude = noexclude,
+ diff_flags = diff_flags)
all = not (modified or new or deleted or conflict or unknown)
if not all:
all = not (modified or new or deleted or conflict or unknown)
if not all:
raise GitException, 'git.diffstat failed'
return diff_str
raise GitException, 'git.diffstat failed'
return diff_str
+def files(rev1, rev2, diff_flags = []):
"""Return the files modified between rev1 and rev2
"""
result = ''
"""Return the files modified between rev1 and rev2
"""
result = ''
- for line in _output_lines(['git-diff-tree', '-r', rev1, rev2]):
+ for line in _output_lines(['git-diff-tree'] + diff_flags + ['-r', rev1, rev2]):
result += '%s %s\n' % tuple(line.rstrip().split(' ',4)[-1].split('\t',1))
return result.rstrip()
result += '%s %s\n' % tuple(line.rstrip().split(' ',4)[-1].split('\t',1))
return result.rstrip()
-def pretty_commit(commit_id = 'HEAD'):
+def pretty_commit(commit_id = 'HEAD', diff_flags = []):
"""Return a given commit (log + diff)
"""
"""Return a given commit (log + diff)
"""
- return _output(['git-diff-tree', '--cc', '--always', '--pretty', '-r',
- commit_id])
+ return _output(['git-diff-tree'] + diff_flags +
+ ['--cc', '--always', '--pretty', '-r', commit_id])
def checkout(files = None, tree_id = None, force = False):
"""Check out the given or all files
def checkout(files = None, tree_id = None, force = False):
"""Check out the given or all files