[JGIT PATCH 2/3] Add another delete method in RefUpdate, reusing RevWalk

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

 



This is similar to update() approach when caller has possiblity to
choose between providing RevWalk instance on its own or let RefUpdate
create one.

Signed-off-by: Marek Zawirski <marek.zawirski@xxxxxxxxx>
---
 .../src/org/spearce/jgit/lib/RefUpdate.java        |   22 ++++++++++++++++++-
 1 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/RefUpdate.java b/org.spearce.jgit/src/org/spearce/jgit/lib/RefUpdate.java
index c6536e3..e9c0e77 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/RefUpdate.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/RefUpdate.java
@@ -325,11 +325,30 @@ public Result update(final RevWalk walk) throws IOException {
 
 	/**
 	 * Delete the ref.
+	 * <p>
+	 * This is the same as:
+	 * 
+	 * <pre>
+	 * return delete(new RevWalk(repository));
+	 * </pre>
 	 * 
 	 * @return the result status of the delete.
 	 * @throws IOException
 	 */
 	public Result delete() throws IOException {
+		return delete(new RevWalk(db.getRepository()));
+	}
+
+	/**
+	 * Delete the ref.
+	 * 
+	 * @param walk
+	 *            a RevWalk instance this delete command can borrow to perform
+	 *            the merge test. The walk will be reset to perform the test.
+	 * @return the result status of the delete.
+	 * @throws IOException
+	 */
+	public Result delete(final RevWalk walk) throws IOException {
 		if (name.startsWith(Constants.R_HEADS)) {
 			final Ref head = db.readRef(Constants.HEAD);
 			if (head != null && name.equals(head.getName()))
@@ -337,8 +356,7 @@ public Result delete() throws IOException {
 		}
 
 		try {
-			return updateImpl(new RevWalk(db.getRepository()),
-					new DeleteStore());
+			return updateImpl(walk, new DeleteStore());
 		} catch (IOException x) {
 			result = Result.IO_FAILURE;
 			throw x;
-- 
1.5.6.3

--
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