[PATCH 5/7] Added removePackedRef method to RefDatabase for packed branch deletion
From: Charles O'Farrell <hidden>
Date: 2016-06-15 22:45:09
Subsystem:
the rest · Maintainer:
Linus Torvalds
Signed-off-by: Charles O'Farrell <redacted> --- .../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