[EGIT PATCH 02/23] RefUpdate: new possible result Result.IO_FAILURE

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

 



This result indicates that I/O error (beyond of IOException) occurred
during RefUpdate#update().

Hitherto behaviour was to just throw IOException and leave result with
value Result.NOT_ATTEMPTED. It was just less informative.

Fetch class from pgm package needed new conditions for printing. Other
classes were reviewed and should still work just fine.

Signed-off-by: Marek Zawirski <marek.zawirski@xxxxxxxxx>
---
 .../src/org/spearce/jgit/lib/RefUpdate.java        |   27 +++++++++++++++++--
 .../src/org/spearce/jgit/pgm/Fetch.java            |    5 +++
 2 files changed, 29 insertions(+), 3 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 48044fb..369cb37 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/RefUpdate.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/RefUpdate.java
@@ -105,7 +105,18 @@ public class RefUpdate {
 		 * update to take place, so ref still contains the old value. No
 		 * previous history was lost.
 		 */
-		REJECTED
+		REJECTED,
+
+		/**
+		 * The ref was probably not updated because of I/O error.
+		 * <p>
+		 * Unexpected I/O error occurred when writing new ref. Such error may
+		 * result in uncertain state, but most probably ref was not updated.
+		 * <p>
+		 * This kind of error doesn't include {@link #LOCK_FAILURE}, which is a
+		 * different case.
+		 */
+		IO_FAILURE
 	}
 
 	/** Repository the ref is stored in. */
@@ -256,7 +267,12 @@ public class RefUpdate {
 	 */
 	public Result forceUpdate() throws IOException {
 		requireCanDoUpdate();
-		return result = forceUpdateImpl();
+		try {
+			return result = forceUpdateImpl();
+		} catch (IOException x) {
+			result = Result.IO_FAILURE;
+			throw x;
+		}
 	}
 
 	private Result forceUpdateImpl() throws IOException {
@@ -310,7 +326,12 @@ public class RefUpdate {
 	 */
 	public Result update(final RevWalk walk) throws IOException {
 		requireCanDoUpdate();
-		return result = updateImpl(walk);
+		try {
+			return result = updateImpl(walk);
+		} catch (IOException x) {
+			result = Result.IO_FAILURE;
+			throw x;
+		}
 	}
 
 	private Result updateImpl(final RevWalk walk) throws IOException {
diff --git a/org.spearce.jgit/src/org/spearce/jgit/pgm/Fetch.java b/org.spearce.jgit/src/org/spearce/jgit/pgm/Fetch.java
index 6277970..3a81575 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/pgm/Fetch.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/pgm/Fetch.java
@@ -109,6 +109,9 @@ class Fetch extends TextBuiltin {
 		if (r == RefUpdate.Result.LOCK_FAILURE)
 			return "[lock fail]";
 
+		if (r == RefUpdate.Result.IO_FAILURE)
+			return "[i/o error]";
+
 		if (r == RefUpdate.Result.NEW) {
 			if (u.getRemoteName().startsWith(REFS_HEADS))
 				return "[new branch]";
@@ -143,6 +146,8 @@ class Fetch extends TextBuiltin {
 	private static char shortTypeOf(final RefUpdate.Result r) {
 		if (r == RefUpdate.Result.LOCK_FAILURE)
 			return '!';
+		if (r == RefUpdate.Result.IO_FAILURE)
+			return '!';
 		if (r == RefUpdate.Result.NEW)
 			return '*';
 		if (r == RefUpdate.Result.FORCED)
-- 
1.5.5.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