[gitg/wip/albfan/other-refs: 20/20] Exclude unknow refs




commit ffaf03af0d624432a8c12f7989df91199512a87b
Author: Alberto Fanjul <albertofanjul gmail com>
Date:   Thu Sep 16 12:06:49 2021 +0200

    Exclude unknow refs
    
    Only heads and remotes have meaning for a default git repo

 gitg/history/gitg-history-refs-list.vala | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
---
diff --git a/gitg/history/gitg-history-refs-list.vala b/gitg/history/gitg-history-refs-list.vala
index 22831078..38ceb328 100644
--- a/gitg/history/gitg-history-refs-list.vala
+++ b/gitg/history/gitg-history-refs-list.vala
@@ -1017,6 +1017,17 @@ public class RefsList : Gtk.ListBox
                }
        }
 
+       // Checks if the provided reference should be filtered.
+       private bool ref_is_filtered(Gitg.Ref reference)
+       {
+               if (reference.parsed_name.rtype != Gitg.RefType.REMOTE)
+               {
+                       string name = reference.parsed_name.shortname;
+                       return !(name.has_prefix("refs/heads") || name.has_prefix("refs/remotes"));
+               }
+               return false;
+       }
+
        // Checks if the provided reference is a symbolic ref with the name HEAD.
        private bool ref_is_a_symbolic_head(Gitg.Ref reference)
        {
@@ -1208,6 +1219,10 @@ public class RefsList : Gtk.ListBox
                                        return 0;
                                }
 
+                               if (ref_is_filtered(r)) {
+                                       return 0;
+                               }
+
                                var row = add_ref_internal(r);
 
                                if (row != null && row.is_head)


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