From: Shawn O. Pearce Date: Fri, 11 Jul 2008 04:22:51 GMT Subject: Re: [EGIT PATCH 1/9] Create a listener structure for changes to refs and index Message-ID: <20080711042251.GB32633@spearce.org> In-Reply-To: <1215729651-26781-2-git-send-email-robin.rosenberg@dewire.com> Robin Rosenberg wrote: > This version does not tell you which refs have changed, nor > what changes have happened. There is not scanning for externally > initiated changes either, though such changes can be found when > a JGit client wants to read index or refs information. > diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/RefDatabase.java b/org.spearce.jgit/src/org/spearce/jgit/lib/RefDatabase.java > index 9e3e020..4be33b8 100644 > --- a/org.spearce.jgit/src/org/spearce/jgit/lib/RefDatabase.java > +++ b/org.spearce.jgit/src/org/spearce/jgit/lib/RefDatabase.java > @@ -81,6 +81,10 @@ class RefDatabase { > > private long packedRefsLength; > > + long lastRefModification; > + > + long lastNotifiedRefModification; > + > RefDatabase(final Repository r) { > db = r; > gitDir = db.getDirectory(); > @@ -155,6 +161,12 @@ class RefDatabase { > } > if (!lck.commit()) > throw new ObjectWritingException("Unable to write " + name); > + setModified(); > + db.fireRefsMaybeChanged(); > + } > + > + void setModified() { > + lastRefModification = System.currentTimeMillis(); > } We don't ever actually need the time here as a time, do we? Wouldn't a simple counter work just as well, but ensure we don't lose notifications that occur more frequently then the resolution of currentTimeMillis()? -- Shawn.