Merge "Read user.name and email from environment first" into stable-3.7
diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/ProtocolErrorTest.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/ProtocolErrorTest.java
index 2823b34..68c5a3a 100644
--- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/ProtocolErrorTest.java
+++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/ProtocolErrorTest.java
@@ -162,7 +162,7 @@
 			try {
 				PacketLineIn pckin = new PacketLineIn(rawin);
 				assertEquals("unpack error "
-						+ JGitText.get().packfileIsTruncated,
+						+ JGitText.get().packfileIsTruncatedNoParam,
 						pckin.readString());
 				assertEquals("ng refs/objects/A n/a (unpacker error)",
 						pckin.readString());
diff --git a/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties b/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties
index efe6105..66b14bb 100644
--- a/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties
+++ b/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties
@@ -146,7 +146,7 @@
 couldNotURLEncodeToUTF8=Could not URL encode to UTF-8
 couldNotWriteFile=Could not write file {0}
 countingObjects=Counting objects
-corruptPack=Pack file {0} is corrupt
+corruptPack=Pack file {0} is corrupt, removing it from pack list
 createBranchFailedUnknownReason=Create branch failed for unknown reason
 createBranchUnexpectedResult=Create branch returned unexpected result {0}
 createNewFileFailed=Could not create new file {0}
@@ -381,14 +381,15 @@
 openingConnection=Opening connection
 operationCanceled=Operation {0} was canceled
 outputHasAlreadyBeenStarted=Output has already been started.
-packChecksumMismatch=Pack checksum mismatch
+packChecksumMismatch=Pack checksum mismatch detected for pack file {0}
 packCorruptedWhileWritingToFilesystem=Pack corrupted while writing to filesystem
 packDoesNotMatchIndex=Pack {0} does not match index
 packetSizeMustBeAtLeast=packet size {0} must be >= {1}
 packetSizeMustBeAtMost=packet size {0} must be <= {1}
 packfileCorruptionDetected=Packfile corruption detected: {0}
 packFileInvalid=Pack file invalid: {0}
-packfileIsTruncated=Packfile is truncated.
+packfileIsTruncated=Packfile {0} is truncated.
+packfileIsTruncatedNoParam=Packfile is truncated.
 packHasUnresolvedDeltas=pack has unresolved deltas
 packingCancelledDuringObjectsWriting=Packing cancelled during objects writing
 packObjectCountMismatch=Pack object count mismatch: pack {0} index {1}: {2}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java
index 8c81c95..0300af1 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java
@@ -448,6 +448,7 @@
 	/***/ public String packfileCorruptionDetected;
 	/***/ public String packFileInvalid;
 	/***/ public String packfileIsTruncated;
+	/***/ public String packfileIsTruncatedNoParam;
 	/***/ public String packHasUnresolvedDeltas;
 	/***/ public String packingCancelledDuringObjectsWriting;
 	/***/ public String packObjectCountMismatch;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java
index 7c4776e..d5e1a58 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java
@@ -199,7 +199,7 @@
 		return key.cachedSize.get();
 	}
 
-	private String getPackName() {
+	String getPackName() {
 		return packDesc.getFileName(PACK);
 	}
 
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsReader.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsReader.java
index 37dbc7e..4cf7cbe 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsReader.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsReader.java
@@ -556,7 +556,8 @@
 			pin(pack, 0);
 			if (block.copy(0, buf, 0, 12) != 12) {
 				pack.setInvalid();
-				throw new IOException(JGitText.get().packfileIsTruncated);
+				throw new IOException(MessageFormat.format(
+						JGitText.get().packfileIsTruncated, pack.getPackName()));
 			}
 			md.update(buf, 0, 12);
 		}
@@ -580,7 +581,8 @@
 			pin(pack, position);
 			if (block.copy(position, buf, 0, 20) != 20) {
 				pack.setInvalid();
-				throw new IOException(JGitText.get().packfileIsTruncated);
+				throw new IOException(MessageFormat.format(
+						JGitText.get().packfileIsTruncated, pack.getPackName()));
 			}
 			if (!Arrays.equals(actHash, buf)) {
 				pack.setInvalid();
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java
index 306a0d3..eb22938 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java
@@ -169,11 +169,13 @@
 			try {
 				final PackIndex idx = PackIndex.open(extFile(INDEX));
 
-				if (packChecksum == null)
+				if (packChecksum == null) {
 					packChecksum = idx.packChecksum;
-				else if (!Arrays.equals(packChecksum, idx.packChecksum))
-					throw new PackMismatchException(JGitText.get().packChecksumMismatch);
-
+				} else if (!Arrays.equals(packChecksum, idx.packChecksum)) {
+					throw new PackMismatchException(MessageFormat.format(
+							JGitText.get().packChecksumMismatch,
+							packFile.getPath()));
+				}
 				loadedIdx = idx;
 			} catch (IOException e) {
 				invalid = true;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/WindowCursor.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/WindowCursor.java
index a0a4c95..85c3c74 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/WindowCursor.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/WindowCursor.java
@@ -246,7 +246,9 @@
 			pin(pack, 0);
 			if (window.copy(0, buf, 0, 12) != 12) {
 				pack.setInvalid();
-				throw new IOException(JGitText.get().packfileIsTruncated);
+				throw new IOException(MessageFormat.format(
+						JGitText.get().packfileIsTruncated, pack.getPackFile()
+								.getPath()));
 			}
 			md.update(buf, 0, 12);
 		}
@@ -270,7 +272,9 @@
 			pin(pack, position);
 			if (window.copy(position, buf, 0, 20) != 20) {
 				pack.setInvalid();
-				throw new IOException(JGitText.get().packfileIsTruncated);
+				throw new IOException(MessageFormat.format(
+						JGitText.get().packfileIsTruncated, pack.getPackFile()
+								.getPath()));
 			}
 			if (!Arrays.equals(actHash, buf)) {
 				pack.setInvalid();
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PackParser.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PackParser.java
index 633554a..5b54891 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PackParser.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PackParser.java
@@ -1135,7 +1135,8 @@
 				break;
 			}
 			if (next <= 0)
-				throw new EOFException(JGitText.get().packfileIsTruncated);
+				throw new EOFException(
+						JGitText.get().packfileIsTruncatedNoParam);
 			bAvail += next;
 		}
 		return bOffset;