From 7f173a17ed57f133fa4985f18ce645d1fd957f1d Mon Sep 17 00:00:00 2001 From: Alan Date: Thu, 25 May 2023 13:39:30 +0800 Subject: [PATCH] disable comment on get_upstream --- GitBranch.vala | 13 ++++++++--- GitRepo.vala | 8 ++++--- Monitor.vala | 5 +++++ c/push.c.vala | 0 fanotify/fanotify.vala | 49 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 69 insertions(+), 6 deletions(-) delete mode 100644 c/push.c.vala create mode 100644 fanotify/fanotify.vala diff --git a/GitBranch.vala b/GitBranch.vala index a2ec3157..1f309f48 100644 --- a/GitBranch.vala +++ b/GitBranch.vala @@ -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); diff --git a/GitRepo.vala b/GitRepo.vala index fa5ce1a7..e3a72949 100644 --- a/GitRepo.vala +++ b/GitRepo.vala @@ -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(); } diff --git a/Monitor.vala b/Monitor.vala index b8e3bced..8a649c64 100644 --- a/Monitor.vala +++ b/Monitor.vala @@ -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 index e69de29b..00000000 diff --git a/fanotify/fanotify.vala b/fanotify/fanotify.vala new file mode 100644 index 00000000..d73859ae --- /dev/null +++ b/fanotify/fanotify.vala @@ -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 -- 2.39.2