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

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

 



Signed-off-by: Charles O'Farrell <charleso@xxxxxxxxxxxx>
---
 .../src/org/spearce/jgit/lib/RefUpdate.java        |   38 ++++---------------
 1 files changed, 8 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..1b38fce 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/RefUpdate.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/RefUpdate.java
@@ -266,31 +266,8 @@ public class RefUpdate {
 	 *             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();
 	}
 
 	/**
@@ -347,6 +324,12 @@ public class RefUpdate {
 			if (oldValue == null)
 				return store(lock, Result.NEW);
 
+			if (isForceUpdate()) {
+				if (oldValue.equals(newValue))
+					return Result.NO_CHANGE;
+				return store(lock, Result.FORCED);
+			}
+
 			newObj = walk.parseAny(newValue);
 			oldObj = walk.parseAny(oldValue);
 			if (newObj == oldObj)
@@ -355,13 +338,8 @@ 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())
-				return store(lock, Result.FORCED);
 			return Result.REJECTED;
 		} finally {
 			lock.unlock();
-- 
1.6.0.rc2.35.g04c6e

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