[gitg] Add gitg config to ignore certain submodules



commit bf15cb69e1af9242234da66f405e659d7e12a255
Author: Jesse van den Kieboom <jessevdk gmail com>
Date:   Sun Mar 8 10:37:56 2015 +0100

    Add gitg config to ignore certain submodules

 libgitg/gitg-stage-status-enumerator.vala |   38 +++++++++++++++++++++++++++-
 1 files changed, 36 insertions(+), 2 deletions(-)
---
diff --git a/libgitg/gitg-stage-status-enumerator.vala b/libgitg/gitg-stage-status-enumerator.vala
index 7cd9b64..cdb5b4d 100644
--- a/libgitg/gitg-stage-status-enumerator.vala
+++ b/libgitg/gitg-stage-status-enumerator.vala
@@ -205,6 +205,21 @@ public class StageStatusEnumerator : Object
        private Cancellable d_cancellable;
        private SourceFunc d_callback;
        private Ggit.StatusOptions? d_options;
+       private Gee.HashSet<string> d_ignored_submodules;
+
+       private static Regex s_ignore_regex;
+
+       static construct
+       {
+               try
+               {
+                       s_ignore_regex = new Regex("submodule\\.(.*)\\.gitgignore");
+               }
+               catch (Error e)
+               {
+                       stderr.printf(@"Failed to compile stage status enumerator regex: $(e.message)\n");
+               }
+       }
 
        internal StageStatusEnumerator(Repository repository,
                                       Ggit.StatusOptions? options = null)
@@ -218,6 +233,21 @@ public class StageStatusEnumerator : Object
 
                try
                {
+                       d_ignored_submodules = new Gee.HashSet<string>();
+
+                       repository.get_config().match_foreach(s_ignore_regex, (match, val) => {
+                               if (val != "true")
+                               {
+                                       return 0;
+                               }
+
+                               d_ignored_submodules.add(match.fetch(1));
+                               return 0;
+                       });
+               } catch {}
+
+               try
+               {
                        d_thread = new Thread<void *>.try("gitg-status-enumerator", run_status);
                } catch {}
        }
@@ -263,10 +293,14 @@ public class StageStatusEnumerator : Object
                try
                {
                        d_repository.submodule_foreach((submodule) => {
-                               submodule.set_ignore(Ggit.SubmoduleIgnore.UNTRACKED);
                                submodule_paths.add(submodule.get_path());
 
-                               add(new StageStatusSubmodule(submodule));
+                               if (!d_ignored_submodules.contains(submodule.get_name()))
+                               {
+                                       submodule.set_ignore(Ggit.SubmoduleIgnore.UNTRACKED);
+
+                                       add(new StageStatusSubmodule(submodule));
+                               }
 
                                return d_cancellable.is_cancelled() ? 1 : 0;
                        });


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