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

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

From
MZMarek Zawirski <marek.zawirski@gmail.com>
Date
Jun 27, 2008, 22:06 UTC
Message-ID
<1214604407-30572-3-git-send-email-marek.zawirski@gmail.com>
In-Reply-To
<1214604407-30572-2-git-send-email-marek.zawirski@gmail.com>

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@gmail.com>
---
 .../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
Previous: Marek ZawirskiNext: Marek Zawirski
Message 3 of 26 in “Push implementation”
  1. 00/23 Push implementationMarek Zawirski, Jun 27, 2008
  2. 01/23 Fix: let FetchProcess use fetch() instead of doFetch()Marek Zawirski, Jun 27, 2008
  3. 02/23 RefUpdate: new possible result Result.IO_FAILUREMarek Zawirski, Jun 27, 2008
  4. 03/23 Refactor TrackingRefUpdate to not hold RefSpecMarek Zawirski, Jun 27, 2008
  5. 04/23 New constructor without RefSpec for TrackingRefUpdateMarek Zawirski, Jun 27, 2008
  6. 05/23 Add RemoteRefUpdate classMarek Zawirski, Jun 27, 2008
  7. 06/23 Refactor: extract superclass OperationResult from FetchResultMarek Zawirski, Jun 27, 2008
  8. 07/23 Add PushResult classMarek Zawirski, Jun 27, 2008
  9. 08/23 Support for fetchThin and pushThin options in TransportMarek Zawirski, Jun 27, 2008
  10. 09/23 Big refactor: *Connection hierarchyMarek Zawirski, Jun 27, 2008
  11. 10/23 Add ignoreMissingUninteresting option to PackWriterMarek Zawirski, Jun 27, 2008
  12. 11/23 Add BasePackPushConnection implementing git-send-pack protocolMarek Zawirski, Jun 27, 2008
  13. 12/23 Fix: let RevWalk reset correctly before isMergedInto()Marek Zawirski, Jun 27, 2008
  14. 13/23 Add PushProcess class implementing git-send-pack logicMarek Zawirski, Jun 27, 2008
  15. 14/23 Clarify Repository#resolve() documentationMarek Zawirski, Jun 27, 2008
  16. 15/23 Add String versions of methods in RefSpecMarek Zawirski, Jun 27, 2008
  17. 16/23 Transport* - general support for push() and implementationsMarek Zawirski, Jun 27, 2008
  18. 17/23 Test cases for PushProcessMarek Zawirski, Jun 27, 2008
  19. 18/23 Test cases for RefSpec to RemoteRefUpdate conversionsMarek Zawirski, Jun 27, 2008
  20. 19/23 Repository search for command line toolsMarek Zawirski, Jun 27, 2008
  21. 20/23 Push command line utilityMarek Zawirski, Jun 27, 2008
  22. 21/23 Don't accept RefSpec with null source for fetchMarek Zawirski, Jun 27, 2008
  23. 22/23 Add new handy constructors to TransportException, PackProtocolExceptionMarek Zawirski, Jun 27, 2008
  24. 23/23 Use new TransportException constructorsMarek Zawirski, Jun 27, 2008
  25. Robin RosenbergJun 28, 2008
  26. Robin RosenbergJun 27, 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.