git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
MZMarek Zawirski <marek.zawirski@gmail.com>
Date
Aug 28, 2008, 02:32 UTC
Message-ID
<1219890769-20119-3-git-send-email-marek.zawirski@gmail.com>
In-Reply-To
<1219890769-20119-2-git-send-email-marek.zawirski@gmail.com>

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@gmail.com>
---
 .../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
Previous: Marek ZawirskiNext: Marek Zawirski
Message 3 of 4 in “Fix local tracking refs updates during push”
  1. 0/3 Fix local tracking refs updates during pushMarek Zawirski, Aug 28, 2008
  2. 1/3 Fix push's RemoteRefUpdate to always force update local TrackingRefUpdateMarek Zawirski, Aug 28, 2008
  3. 2/3 Add another delete method in RefUpdate, reusing RevWalkMarek Zawirski, Aug 28, 2008
  4. 3/3 Fix RemoteRefUpdate to delete local tracking ref upon successful deletionMarek Zawirski, Aug 28, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.