git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[JGIT PATCH 1/2] Fix missing packed-refs entries during ref lookup/enumeration

From
Shawn O. Pearce <spearce@spearce.org>
Date
Jul 27, 2008, 04:33 UTC
Message-ID
<1217133221-15513-1-git-send-email-spearce@spearce.org>

Some codepaths in RefDatabase allowed the caller to lookup a ref without making sure the packed-refs file was loaded into memory. This caused refs which were only packed to appear to not exist, which meant fetch would still try to fetch something we already have had for quite some time.

This resolves the issue I was seeing where `jgit fetch` was always downloading the stable branch of egit.git, even though it has not changed in many weeks.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 .../src/org/spearce/jgit/lib/RefDatabase.java      |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
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 82b995e..98c365e 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/RefDatabase.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/RefDatabase.java
@@ -115,6 +115,7 @@ class RefDatabase {
 	}
 
 	ObjectId idOf(final String name) throws IOException {
+		refreshPackedRefs();
 		final Ref r = readRefBasic(name, 0);
 		return r != null ? r.getObjectId() : null;
 	}
@@ -132,6 +133,7 @@ class RefDatabase {
 	 *             to the base ref, as the symbolic ref could not be read.
 	 */
 	RefUpdate newUpdate(final String name) throws IOException {
+		refreshPackedRefs();
 		Ref r = readRefBasic(name, 0);
 		if (r == null)
 			r = new Ref(Ref.Storage.NEW, name, null);
-- 
1.6.0.rc0.182.gb96c7
Next: Shawn O. Pearce
Message 1 of 2 in “Fix missing packed-refs entries during ref lookup/enumeration”
  1. 1/2 Fix missing packed-refs entries during ref lookup/enumerationShawn O. Pearce, Jul 27, 2008
  2. 2/2 Teach fetch command line a --verbose/-v switch for unchanged refsShawn O. Pearce, Jul 27, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.