disable comment on get_upstream
authorAlan <alan@roojs.com>
Thu, 25 May 2023 05:39:30 +0000 (13:39 +0800)
committerAlan <alan@roojs.com>
Thu, 25 May 2023 05:39:30 +0000 (13:39 +0800)
GitBranch.vala
GitRepo.vala
Monitor.vala
c/push.c.vala [deleted file]
fanotify/fanotify.vala [new file with mode: 0644]

index a2ec315..1f309f4 100644 (file)
@@ -90,12 +90,15 @@ public class GitBranch : Object
                                remotes.set(rn.substring(11), rh.get_oid());
                                remotes_used.set(rn.substring(11), false);
 
-                 } 
+                   } 
+                  
+                   
                } catch (Error e) {
                        GLib.debug("Failed to fetch remotes continuing on ");
                }
+          rem.disconnect();
+               
                
-                
                var r = repo.repo.enumerate_branches(Ggit.BranchType.LOCAL);
                while (r.next()) {
                
@@ -110,13 +113,17 @@ public class GitBranch : Object
                        br.active = gbr.is_head();
                        br.name = gbr.get_name();
                        br.lastrev = gbr.get_target().to_string();
-                       string rname ;
+                       string rname ="";
+                       /*
+                       
+                       THIS IS DISABLED, and get_upstream has a major memor leak.
                        try {
                                rname = gbr.get_upstream() != null ? gbr.get_upstream().get_name() : "";
                        } catch(Error e) {
                                GLib.debug("Skip branch = got error");
                                continue;
                        }
+                       */
                        repo.branches.set(gbr.get_name(), br);                  
                        if (rname.has_prefix("refs/remotes/origin/")) {
                                rname = rname.substring(20);
index fa5ce1a..e3a7294 100644 (file)
@@ -218,12 +218,12 @@ public class GitRepo : Object
        
        this.repo =  Ggit.Repository.open(GLib.File.new_for_path(path));
        
-       var r = this.repo.lookup_remote("origin");
+       //var r = this.repo.lookup_remote("origin");
        
        
        //var r = this.git({ "remote" , "get-url" , "--push" , "origin"});
-       var uri = new Soup.URI(r.get_url());            
-       this.host = uri.get_host();
+       //var uri = new Soup.URI(r.get_url());          
+       //this.host = uri.get_host();
                this.init_config();
        
        this.loadBranches();
@@ -1014,6 +1014,7 @@ public class GitRepo : Object
                                var options = new Ggit.FetchOptions();
                                options.set_remote_callbacks( new GitCallbacks(this));
                                r.download(far, options);
+                               r.disconnect();
                        }
                        this.loadStatus();
                         
@@ -1137,6 +1138,7 @@ public class GitRepo : Object
                var cb = new GitCallbacks(this);
                r.connect(Ggit.Direction.FETCH, cb, null, null);
                this.remote_heads = r.list();
+               r.disconnect();
        
        }
     
index b8e3bce..8a649c6 100644 (file)
@@ -164,6 +164,11 @@ public class Monitor : gitMonitorBase
  
                  fm.changed.connect( this.onEvent );
                 this.monitors.append_val(fm);
+                
+                total_monitors++;
+                GLib.debug("Total Monitors this: %d, All:%d: %s", (int)this.monitors.length, total_monitors, path);
 
             } catch (Error e) {
                   GLib.debug("Error adding monitor: %s\n", e.message);
diff --git a/c/push.c.vala b/c/push.c.vala
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/fanotify/fanotify.vala b/fanotify/fanotify.vala
new file mode 100644 (file)
index 0000000..d73859a
--- /dev/null
@@ -0,0 +1,49 @@
+
+/**
+valac --vapidir=. --pkg fanotify --pkg posix -o /tmp/fanotify fanotify.vala fanotify-helper.c
+*/
+
+extern   void fanotify_read (int fh);
+
+void main (string[] args) {
+
+  
+    // root version?
+    //var fan = Fanotify.init(Fanotify.InitFlag.CLOEXEC | Fanotify.InitFlag.CLASS_CONTENT ,   Posix.O_RDONLY );   
+    
+      //non-root (not content?)
+    // var fan = Fanotify.init(Fanotify.InitFlag.CLOEXEC | Fanotify.InitFlag.CLASS_NOTIF | Fanotify.InitFlag.REPORT_FID   , Posix.O_RDONLY );
+     var fan = Fanotify.init(
+            Fanotify.InitFlag.CLOEXEC | Fanotify.InitFlag.CLASS_NOTIF | Fanotify.InitFlag.REPORT_DIR_FID  |  Fanotify.InitFlag.REPORT_NAME ,
+            Posix.O_RDONLY );   
+    if(fan == -1){
+        Posix.perror("fanotify_init");
+        Posix.exit(Posix.EXIT_FAILURE);
+    }
+    /* 
+    // root version.
+     var ret = Fanotify.mark(
+                fan,
+                Fanotify.Mark.ADD | Fanotify.Mark.MOUNT,
+                Fanotify.EventType.OPEN_PERM  | Fanotify.EventType.CLOSE_WRITE  ,  
+                Posix.AT_FDCWD, "/home/"
+    );
+ */
+    // not root version?
+    var ret = Fanotify.mark(
+                fan,
+                Fanotify.Mark.ADD  ,
+                Fanotify.EventType.CREATE | Fanotify.EventType.DELETE | Fanotify.EventType.MODIFY | Fanotify.EventType.EVENT_ON_CHILD,
+                Posix.AT_FDCWD, "/home/alan/gitlive/gitlive/fanotify"
+    );
+    
+    if(ret == -1){
+        Posix.perror("fanotify_mark");
+        Posix.exit(Posix.EXIT_FAILURE);
+    }
+    Posix.printf("got mark %d", ret);
+    fanotify_read(fan);
+    
+}
\ No newline at end of file