git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Karl Hasselström" <kha@treskal.com>
To: Catalin Marinas <catalin.marinas@gmail.com>
Cc: git@vger.kernel.org
Subject: [StGIT PATCH] Teach StGIT about core.excludesfile
Date: Tue, 07 Aug 2007 04:40:37 +0200	[thread overview]
Message-ID: <20070807024037.11009.14569.stgit@yoghurt> (raw)

If there is a core.excludesfile option specified, let StGIT take
exclude patterns from that file, since that's what the docs say, and
what everyone else is already doing.

Signed-off-by: Karl Hasselström <kha@treskal.com>

---

 stgit/git.py |   27 +++++++++++++++------------
 1 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/stgit/git.py b/stgit/git.py
index 72bf889..57c156e 100644
--- a/stgit/git.py
+++ b/stgit/git.py
@@ -216,6 +216,13 @@ def __run(cmd, args=None):
         return r
     return 0
 
+def exclude_files():
+    files = [os.path.join(basedir.get(), 'info', 'exclude')]
+    user_exclude = config.get('core.excludesfile')
+    if user_exclude:
+        files.append(user_exclude)
+    return files
+
 def tree_status(files = None, tree_id = 'HEAD', unknown = False,
                   noexclude = True, verbose = False, diff_flags = []):
     """Returns a list of pairs - [status, filename]
@@ -231,20 +238,16 @@ def tree_status(files = None, tree_id = 'HEAD', unknown = False,
 
     # unknown files
     if unknown:
-        exclude_file = os.path.join(basedir.get(), 'info', 'exclude')
-        base_exclude = ['--exclude=%s' % s for s in
-                        ['*.[ao]', '*.pyc', '.*', '*~', '#*', 'TAGS', 'tags']]
-        base_exclude.append('--exclude-per-directory=.gitignore')
-
-        if os.path.exists(exclude_file):
-            extra_exclude = ['--exclude-from=%s' % exclude_file]
-        else:
-            extra_exclude = []
         if noexclude:
-            extra_exclude = base_exclude = []
-
+            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 = _output_lines(['git-ls-files', '--others', '--directory']
-                        + base_exclude + extra_exclude)
+                              + exclude)
         cache_files += [('?', line.strip()) for line in lines]
 
     # conflicted files

                 reply	other threads:[~2007-08-07  2:40 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20070807024037.11009.14569.stgit@yoghurt \
    --to=kha@treskal.com \
    --cc=catalin.marinas@gmail.com \
    --cc=git@vger.kernel.org \
    /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).