2009/5/4 Shinya Kuribayashi <skuribay@xxxxxxxxxxxxxx>: > Catalin Marinas wrote: >> +def color_diff_flags(): >> + """Return the git flags for coloured diff output if the configuration >> and >> + stdout allows.""" >> + if sys.stdout.isatty() and config.get('color.diff') in ['true', >> 'auto']: >> + return ['--color'] >> + else: >> + return [] >> + >> def check_local_changes(): >> if git.local_changes(): >> raise CmdException('local changes in the tree. Use "refresh" or' > > Junio introduces `color.ui=auto' as one of base settings in his recent > Japanese article for Git newbies: That's probably a better option. I changed the patch to this (only showing the relevant parts): --- a/stgit/commands/common.py +++ b/stgit/commands/common.py @@ -97,6 +97,15 @@ def git_commit(name, repository, branch_name = None): except libgit.RepositoryException: raise CmdException('%s: Unknown patch or revision name' % name) +def color_diff_flags(): + """Return the git flags for coloured diff output if the configuration and + stdout allows.""" + stdout_is_tty = (sys.stdout.isatty() and 'true') or 'false' + if config.get_colorbool('color.diff', stdout_is_tty) == 'true': + return ['--color'] + else: + return [] + def check_local_changes(): if git.local_changes(): raise CmdException('local changes in the tree. Use "refresh" or' --- a/stgit/config.py +++ b/stgit/config.py @@ -109,16 +110,18 @@ class GitConfig: if m: result.append(m.group(1)) return result + + def get_colorbool(self, name, stdout_is_tty): + """Invoke 'git config --get-colorbool' and return the result.""" + return Run('git', 'config', '--get-colorbool', name, + stdout_is_tty).output_one_line() config=GitConfig() >> diff --git a/stgit/config.py b/stgit/config.py >> index efce097..4f16978 100644 >> --- a/stgit/config.py >> +++ b/stgit/config.py >> @@ -37,7 +37,8 @@ class GitConfig: >> 'stgit.autoimerge': 'no', >> 'stgit.keepoptimized': 'no', >> 'stgit.extensions': '.ancestor .current .patched', >> - 'stgit.shortnr': '5' >> + 'stgit.shortnr': '5', >> + 'stgit.pager': 'less -FRSX' >> } >> __cache={} > > Wrong indentation? :-) The indentation is right, only that in the past there was a tab left which I removed with this occasion. -- Catalin -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html