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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Charles O'Farrell <charleso@xxxxxxxxxxxx>
---
 .../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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux