From: Charles O'Farrell Date: Thu, 14 Aug 2008 10:13:47 GMT Subject: [PATCH 5/7] Added removePackedRef method to RefDatabase for packed branch deletion 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 --- .../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