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

[PATCH 5/7] Added removePackedRef method to RefDatabase for packed branch deletion

From
Charles O'Farrell <charleso@charleso.org>
Date
Aug 14, 2008, 10:13 UTC
Message-ID
<1218708829-8175-6-git-send-email-charleso@charleso.org>
In-Reply-To
<1218708829-8175-5-git-send-email-charleso@charleso.org>
Signed-off-by: Charles O'Farrell <charleso@charleso.org>
---
 .../src/org/spearce/jgit/lib/RefDatabase.java      |   16 +++++++++++++++-
 .../src/org/spearce/jgit/lib/Repository.java       |    2 +-
 2 files changed, 16 insertions(+), 2 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 3d8280d..0293ace 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/RefDatabase.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/RefDatabase.java
@@ -121,7 +121,7 @@ class RefDatabase {
 	}
 
 	/**
-	 * Create a command to update (or create) a ref in this repository.
+	 * Create a command to update, create or delete a ref in this repository.
 	 * 
 	 * @param name
 	 *            name of the ref the caller wants to modify.
@@ -432,6 +432,20 @@ class RefDatabase {
 			throw new ObjectWritingException("Unable to write " + name);
 	}
 
+	void removePackedRef(String name) throws IOException {
+		packedRefs.remove(name);
+		writePackedRefs();
+	}
+
+	private void writePackedRefs() throws IOException {
+		new RefWriter(packedRefs.values()) {
+			@Override
+			protected void writeFile(String name, byte[] content) throws IOException {
+				lockAndWriteFile(new File(db.getDirectory(), name), content);
+			}
+		}.writePackedRefs();
+	}
+
 	private static String readLine(final File file)
 			throws FileNotFoundException, IOException {
 		final BufferedReader br = openReader(file);
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
index 6f7961e..7679e53 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
@@ -493,7 +493,7 @@ public class Repository {
 	}
 
 	/**
-	 * Create a command to update (or create) a ref in this repository.
+	 * Create a command to update, create or delete a ref in this repository.
 	 * 
 	 * @param ref
 	 *            name of the ref the caller wants to modify.
-- 
1.6.0.rc2.35.g04c6e
Previous: Charles O'FarrellNext: Charles O'Farrell
Message 6 of 11 in “jgit: Branch command now supports deletion”
  1. 0/7 jgit: Branch command now supports deletionCharles O'Farrell, Aug 14, 2008
  2. 1/7 Refactor of WalkRemoteObjectDatabase ref writing into common classCharles O'Farrell, Aug 14, 2008
  3. 2/7 Refactor of RefUpdate force to call common updateImpl instead of duplicationCharles O'Farrell, Aug 14, 2008
  4. 3/7 Minor refactor of constants, including log and ROOT_DIRCharles O'Farrell, Aug 14, 2008
  5. 4/7 Extract lockAndWriteFile method in RefDatabase for reuseCharles O'Farrell, Aug 14, 2008
  6. 5/7 Added removePackedRef method to RefDatabase for packed branch deletionCharles O'Farrell, Aug 14, 2008
  7. 6/7 Added ref deletion to RefUpdateCharles O'Farrell, Aug 14, 2008
  8. 7/7 jgit: Added branch deletion to jgit commandCharles O'Farrell, Aug 14, 2008
  9. Shawn O. PearceAug 14, 2008
  10. 2/7 Refactor of RefUpdate force to call common updateImpl instead of duplicationCharles O'Farrell, Aug 15, 2008
  11. 6/7 Added ref deletion to RefUpdateCharles O'Farrell, Aug 15, 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.