git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Catalin Marinas <catalin.marinas@gmail.com>
To: Shinya Kuribayashi <skuribay@ruby.dti.ne.jp>
Cc: git@vger.kernel.org, "Karl Hasselström" <kha@treskal.com>
Subject: Re: [StGit PATCH 9/9] Use the default git colouring scheme rather  than specific scripts
Date: Fri, 29 May 2009 13:22:48 +0100	[thread overview]
Message-ID: <b0943d9e0905290522l377c8f35h7f442b183cb7c7d2@mail.gmail.com> (raw)
In-Reply-To: <49FEE41F.4010006@ruby.dti.ne.jp>

2009/5/4 Shinya Kuribayashi <skuribay@ruby.dti.ne.jp>:
> 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

  reply	other threads:[~2009-05-29 12:22 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-28 15:09 [StGit PATCH 0/9] Various StGit updates Catalin Marinas
2009-04-28 15:09 ` [StGit PATCH 1/9] Show "Pushing <patch>...done" when pushing a patch Catalin Marinas
2009-04-29  6:04   ` Karl Hasselström
2009-04-28 15:09 ` [StGit PATCH 2/9] Show some progress information when checking for upstream merges Catalin Marinas
2009-04-29  6:07   ` Karl Hasselström
2009-04-28 15:09 ` [StGit PATCH 3/9] Do not sleep after the last patch sent by e-mail Catalin Marinas
2009-04-29  6:13   ` Karl Hasselström
2009-04-28 15:09 ` [StGit PATCH 4/9] Convert 'clone' to the use stgit.lib Catalin Marinas
2009-04-29  6:21   ` Karl Hasselström
2009-05-13 16:10     ` Catalin Marinas
2009-04-28 15:10 ` [StGit PATCH 5/9] Convert 'hide' to the lib infrastructure Catalin Marinas
2009-04-29  6:27   ` Karl Hasselström
2009-05-13 16:08     ` Catalin Marinas
2009-04-28 15:10 ` [StGit PATCH 6/9] Convert 'unhide' " Catalin Marinas
2009-04-29  6:29   ` Karl Hasselström
2009-04-28 15:10 ` [StGit PATCH 7/9] Reinstate the --annotate option for refresh Catalin Marinas
2009-04-29  6:33   ` Karl Hasselström
2009-04-28 15:10 ` [StGit PATCH 8/9] Add the log --clear option Catalin Marinas
2009-04-29  6:35   ` Karl Hasselström
2009-04-28 15:10 ` [StGit PATCH 9/9] Use the default git colouring scheme rather than specific scripts Catalin Marinas
2009-04-29  6:43   ` Karl Hasselström
2009-04-29 11:48     ` Samuel Tardieu
2009-04-29 11:56       ` Samuel Tardieu
2009-04-29 14:25       ` Karl Hasselström
2009-05-04 12:48   ` Shinya Kuribayashi
2009-05-29 12:22     ` Catalin Marinas [this message]
2009-05-30  0:36       ` Shinya Kuribayashi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b0943d9e0905290522l377c8f35h7f442b183cb7c7d2@mail.gmail.com \
    --to=catalin.marinas@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=kha@treskal.com \
    --cc=skuribay@ruby.dti.ne.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).