Re: [StGit PATCH 9/9] Use the default git colouring scheme rather than specific scripts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

Catalin Marinas wrote:
This patch adds the mechanism to check if the output is tty for the
diff and show commands and passes the --color option to git if the
color.diff config option is set auto or true. The patch also changes the
default pager to 'less -FRSX' from the diffcol.sh script.

Signed-off-by: Catalin Marinas <catalin.marinas@xxxxxxxxx>

Cool.

diff --git a/stgit/commands/common.py b/stgit/commands/common.py
index 6bb3685..e46412e 100644
--- a/stgit/commands/common.py
+++ b/stgit/commands/common.py
@@ -83,6 +83,14 @@ 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."""
+    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:

http://gitster.livejournal.com/2009/04/24/

Is color.ui worth supporting in color_diff_flags()?, or simply having additional color.diff would be better?

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? :-)


Shinya


--
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

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]