Merge branch 'stable-3.7'
* stable-3.7: Prepare 3.7.1-SNAPSHOT builds JGit v3.7.0.201502260915-r Read user.name and email from environment first Provide more details in exceptions thrown when packfile is invalid Change-Id: I427f861c6bc94da5e3e05dbbebbf0ad15719a323 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
commit
1350f7ea1d
|
@ -162,7 +162,7 @@ public void testPush_UnpackError_TruncatedPack() throws Exception {
|
||||||
try {
|
try {
|
||||||
PacketLineIn pckin = new PacketLineIn(rawin);
|
PacketLineIn pckin = new PacketLineIn(rawin);
|
||||||
assertEquals("unpack error "
|
assertEquals("unpack error "
|
||||||
+ JGitText.get().packfileIsTruncated,
|
+ JGitText.get().packfileIsTruncatedNoParam,
|
||||||
pckin.readString());
|
pckin.readString());
|
||||||
assertEquals("ng refs/objects/A n/a (unpacker error)",
|
assertEquals("ng refs/objects/A n/a (unpacker error)",
|
||||||
pckin.readString());
|
pckin.readString());
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
Manifest-Version: 1.0
|
Manifest-Version: 1.0
|
||||||
Bundle-ManifestVersion: 2
|
Bundle-ManifestVersion: 2
|
||||||
Fragment-Host: org.eclipse.jgit;bundle-version="3.1.1"
|
Fragment-Host: org.eclipse.jgit;bundle-version="4.0.0"
|
||||||
Bundle-Name: %plugin_name
|
Bundle-Name: %plugin_name
|
||||||
Bundle-SymbolicName: org.eclipse.jgit.java7
|
Bundle-SymbolicName: org.eclipse.jgit.java7
|
||||||
Bundle-Version: 4.0.0.qualifier
|
Bundle-Version: 4.0.0.qualifier
|
||||||
|
|
|
@ -186,6 +186,9 @@ public void test007_readUserConfig() {
|
||||||
assertFalse(localConfig.get(UserConfig.KEY).isAuthorEmailImplicit());
|
assertFalse(localConfig.get(UserConfig.KEY).isAuthorEmailImplicit());
|
||||||
|
|
||||||
// the values are defined in the global configuration
|
// the values are defined in the global configuration
|
||||||
|
// first clear environment variables since they would override
|
||||||
|
// configuration files
|
||||||
|
mockSystemReader.clearProperties();
|
||||||
userGitConfig.setString("user", null, "name", "global username");
|
userGitConfig.setString("user", null, "name", "global username");
|
||||||
userGitConfig.setString("user", null, "email", "author@globalemail");
|
userGitConfig.setString("user", null, "email", "author@globalemail");
|
||||||
authorName = localConfig.get(UserConfig.KEY).getAuthorName();
|
authorName = localConfig.get(UserConfig.KEY).getAuthorName();
|
||||||
|
@ -211,6 +214,20 @@ public void test007_readUserConfig() {
|
||||||
assertEquals("author@localemail", authorEmail);
|
assertEquals("author@localemail", authorEmail);
|
||||||
assertFalse(localConfig.get(UserConfig.KEY).isCommitterNameImplicit());
|
assertFalse(localConfig.get(UserConfig.KEY).isCommitterNameImplicit());
|
||||||
assertFalse(localConfig.get(UserConfig.KEY).isCommitterEmailImplicit());
|
assertFalse(localConfig.get(UserConfig.KEY).isCommitterEmailImplicit());
|
||||||
|
|
||||||
|
// also git environment variables are defined
|
||||||
|
mockSystemReader.setProperty(Constants.GIT_AUTHOR_NAME_KEY,
|
||||||
|
"git author name");
|
||||||
|
mockSystemReader.setProperty(Constants.GIT_AUTHOR_EMAIL_KEY,
|
||||||
|
"author@email");
|
||||||
|
localConfig.setString("user", null, "name", "local username");
|
||||||
|
localConfig.setString("user", null, "email", "author@localemail");
|
||||||
|
authorName = localConfig.get(UserConfig.KEY).getAuthorName();
|
||||||
|
authorEmail = localConfig.get(UserConfig.KEY).getAuthorEmail();
|
||||||
|
assertEquals("git author name", authorName);
|
||||||
|
assertEquals("author@email", authorEmail);
|
||||||
|
assertFalse(localConfig.get(UserConfig.KEY).isAuthorNameImplicit());
|
||||||
|
assertFalse(localConfig.get(UserConfig.KEY).isAuthorEmailImplicit());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -146,7 +146,7 @@ couldNotRenameTemporaryIndexFileToIndex=Could not rename temporary index file to
|
||||||
couldNotURLEncodeToUTF8=Could not URL encode to UTF-8
|
couldNotURLEncodeToUTF8=Could not URL encode to UTF-8
|
||||||
couldNotWriteFile=Could not write file {0}
|
couldNotWriteFile=Could not write file {0}
|
||||||
countingObjects=Counting objects
|
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
|
createBranchFailedUnknownReason=Create branch failed for unknown reason
|
||||||
createBranchUnexpectedResult=Create branch returned unexpected result {0}
|
createBranchUnexpectedResult=Create branch returned unexpected result {0}
|
||||||
createNewFileFailed=Could not create new file {0}
|
createNewFileFailed=Could not create new file {0}
|
||||||
|
@ -382,14 +382,15 @@ openFilesMustBeAtLeast1=Open files must be >= 1
|
||||||
openingConnection=Opening connection
|
openingConnection=Opening connection
|
||||||
operationCanceled=Operation {0} was canceled
|
operationCanceled=Operation {0} was canceled
|
||||||
outputHasAlreadyBeenStarted=Output has already been started.
|
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
|
packCorruptedWhileWritingToFilesystem=Pack corrupted while writing to filesystem
|
||||||
packDoesNotMatchIndex=Pack {0} does not match index
|
packDoesNotMatchIndex=Pack {0} does not match index
|
||||||
packetSizeMustBeAtLeast=packet size {0} must be >= {1}
|
packetSizeMustBeAtLeast=packet size {0} must be >= {1}
|
||||||
packetSizeMustBeAtMost=packet size {0} must be <= {1}
|
packetSizeMustBeAtMost=packet size {0} must be <= {1}
|
||||||
packfileCorruptionDetected=Packfile corruption detected: {0}
|
packfileCorruptionDetected=Packfile corruption detected: {0}
|
||||||
packFileInvalid=Pack file invalid: {0}
|
packFileInvalid=Pack file invalid: {0}
|
||||||
packfileIsTruncated=Packfile is truncated.
|
packfileIsTruncated=Packfile {0} is truncated.
|
||||||
|
packfileIsTruncatedNoParam=Packfile is truncated.
|
||||||
packHasUnresolvedDeltas=pack has unresolved deltas
|
packHasUnresolvedDeltas=pack has unresolved deltas
|
||||||
packingCancelledDuringObjectsWriting=Packing cancelled during objects writing
|
packingCancelledDuringObjectsWriting=Packing cancelled during objects writing
|
||||||
packObjectCountMismatch=Pack object count mismatch: pack {0} index {1}: {2}
|
packObjectCountMismatch=Pack object count mismatch: pack {0} index {1}: {2}
|
||||||
|
|
|
@ -449,6 +449,7 @@ public static JGitText get() {
|
||||||
/***/ public String packfileCorruptionDetected;
|
/***/ public String packfileCorruptionDetected;
|
||||||
/***/ public String packFileInvalid;
|
/***/ public String packFileInvalid;
|
||||||
/***/ public String packfileIsTruncated;
|
/***/ public String packfileIsTruncated;
|
||||||
|
/***/ public String packfileIsTruncatedNoParam;
|
||||||
/***/ public String packHasUnresolvedDeltas;
|
/***/ public String packHasUnresolvedDeltas;
|
||||||
/***/ public String packingCancelledDuringObjectsWriting;
|
/***/ public String packingCancelledDuringObjectsWriting;
|
||||||
/***/ public String packObjectCountMismatch;
|
/***/ public String packObjectCountMismatch;
|
||||||
|
|
|
@ -199,7 +199,7 @@ public long getCachedSize() {
|
||||||
return key.cachedSize.get();
|
return key.cachedSize.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getPackName() {
|
String getPackName() {
|
||||||
return packDesc.getFileName(PACK);
|
return packDesc.getFileName(PACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -556,7 +556,8 @@ void copyPackAsIs(DfsPackFile pack, long length, boolean validate,
|
||||||
pin(pack, 0);
|
pin(pack, 0);
|
||||||
if (block.copy(0, buf, 0, 12) != 12) {
|
if (block.copy(0, buf, 0, 12) != 12) {
|
||||||
pack.setInvalid();
|
pack.setInvalid();
|
||||||
throw new IOException(JGitText.get().packfileIsTruncated);
|
throw new IOException(MessageFormat.format(
|
||||||
|
JGitText.get().packfileIsTruncated, pack.getPackName()));
|
||||||
}
|
}
|
||||||
md.update(buf, 0, 12);
|
md.update(buf, 0, 12);
|
||||||
}
|
}
|
||||||
|
@ -580,7 +581,8 @@ void copyPackAsIs(DfsPackFile pack, long length, boolean validate,
|
||||||
pin(pack, position);
|
pin(pack, position);
|
||||||
if (block.copy(position, buf, 0, 20) != 20) {
|
if (block.copy(position, buf, 0, 20) != 20) {
|
||||||
pack.setInvalid();
|
pack.setInvalid();
|
||||||
throw new IOException(JGitText.get().packfileIsTruncated);
|
throw new IOException(MessageFormat.format(
|
||||||
|
JGitText.get().packfileIsTruncated, pack.getPackName()));
|
||||||
}
|
}
|
||||||
if (!Arrays.equals(actHash, buf)) {
|
if (!Arrays.equals(actHash, buf)) {
|
||||||
pack.setInvalid();
|
pack.setInvalid();
|
||||||
|
|
|
@ -170,11 +170,13 @@ private synchronized PackIndex idx() throws IOException {
|
||||||
try {
|
try {
|
||||||
final PackIndex idx = PackIndex.open(extFile(INDEX));
|
final PackIndex idx = PackIndex.open(extFile(INDEX));
|
||||||
|
|
||||||
if (packChecksum == null)
|
if (packChecksum == null) {
|
||||||
packChecksum = idx.packChecksum;
|
packChecksum = idx.packChecksum;
|
||||||
else if (!Arrays.equals(packChecksum, idx.packChecksum))
|
} else if (!Arrays.equals(packChecksum, idx.packChecksum)) {
|
||||||
throw new PackMismatchException(JGitText.get().packChecksumMismatch);
|
throw new PackMismatchException(MessageFormat.format(
|
||||||
|
JGitText.get().packChecksumMismatch,
|
||||||
|
packFile.getPath()));
|
||||||
|
}
|
||||||
loadedIdx = idx;
|
loadedIdx = idx;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
invalid = true;
|
invalid = true;
|
||||||
|
|
|
@ -246,7 +246,9 @@ void copyPackAsIs(final PackFile pack, final long length, boolean validate,
|
||||||
pin(pack, 0);
|
pin(pack, 0);
|
||||||
if (window.copy(0, buf, 0, 12) != 12) {
|
if (window.copy(0, buf, 0, 12) != 12) {
|
||||||
pack.setInvalid();
|
pack.setInvalid();
|
||||||
throw new IOException(JGitText.get().packfileIsTruncated);
|
throw new IOException(MessageFormat.format(
|
||||||
|
JGitText.get().packfileIsTruncated, pack.getPackFile()
|
||||||
|
.getPath()));
|
||||||
}
|
}
|
||||||
md.update(buf, 0, 12);
|
md.update(buf, 0, 12);
|
||||||
}
|
}
|
||||||
|
@ -270,7 +272,9 @@ void copyPackAsIs(final PackFile pack, final long length, boolean validate,
|
||||||
pin(pack, position);
|
pin(pack, position);
|
||||||
if (window.copy(position, buf, 0, 20) != 20) {
|
if (window.copy(position, buf, 0, 20) != 20) {
|
||||||
pack.setInvalid();
|
pack.setInvalid();
|
||||||
throw new IOException(JGitText.get().packfileIsTruncated);
|
throw new IOException(MessageFormat.format(
|
||||||
|
JGitText.get().packfileIsTruncated, pack.getPackFile()
|
||||||
|
.getPath()));
|
||||||
}
|
}
|
||||||
if (!Arrays.equals(actHash, buf)) {
|
if (!Arrays.equals(actHash, buf)) {
|
||||||
pack.setInvalid();
|
pack.setInvalid();
|
||||||
|
|
|
@ -172,12 +172,13 @@ public boolean isCommitterEmailImplicit() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getNameInternal(Config rc, String envKey) {
|
private static String getNameInternal(Config rc, String envKey) {
|
||||||
// try to get the user name from the local and global configurations.
|
// try to get the user name for the system property GIT_XXX_NAME
|
||||||
String username = rc.getString("user", null, "name"); //$NON-NLS-1$ //$NON-NLS-2$
|
String username = system().getenv(envKey);
|
||||||
|
|
||||||
if (username == null) {
|
if (username == null) {
|
||||||
// try to get the user name for the system property GIT_XXX_NAME
|
// try to get the user name from the local and global
|
||||||
username = system().getenv(envKey);
|
// configurations.
|
||||||
|
username = rc.getString("user", null, "name"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
}
|
}
|
||||||
|
|
||||||
return stripInvalidCharacters(username);
|
return stripInvalidCharacters(username);
|
||||||
|
@ -196,12 +197,12 @@ private static String getDefaultUserName() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getEmailInternal(Config rc, String envKey) {
|
private static String getEmailInternal(Config rc, String envKey) {
|
||||||
// try to get the email from the local and global configurations.
|
// try to get the email for the system property GIT_XXX_EMAIL
|
||||||
String email = rc.getString("user", null, "email"); //$NON-NLS-1$ //$NON-NLS-2$
|
String email = system().getenv(envKey);
|
||||||
|
|
||||||
if (email == null) {
|
if (email == null) {
|
||||||
// try to get the email for the system property GIT_XXX_EMAIL
|
// try to get the email from the local and global configurations.
|
||||||
email = system().getenv(envKey);
|
email = rc.getString("user", null, "email"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
}
|
}
|
||||||
|
|
||||||
return stripInvalidCharacters(email);
|
return stripInvalidCharacters(email);
|
||||||
|
|
|
@ -1135,7 +1135,8 @@ private int fill(final Source src, final int need) throws IOException {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (next <= 0)
|
if (next <= 0)
|
||||||
throw new EOFException(JGitText.get().packfileIsTruncated);
|
throw new EOFException(
|
||||||
|
JGitText.get().packfileIsTruncatedNoParam);
|
||||||
bAvail += next;
|
bAvail += next;
|
||||||
}
|
}
|
||||||
return bOffset;
|
return bOffset;
|
||||||
|
|
Loading…
Reference in New Issue