git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[StGIT PATCH] Teach StGIT about core.excludesfile

From
Karl Hasselström <kha@treskal.com>
Date
Aug 7, 2007, 02:40 UTC
Message-ID
<20070807024037.11009.14569.stgit@yoghurt>

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
Message 1 of 1 in “Teach StGIT about core.excludesfile”
  1. Teach StGIT about core.excludesfileKarl Hasselström, Aug 7, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.