[JGIT PATCH v2 2/7] Refactor of RefUpdate force to call common updateImpl instead of duplication

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <git@...>
Cc: Charles O'Farrell <charleso@...>
Date: Thursday, August 14, 2008 - 8:25 pm

Signed-off-by: Charles O'Farrell <charleso@charleso.org>
---
 .../src/org/spearce/jgit/lib/RefUpdate.java        |   34 ++-----------------
 1 files changed, 4 insertions(+), 30 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 369cb37..4587fc1 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/RefUpdate.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/RefUpdate.java
@@ -258,39 +258,16 @@ public class RefUpdate {
 	/**
 	 * Force the ref to take the new value.
 	 * <p>
-	 * No merge tests are performed, so the value of {@link #isForceUpdate()}
-	 * will not be honored.
+	 * This is just a convenient helper for setting the force flag, and as such
+	 * the merge test is performed.
 	 * 
 	 * @return the result status of the update.
 	 * @throws IOException
 	 *             an unexpected IO error occurred while writing changes.
 	 */
 	public Result forceUpdate() throws IOException {
-		requireCanDoUpdate();
-		try {
-			return result = forceUpdateImpl();
-		} catch (IOException x) {
-			result = Result.IO_FAILURE;
-			throw x;
-		}
-	}
-
-	private Result forceUpdateImpl() throws IOException {
-		final LockFile lock;
-
-		lock = new LockFile(looseFile);
-		if (!lock.lock())
-			return Result.LOCK_FAILURE;
-		try {
-			oldValue = db.idOf(name);
-			if (oldValue == null)
-				return store(lock, Result.NEW);
-			if (oldValue.equals(newValue))
-				return Result.NO_CHANGE;
-			return store(lock, Result.FORCED);
-		} finally {
-			lock.unlock();
-		}
+		force = true;
+		return update();
 	}
 
 	/**
@@ -355,9 +332,6 @@ public class RefUpdate {
 			if (newObj instanceof RevCommit && oldObj instanceof RevCommit) {
 				if (walk.isMergedInto((RevCommit) oldObj, (RevCommit) newObj))
 					return store(lock, Result.FAST_FORWARD);
-				if (isForceUpdate())
-					return store(lock, Result.FORCED);
-				return Result.REJECTED;
 			}
 
 			if (isForceUpdate())
-- 
1.6.0.rc2.35.g04c6e

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 0/7] jgit: Branch command now supports deletion , Charles O'Farrell, (Thu Aug 14, 6:13 am)
[JGIT PATCH v2 2/7] Refactor of RefUpdate force to call comm..., Charles O'Farrell, (Thu Aug 14, 8:25 pm)
[JGIT PATCH v2 6/7] Added ref deletion to RefUpdate, Charles O'Farrell, (Thu Aug 14, 8:25 pm)
[PATCH 1/7] Refactor of WalkRemoteObjectDatabase ref writing..., Charles O'Farrell, (Thu Aug 14, 6:13 am)
[PATCH 2/7] Refactor of RefUpdate force to call common updat..., Charles O'Farrell, (Thu Aug 14, 6:13 am)
[PATCH 3/7] Minor refactor of constants, including log and R..., Charles O'Farrell, (Thu Aug 14, 6:13 am)
[PATCH 4/7] Extract lockAndWriteFile method in RefDatabase f..., Charles O'Farrell, (Thu Aug 14, 6:13 am)