git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [StGIT PATCH] Teach StGIT about core.excludesfile
@ 2007-08-07  2:40 Karl Hasselström
  0 siblings, 0 replies; only message in thread
From: Karl Hasselström @ 2007-08-07  2:40 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git

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

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2007-08-07  2:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-07  2:40 [StGIT PATCH] Teach StGIT about core.excludesfile Karl Hasselström

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