git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Charles O'Farrell <charleso@charleso.org>
To: git@vger.kernel.org
Cc: Charles O'Farrell <charleso@charleso.org>
Subject: [PATCH 5/7] Added removePackedRef method to RefDatabase for packed branch deletion
Date: Thu, 14 Aug 2008 20:13:47 +1000	[thread overview]
Message-ID: <1218708829-8175-6-git-send-email-charleso@charleso.org> (raw)
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

  reply	other threads:[~2008-08-14 10:16 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-14 10:13 [PATCH 0/7] jgit: Branch command now supports deletion Charles O'Farrell
2008-08-14 10:13 ` [PATCH 1/7] Refactor of WalkRemoteObjectDatabase ref writing into common class Charles O'Farrell
2008-08-14 10:13   ` [PATCH 2/7] Refactor of RefUpdate force to call common updateImpl instead of duplication Charles O'Farrell
2008-08-14 10:13     ` [PATCH 3/7] Minor refactor of constants, including log and ROOT_DIR Charles O'Farrell
2008-08-14 10:13       ` [PATCH 4/7] Extract lockAndWriteFile method in RefDatabase for reuse Charles O'Farrell
2008-08-14 10:13         ` Charles O'Farrell [this message]
2008-08-14 10:13           ` [PATCH 6/7] Added ref deletion to RefUpdate Charles O'Farrell
2008-08-14 10:13             ` [PATCH 7/7] jgit: Added branch deletion to jgit command Charles O'Farrell
2008-08-14 22:23     ` [PATCH 2/7] Refactor of RefUpdate force to call common updateImpl instead of duplication Shawn O. Pearce
2008-08-15  0:25 ` [JGIT PATCH v2 " Charles O'Farrell
2008-08-15  0:25   ` [JGIT PATCH v2 6/7] Added ref deletion to RefUpdate Charles O'Farrell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1218708829-8175-6-git-send-email-charleso@charleso.org \
    --to=charleso@charleso.org \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).