[StGIT PATCH] Teach StGIT about core.excludesfile

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

 



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

---

 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

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

  Powered by Linux