Enable and fix "Statement unnecessarily nested within else clause" warnings
Since [1] the gerrit project includes jgit as a submodule, and has this warning enabled, resulting in 100s of warnings in the console. Also enable the warning here, and fix them. At the same time, add missing braces around adjacent and nearby one-line blocks. [1] https://gerrit-review.googlesource.com/c/gerrit/+/227897 Change-Id: I81df3fc7ed6eedf6874ce1a3bedfa727a1897e4c Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
This commit is contained in:
parent
762f6212b4
commit
98cdca9b5a
|
@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
|
|||
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
|
||||
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
|
||||
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=error
|
||||
|
|
|
@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
|
|||
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
|
||||
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
|
||||
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
|
||||
|
|
|
@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
|
|||
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
|
||||
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
|
||||
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
|
||||
|
|
|
@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
|
|||
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
|
||||
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
|
||||
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
|
||||
|
|
|
@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
|
|||
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
|
||||
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
|
||||
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
|
||||
|
|
|
@ -86,10 +86,10 @@ public void with(HttpServlet servlet) {
|
|||
* @return the configured servlet, or singleton returning 404 if none.
|
||||
*/
|
||||
protected HttpServlet getServlet() {
|
||||
if (httpServlet != null)
|
||||
if (httpServlet != null) {
|
||||
return httpServlet;
|
||||
else
|
||||
return new ErrorServlet(HttpServletResponse.SC_NOT_FOUND);
|
||||
}
|
||||
return new ErrorServlet(HttpServletResponse.SC_NOT_FOUND);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -83,8 +83,7 @@ public UploadPack create(HttpServletRequest req, Repository db)
|
|||
up.setExtraParameters(Arrays.asList(params));
|
||||
}
|
||||
return up;
|
||||
} else {
|
||||
throw new ServiceNotEnabledException();
|
||||
}
|
||||
throw new ServiceNotEnabledException();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
|
|||
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
|
||||
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
|
||||
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=error
|
||||
|
|
|
@ -331,9 +331,8 @@ private String local(String url, boolean toLocal) {
|
|||
String fragment = u.getRawFragment();
|
||||
if (fragment != null) {
|
||||
return u.getRawPath() + '#' + fragment;
|
||||
} else {
|
||||
return u.getRawPath();
|
||||
}
|
||||
return u.getRawPath();
|
||||
} catch (URISyntaxException e) {
|
||||
return url;
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
|
|||
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
|
||||
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
|
||||
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=error
|
||||
|
|
|
@ -308,10 +308,10 @@ protected void doStart() throws Exception {
|
|||
|
||||
@Override
|
||||
protected String[] loadRoleInfo(UserPrincipal user) {
|
||||
if (users.get(user.getName()) == null)
|
||||
if (users.get(user.getName()) == null) {
|
||||
return null;
|
||||
else
|
||||
return new String[] { role };
|
||||
}
|
||||
return new String[] { role };
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
|
|||
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
|
||||
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
|
||||
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=error
|
||||
|
|
|
@ -103,7 +103,7 @@ org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
|
|||
org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentType=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentTypeStrict=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.unlikelyEqualsArgumentType=info
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
|
||||
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unstableAutoModuleName=warning
|
||||
|
|
|
@ -782,9 +782,8 @@ public RevCommit cherryPick(AnyObjectId id) throws Exception {
|
|||
}
|
||||
update(Constants.HEAD, result);
|
||||
return pool.parseCommit(result);
|
||||
} else {
|
||||
throw new IOException("Merge conflict");
|
||||
}
|
||||
throw new IOException("Merge conflict");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
|
|||
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
|
||||
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
|
||||
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=error
|
||||
|
|
|
@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
|
|||
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
|
||||
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
|
||||
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
|
||||
|
|
|
@ -110,9 +110,8 @@ public long getSize(AnyLongObjectId id) throws IOException {
|
|||
Path p = getPath(id);
|
||||
if (Files.exists(p)) {
|
||||
return Files.size(p);
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -352,9 +352,8 @@ private static String canonicalizeResourcePath(URL endpoint) {
|
|||
String encodedPath = urlEncode(path, true);
|
||||
if (encodedPath.startsWith("/")) { //$NON-NLS-1$
|
||||
return encodedPath;
|
||||
} else {
|
||||
return "/" + encodedPath; //$NON-NLS-1$
|
||||
}
|
||||
return "/" + encodedPath; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
private static byte[] hash(String s) {
|
||||
|
|
|
@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
|
|||
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
|
||||
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
|
||||
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=error
|
||||
|
|
|
@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
|
|||
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
|
||||
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
|
||||
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
|
||||
|
|
|
@ -83,9 +83,8 @@ public ObjectLoader applySmudgeFilter(Repository db, ObjectLoader loader,
|
|||
Attribute attribute) throws IOException {
|
||||
if (isEnabled(db) && (attribute == null || isEnabled(db, attribute))) {
|
||||
return LfsBlobFilter.smudgeLfsBlob(db, loader);
|
||||
} else {
|
||||
return loader;
|
||||
}
|
||||
return loader;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -93,9 +92,8 @@ public LfsInputStream applyCleanFilter(Repository db, InputStream input,
|
|||
long length, Attribute attribute) throws IOException {
|
||||
if (isEnabled(db, attribute)) {
|
||||
return new LfsInputStream(LfsBlobFilter.cleanLfsBlob(db, input));
|
||||
} else {
|
||||
return new LfsInputStream(input, length);
|
||||
}
|
||||
return new LfsInputStream(input, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -138,32 +138,30 @@ public int run() throws IOException {
|
|||
aOut.write(buf, 0, length);
|
||||
size += length;
|
||||
return length;
|
||||
} else {
|
||||
aOut.close();
|
||||
AnyLongObjectId loid = aOut.getId();
|
||||
aOut = null;
|
||||
Path mediaFile = lfsUtil.getMediaFile(loid);
|
||||
if (Files.isRegularFile(mediaFile)) {
|
||||
long fsSize = Files.size(mediaFile);
|
||||
if (fsSize != size) {
|
||||
throw new CorruptMediaFile(mediaFile, size, fsSize);
|
||||
} else {
|
||||
FileUtils.delete(tmpFile.toFile());
|
||||
}
|
||||
} else {
|
||||
Path parent = mediaFile.getParent();
|
||||
if (parent != null) {
|
||||
FileUtils.mkdirs(parent.toFile(), true);
|
||||
}
|
||||
FileUtils.rename(tmpFile.toFile(), mediaFile.toFile(),
|
||||
StandardCopyOption.ATOMIC_MOVE);
|
||||
}
|
||||
LfsPointer lfsPointer = new LfsPointer(loid, size);
|
||||
lfsPointer.encode(out);
|
||||
in.close();
|
||||
out.close();
|
||||
return -1;
|
||||
}
|
||||
aOut.close();
|
||||
AnyLongObjectId loid = aOut.getId();
|
||||
aOut = null;
|
||||
Path mediaFile = lfsUtil.getMediaFile(loid);
|
||||
if (Files.isRegularFile(mediaFile)) {
|
||||
long fsSize = Files.size(mediaFile);
|
||||
if (fsSize != size) {
|
||||
throw new CorruptMediaFile(mediaFile, size, fsSize);
|
||||
}
|
||||
FileUtils.delete(tmpFile.toFile());
|
||||
} else {
|
||||
Path parent = mediaFile.getParent();
|
||||
if (parent != null) {
|
||||
FileUtils.mkdirs(parent.toFile(), true);
|
||||
}
|
||||
FileUtils.rename(tmpFile.toFile(), mediaFile.toFile(),
|
||||
StandardCopyOption.ATOMIC_MOVE);
|
||||
}
|
||||
LfsPointer lfsPointer = new LfsPointer(loid, size);
|
||||
lfsPointer.encode(out);
|
||||
in.close();
|
||||
out.close();
|
||||
return -1;
|
||||
} catch (IOException e) {
|
||||
if (aOut != null) {
|
||||
aOut.abort();
|
||||
|
|
|
@ -179,9 +179,8 @@ private static String discoverLfsUrl(Repository db, String purpose,
|
|||
remoteUrl, u);
|
||||
additionalHeaders.putAll(action.header);
|
||||
return action.href;
|
||||
} else {
|
||||
return remoteUrl + Protocol.INFO_LFS_ENDPOINT;
|
||||
}
|
||||
return remoteUrl + Protocol.INFO_LFS_ENDPOINT;
|
||||
}
|
||||
|
||||
private static Protocol.ExpiringAction getSshAuthentication(
|
||||
|
@ -262,9 +261,8 @@ private static String extractProjectName(URIish u) {
|
|||
|
||||
if (path.endsWith(org.eclipse.jgit.lib.Constants.DOT_GIT)) {
|
||||
return path.substring(0, path.length() - 4);
|
||||
} else {
|
||||
return path;
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -303,10 +303,10 @@ public final boolean equals(AnyLongObjectId other) {
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final boolean equals(Object o) {
|
||||
if (o instanceof AnyLongObjectId)
|
||||
if (o instanceof AnyLongObjectId) {
|
||||
return equals((AnyLongObjectId) o);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
|
|||
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
|
||||
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
|
||||
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=error
|
||||
|
|
|
@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
|
|||
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
|
||||
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
|
||||
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
|
||||
|
|
|
@ -136,18 +136,15 @@ private boolean get(CredentialItem.StringType item) {
|
|||
if (v != null) {
|
||||
item.setValue(new String(v));
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
String v = cons.readLine("%s: ", item.getPromptText()); //$NON-NLS-1$
|
||||
if (v != null) {
|
||||
item.setValue(v);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
String v = cons.readLine("%s: ", item.getPromptText()); //$NON-NLS-1$
|
||||
if (v != null) {
|
||||
item.setValue(v);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean get(CredentialItem.CharArrayType item) {
|
||||
|
@ -156,18 +153,15 @@ private boolean get(CredentialItem.CharArrayType item) {
|
|||
if (v != null) {
|
||||
item.setValueNoCopy(v);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
String v = cons.readLine("%s: ", item.getPromptText()); //$NON-NLS-1$
|
||||
if (v != null) {
|
||||
item.setValueNoCopy(v.toCharArray());
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
String v = cons.readLine("%s: ", item.getPromptText()); //$NON-NLS-1$
|
||||
if (v != null) {
|
||||
item.setValueNoCopy(v.toCharArray());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean get(CredentialItem.InformationalMessage item) {
|
||||
|
@ -182,8 +176,7 @@ private boolean get(CredentialItem.YesNoType item) {
|
|||
if (r != null) {
|
||||
item.setValue(CLIText.get().answerYes.equalsIgnoreCase(r));
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -306,8 +306,8 @@ protected int printList(Collection<String> list) throws IOException {
|
|||
}
|
||||
outw.flush();
|
||||
return list.size();
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -189,9 +189,8 @@ private void recreateCommitGraph() throws IOException {
|
|||
// rewritten.
|
||||
queue.add(t);
|
||||
continue REWRITE;
|
||||
} else {
|
||||
newParents[k] = p.newId;
|
||||
}
|
||||
newParents[k] = p.newId;
|
||||
} else {
|
||||
// We have the old parent object. Use it.
|
||||
//
|
||||
|
|
|
@ -138,9 +138,8 @@ protected int hashRegion(byte[] raw, int ptr, int end) {
|
|||
Arrays.fill(buf16, (byte) 0);
|
||||
System.arraycopy(raw, ptr, buf16, 0, end - ptr);
|
||||
return rabin(buf16, 0);
|
||||
} else {
|
||||
return rabin(raw, ptr);
|
||||
}
|
||||
return rabin(raw, ptr);
|
||||
}
|
||||
|
||||
private int rabin(byte[] raw, int ptr) {
|
||||
|
|
|
@ -299,10 +299,10 @@ public boolean required() {
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected OptionHandler createOptionHandler(OptionDef o, Setter setter) {
|
||||
if (o instanceof NamedOptionDef)
|
||||
if (o instanceof NamedOptionDef) {
|
||||
return super.createOptionHandler(o, setter);
|
||||
else
|
||||
return super.createOptionHandler(new MyOptionDef(o), setter);
|
||||
}
|
||||
return super.createOptionHandler(new MyOptionDef(o), setter);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
|
|||
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
|
||||
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
|
||||
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=error
|
||||
|
|
|
@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
|
|||
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
|
||||
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
|
||||
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
|
||||
|
|
|
@ -179,9 +179,8 @@ protected IoWriteFuture sendIdentification(String ident)
|
|||
} catch (Exception other) {
|
||||
throw new IOException(other.getLocalizedMessage(), other);
|
||||
}
|
||||
} else {
|
||||
return super.sendIdentification(ident);
|
||||
}
|
||||
return super.sendIdentification(ident);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -205,9 +204,8 @@ protected byte[] sendKexInit()
|
|||
} catch (Exception other) {
|
||||
throw new IOException(other.getLocalizedMessage(), other);
|
||||
}
|
||||
} else {
|
||||
return super.sendKexInit();
|
||||
}
|
||||
return super.sendKexInit();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -453,9 +453,8 @@ private static boolean askUser(CredentialsProvider provider, URIish uri,
|
|||
prompt);
|
||||
items.add(answer);
|
||||
return provider.get(uri, items) && answer.getValue();
|
||||
} else {
|
||||
return provider.get(uri, items);
|
||||
}
|
||||
return provider.get(uri, items);
|
||||
}
|
||||
|
||||
private Check checkMode(SocketAddress remoteAddress, boolean changed) {
|
||||
|
|
|
@ -207,11 +207,10 @@ private static int parseChallenge(AuthenticationChallenge challenge,
|
|||
next++;
|
||||
}
|
||||
return next;
|
||||
} else {
|
||||
// This token must be the name of the next authentication
|
||||
// scheme.
|
||||
return start;
|
||||
}
|
||||
// This token must be the name of the next authentication
|
||||
// scheme.
|
||||
return start;
|
||||
}
|
||||
int nextStart = skipWhiteSpace(header, next + 1);
|
||||
if (nextStart >= length) {
|
||||
|
@ -244,11 +243,10 @@ private static int parseChallenge(AuthenticationChallenge challenge,
|
|||
// token, and the equals sign is part of the token
|
||||
challenge.setToken(header.substring(start, end + 1));
|
||||
return nextStart + 1;
|
||||
} else {
|
||||
// Key without value...
|
||||
challenge.addArgument(header.substring(start, end), null);
|
||||
start = nextStart + 1;
|
||||
}
|
||||
// Key without value...
|
||||
challenge.addArgument(header.substring(start, end), null);
|
||||
start = nextStart + 1;
|
||||
} else {
|
||||
if (header.charAt(nextStart) == '"') {
|
||||
int nextEnd[] = { nextStart + 1 };
|
||||
|
|
|
@ -281,11 +281,10 @@ private byte[] getAuthenticationProposals() {
|
|||
}
|
||||
if (i == proposals.length) {
|
||||
return proposals;
|
||||
} else {
|
||||
byte[] result = new byte[i];
|
||||
System.arraycopy(proposals, 0, result, 0, i);
|
||||
return result;
|
||||
}
|
||||
byte[] result = new byte[i];
|
||||
System.arraycopy(proposals, 0, result, 0, i);
|
||||
return result;
|
||||
}
|
||||
|
||||
private void sendConnectInfo(IoSession session) throws Exception {
|
||||
|
|
|
@ -354,9 +354,8 @@ private String absolute(String path) {
|
|||
if (path.charAt(0) != '/') {
|
||||
if (cwd.charAt(cwd.length() - 1) == '/') {
|
||||
return cwd + path;
|
||||
} else {
|
||||
return cwd + '/' + path;
|
||||
}
|
||||
return cwd + '/' + path;
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
|
|||
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
|
||||
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
|
||||
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=error
|
||||
|
|
|
@ -295,9 +295,8 @@ private Path copyFile(Path src, Path dst) throws IOException {
|
|||
Files.copy(src, dstOut);
|
||||
return dst;
|
||||
}
|
||||
} else {
|
||||
return Files.copy(src, dst, StandardCopyOption.REPLACE_EXISTING);
|
||||
}
|
||||
return Files.copy(src, dst, StandardCopyOption.REPLACE_EXISTING);
|
||||
}
|
||||
|
||||
private Path copyPack(Path base, String srcSuffix, String dstSuffix)
|
||||
|
|
|
@ -88,9 +88,8 @@ private ObjectId writeAndReadBackFromTempFile(ObjectId objectId)
|
|||
try (InputStream in = new FileInputStream(file)) {
|
||||
if (objectId == null) {
|
||||
return ObjectIdSerializer.read(in);
|
||||
} else {
|
||||
return ObjectIdSerializer.readWithoutMarker(in);
|
||||
}
|
||||
return ObjectIdSerializer.readWithoutMarker(in);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,9 +67,8 @@ public Map<String, Ref> getRefs(String prefix) throws IOException {
|
|||
existing.put("refs/heads/a/b", null /* not used */);
|
||||
existing.put("refs/heads/q", null /* not used */);
|
||||
return existing;
|
||||
} else {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -133,16 +133,15 @@ public void connect() throws IOException {
|
|||
|
||||
@Override
|
||||
public String getHeaderField(String name) {
|
||||
if (!headerFields.containsKey(name))
|
||||
if (!headerFields.containsKey(name)) {
|
||||
return null;
|
||||
else {
|
||||
int n = headerFields.get(name).size();
|
||||
|
||||
if (n > 0)
|
||||
return headerFields.get(name).get(n - 1);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
int n = headerFields.get(name).size();
|
||||
|
||||
if (n > 0) {
|
||||
return headerFields.get(name).get(n - 1);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -239,9 +239,8 @@ && haveEnvVar(ENV_BUCKET_NAME)) {
|
|||
loadEnvVar(ENV_SECRET_KEY, SECRET_KEY, props);
|
||||
loadEnvVar(ENV_BUCKET_NAME, TEST_BUCKET, props);
|
||||
return props;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static Properties fromEnvFile() throws Exception {
|
||||
|
@ -250,12 +249,10 @@ static Properties fromEnvFile() throws Exception {
|
|||
props.load(new FileInputStream(ENV_CONFIG_FILE));
|
||||
if (checkTestProps(props)) {
|
||||
return props;
|
||||
} else {
|
||||
throw new Error("Environment config file is incomplete.");
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
throw new Error("Environment config file is incomplete.");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static Properties fromSysProps() {
|
||||
|
@ -266,9 +263,8 @@ && haveSysProp(SYS_BUCKET_NAME)) {
|
|||
loadSysProp(SYS_SECRET_KEY, SECRET_KEY, props);
|
||||
loadSysProp(SYS_BUCKET_NAME, TEST_BUCKET, props);
|
||||
return props;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static Properties fromSysFile() throws Exception {
|
||||
|
@ -277,12 +273,10 @@ static Properties fromSysFile() throws Exception {
|
|||
props.load(new FileInputStream(SYS_CONFIG_FILE));
|
||||
if (checkTestProps(props)) {
|
||||
return props;
|
||||
} else {
|
||||
throw new Error("System props config file is incomplete.");
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
throw new Error("System props config file is incomplete.");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static Properties fromConfigFile(String path) throws Exception {
|
||||
|
@ -292,12 +286,10 @@ static Properties fromConfigFile(String path) throws Exception {
|
|||
props.load(new FileInputStream(file));
|
||||
if (checkTestProps(props)) {
|
||||
return props;
|
||||
} else {
|
||||
throw new Error("Props config file is incomplete: " + path);
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
throw new Error("Props config file is incomplete: " + path);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
|
|||
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
|
||||
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
|
||||
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
|
||||
|
|
|
@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
|
|||
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
|
||||
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
|
||||
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
|
||||
|
|
|
@ -275,13 +275,12 @@ private static byte[] toByteArray(InputStream source, int upperSizeLimit)
|
|||
byte[] buffer = new byte[upperSizeLimit];
|
||||
try {
|
||||
int read = IO.readFully(source, buffer, 0);
|
||||
if (read == upperSizeLimit)
|
||||
if (read == upperSizeLimit) {
|
||||
return buffer;
|
||||
else {
|
||||
byte[] copy = new byte[read];
|
||||
System.arraycopy(buffer, 0, copy, 0, read);
|
||||
return copy;
|
||||
}
|
||||
byte[] copy = new byte[read];
|
||||
System.arraycopy(buffer, 0, copy, 0, read);
|
||||
return copy;
|
||||
} finally {
|
||||
source.close();
|
||||
}
|
||||
|
|
|
@ -136,28 +136,32 @@ public List<DiffEntry> call() throws GitAPIException {
|
|||
}
|
||||
newTree = new DirCacheIterator(repo.readDirCache());
|
||||
} else {
|
||||
if (oldTree == null)
|
||||
if (oldTree == null) {
|
||||
oldTree = new DirCacheIterator(repo.readDirCache());
|
||||
if (newTree == null)
|
||||
}
|
||||
if (newTree == null) {
|
||||
newTree = new FileTreeIterator(repo);
|
||||
}
|
||||
}
|
||||
|
||||
diffFmt.setPathFilter(pathFilter);
|
||||
|
||||
List<DiffEntry> result = diffFmt.scan(oldTree, newTree);
|
||||
if (showNameAndStatusOnly)
|
||||
return result;
|
||||
else {
|
||||
if (contextLines >= 0)
|
||||
diffFmt.setContext(contextLines);
|
||||
if (destinationPrefix != null)
|
||||
diffFmt.setNewPrefix(destinationPrefix);
|
||||
if (sourcePrefix != null)
|
||||
diffFmt.setOldPrefix(sourcePrefix);
|
||||
diffFmt.format(result);
|
||||
diffFmt.flush();
|
||||
if (showNameAndStatusOnly) {
|
||||
return result;
|
||||
}
|
||||
if (contextLines >= 0) {
|
||||
diffFmt.setContext(contextLines);
|
||||
}
|
||||
if (destinationPrefix != null) {
|
||||
diffFmt.setNewPrefix(destinationPrefix);
|
||||
}
|
||||
if (sourcePrefix != null) {
|
||||
diffFmt.setOldPrefix(sourcePrefix);
|
||||
}
|
||||
diffFmt.format(result);
|
||||
diffFmt.flush();
|
||||
return result;
|
||||
} catch (IOException e) {
|
||||
throw new JGitInternalException(e.getMessage(), e);
|
||||
}
|
||||
|
|
|
@ -360,17 +360,17 @@ public FetchCommand setCheckFetchedObjects(boolean checkFetchedObjects) {
|
|||
* @return whether to remove refs which no longer exist in the source
|
||||
*/
|
||||
public boolean isRemoveDeletedRefs() {
|
||||
if (removeDeletedRefs != null)
|
||||
if (removeDeletedRefs != null) {
|
||||
return removeDeletedRefs.booleanValue();
|
||||
else { // fall back to configuration
|
||||
boolean result = false;
|
||||
StoredConfig config = repo.getConfig();
|
||||
result = config.getBoolean(ConfigConstants.CONFIG_FETCH_SECTION,
|
||||
null, ConfigConstants.CONFIG_KEY_PRUNE, result);
|
||||
result = config.getBoolean(ConfigConstants.CONFIG_REMOTE_SECTION,
|
||||
remote, ConfigConstants.CONFIG_KEY_PRUNE, result);
|
||||
return result;
|
||||
}
|
||||
// fall back to configuration
|
||||
boolean result = false;
|
||||
StoredConfig config = repo.getConfig();
|
||||
result = config.getBoolean(ConfigConstants.CONFIG_FETCH_SECTION, null,
|
||||
ConfigConstants.CONFIG_KEY_PRUNE, result);
|
||||
result = config.getBoolean(ConfigConstants.CONFIG_REMOTE_SECTION,
|
||||
remote, ConfigConstants.CONFIG_KEY_PRUNE, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -243,9 +243,8 @@ public Properties getStatistics() throws GitAPIException {
|
|||
if (repo instanceof FileRepository) {
|
||||
GC gc = new GC((FileRepository) repo);
|
||||
return toProperties(gc.getStatistics());
|
||||
} else {
|
||||
return new Properties();
|
||||
}
|
||||
return new Properties();
|
||||
} catch (IOException e) {
|
||||
throw new JGitInternalException(
|
||||
JGitText.get().couldNotGetRepoStatistics, e);
|
||||
|
|
|
@ -409,27 +409,24 @@ public MergeResult call() throws GitAPIException, NoHeadException,
|
|||
new ObjectId[] { headCommit.getId(),
|
||||
srcCommit.getId() }, mergeStatus,
|
||||
mergeStrategy, null, msg);
|
||||
} else {
|
||||
if (failingPaths != null) {
|
||||
repo.writeMergeCommitMsg(null);
|
||||
repo.writeMergeHeads(null);
|
||||
return new MergeResult(null, merger.getBaseCommitId(),
|
||||
new ObjectId[] {
|
||||
headCommit.getId(), srcCommit.getId() },
|
||||
MergeStatus.FAILED, mergeStrategy,
|
||||
lowLevelResults, failingPaths, null);
|
||||
} else {
|
||||
String mergeMessageWithConflicts = new MergeMessageFormatter()
|
||||
.formatWithConflicts(mergeMessage,
|
||||
unmergedPaths);
|
||||
repo.writeMergeCommitMsg(mergeMessageWithConflicts);
|
||||
return new MergeResult(null, merger.getBaseCommitId(),
|
||||
new ObjectId[] { headCommit.getId(),
|
||||
srcCommit.getId() },
|
||||
MergeStatus.CONFLICTING, mergeStrategy,
|
||||
lowLevelResults, null);
|
||||
}
|
||||
}
|
||||
if (failingPaths != null) {
|
||||
repo.writeMergeCommitMsg(null);
|
||||
repo.writeMergeHeads(null);
|
||||
return new MergeResult(null, merger.getBaseCommitId(),
|
||||
new ObjectId[] { headCommit.getId(),
|
||||
srcCommit.getId() },
|
||||
MergeStatus.FAILED, mergeStrategy, lowLevelResults,
|
||||
failingPaths, null);
|
||||
}
|
||||
String mergeMessageWithConflicts = new MergeMessageFormatter()
|
||||
.formatWithConflicts(mergeMessage, unmergedPaths);
|
||||
repo.writeMergeCommitMsg(mergeMessageWithConflicts);
|
||||
return new MergeResult(null, merger.getBaseCommitId(),
|
||||
new ObjectId[] { headCommit.getId(),
|
||||
srcCommit.getId() },
|
||||
MergeStatus.CONFLICTING, mergeStrategy, lowLevelResults,
|
||||
null);
|
||||
}
|
||||
} catch (org.eclipse.jgit.errors.CheckoutConflictException e) {
|
||||
List<String> conflicts = (dco == null) ? Collections
|
||||
|
|
|
@ -315,23 +315,24 @@ public PullResult call() throws GitAPIException,
|
|||
Ref r = null;
|
||||
if (fetchRes != null) {
|
||||
r = fetchRes.getAdvertisedRef(remoteBranchName);
|
||||
if (r == null)
|
||||
if (r == null) {
|
||||
r = fetchRes.getAdvertisedRef(Constants.R_HEADS
|
||||
+ remoteBranchName);
|
||||
}
|
||||
}
|
||||
if (r == null) {
|
||||
throw new RefNotAdvertisedException(MessageFormat.format(
|
||||
JGitText.get().couldNotGetAdvertisedRef, remote,
|
||||
remoteBranchName));
|
||||
} else {
|
||||
commitToMerge = r.getObjectId();
|
||||
}
|
||||
commitToMerge = r.getObjectId();
|
||||
} else {
|
||||
try {
|
||||
commitToMerge = repo.resolve(remoteBranchName);
|
||||
if (commitToMerge == null)
|
||||
if (commitToMerge == null) {
|
||||
throw new RefNotFoundException(MessageFormat.format(
|
||||
JGitText.get().refNotResolved, remoteBranchName));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new JGitInternalException(
|
||||
JGitText.get().exceptionCaughtDuringExecutionOfPullCommand,
|
||||
|
|
|
@ -509,10 +509,10 @@ private RebaseResult cherryPickCommit(RevCommit commitToPick)
|
|||
monitor.beginTask(MessageFormat.format(
|
||||
JGitText.get().applyingCommit,
|
||||
commitToPick.getShortMessage()), ProgressMonitor.UNKNOWN);
|
||||
if (preserveMerges)
|
||||
if (preserveMerges) {
|
||||
return cherryPickCommitPreservingMerges(commitToPick);
|
||||
else
|
||||
return cherryPickCommitFlattening(commitToPick);
|
||||
}
|
||||
return cherryPickCommitFlattening(commitToPick);
|
||||
} finally {
|
||||
monitor.endTask();
|
||||
}
|
||||
|
@ -539,11 +539,11 @@ private RebaseResult cherryPickCommitFlattening(RevCommit commitToPick)
|
|||
.call();
|
||||
switch (cherryPickResult.getStatus()) {
|
||||
case FAILED:
|
||||
if (operation == Operation.BEGIN)
|
||||
if (operation == Operation.BEGIN) {
|
||||
return abort(RebaseResult
|
||||
.failed(cherryPickResult.getFailingPaths()));
|
||||
else
|
||||
return stop(commitToPick, Status.STOPPED);
|
||||
}
|
||||
return stop(commitToPick, Status.STOPPED);
|
||||
case CONFLICTING:
|
||||
return stop(commitToPick, Status.STOPPED);
|
||||
case OK:
|
||||
|
@ -599,11 +599,11 @@ private RebaseResult cherryPickCommitPreservingMerges(RevCommit commitToPick)
|
|||
CherryPickResult cherryPickResult = pickCommand.call();
|
||||
switch (cherryPickResult.getStatus()) {
|
||||
case FAILED:
|
||||
if (operation == Operation.BEGIN)
|
||||
if (operation == Operation.BEGIN) {
|
||||
return abort(RebaseResult.failed(
|
||||
cherryPickResult.getFailingPaths()));
|
||||
else
|
||||
return stop(commitToPick, Status.STOPPED);
|
||||
}
|
||||
return stop(commitToPick, Status.STOPPED);
|
||||
case CONFLICTING:
|
||||
return stop(commitToPick, Status.STOPPED);
|
||||
case OK:
|
||||
|
|
|
@ -334,10 +334,10 @@ public boolean isReflogDisabled() {
|
|||
}
|
||||
|
||||
private String getRefOrHEAD() {
|
||||
if (ref != null)
|
||||
if (ref != null) {
|
||||
return ref;
|
||||
else
|
||||
return Constants.HEAD;
|
||||
}
|
||||
return Constants.HEAD;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -106,10 +106,10 @@ public SubmoduleSyncCommand addPath(String path) {
|
|||
*/
|
||||
protected String getHeadBranch(Repository subRepo) throws IOException {
|
||||
Ref head = subRepo.exactRef(Constants.HEAD);
|
||||
if (head != null && head.isSymbolic())
|
||||
if (head != null && head.isSymbolic()) {
|
||||
return Repository.shortenRefName(head.getLeaf().getName());
|
||||
else
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
|
|
@ -267,18 +267,18 @@ public void computeAll() throws IOException {
|
|||
*/
|
||||
public int computeNext() throws IOException {
|
||||
BlameGenerator gen = generator;
|
||||
if (gen == null)
|
||||
if (gen == null) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (gen.next()) {
|
||||
loadFrom(gen);
|
||||
lastLength = gen.getRegionLength();
|
||||
return gen.getResultStart();
|
||||
} else {
|
||||
gen.close();
|
||||
generator = null;
|
||||
return -1;
|
||||
}
|
||||
gen.close();
|
||||
generator = null;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -489,8 +489,8 @@ private AbstractTreeIterator makeIteratorFromTreeOrNull(RevTree tree)
|
|||
CanonicalTreeParser parser = new CanonicalTreeParser();
|
||||
parser.reset(reader, tree);
|
||||
return parser;
|
||||
} else
|
||||
return new EmptyTreeIterator();
|
||||
}
|
||||
return new EmptyTreeIterator();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -125,17 +125,17 @@ public Edit(int as, int ae, int bs, int be) {
|
|||
*/
|
||||
public final Type getType() {
|
||||
if (beginA < endA) {
|
||||
if (beginB < endB)
|
||||
if (beginB < endB) {
|
||||
return Type.REPLACE;
|
||||
else /* if (beginB == endB) */
|
||||
return Type.DELETE;
|
||||
}
|
||||
return Type.DELETE;
|
||||
|
||||
} else /* if (beginA == endA) */{
|
||||
if (beginB < endB)
|
||||
return Type.INSERT;
|
||||
else /* if (beginB == endB) */
|
||||
return Type.EMPTY;
|
||||
}
|
||||
if (beginB < endB) {
|
||||
return Type.INSERT;
|
||||
}
|
||||
// beginB == endB)
|
||||
return Type.EMPTY;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -383,15 +383,17 @@ public static boolean isCrLfText(byte[] raw, int length) {
|
|||
* @return the line delimiter or <code>null</code>
|
||||
*/
|
||||
public String getLineDelimiter() {
|
||||
if (size() == 0)
|
||||
if (size() == 0) {
|
||||
return null;
|
||||
}
|
||||
int e = getEnd(0);
|
||||
if (content[e - 1] != '\n')
|
||||
if (content[e - 1] != '\n') {
|
||||
return null;
|
||||
if (content.length > 1 && e > 1 && content[e - 2] == '\r')
|
||||
}
|
||||
if (content.length > 1 && e > 1 && content[e - 2] == '\r') {
|
||||
return "\r\n"; //$NON-NLS-1$
|
||||
else
|
||||
return "\n"; //$NON-NLS-1$
|
||||
}
|
||||
return "\n"; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -517,10 +517,10 @@ private boolean doCheckout() throws CorruptObjectException, IOException,
|
|||
prescanOneTree();
|
||||
|
||||
if (!conflicts.isEmpty()) {
|
||||
if (failOnConflict)
|
||||
if (failOnConflict) {
|
||||
throw new CheckoutConflictException(conflicts.toArray(new String[0]));
|
||||
else
|
||||
cleanUpConflicts();
|
||||
}
|
||||
cleanUpConflicts();
|
||||
}
|
||||
|
||||
// update our index
|
||||
|
@ -895,15 +895,14 @@ void processEntry(CanonicalTreeParser h, CanonicalTreeParser m,
|
|||
// the workingtree entry doesn't exist or also contains a folder
|
||||
// -> no problem
|
||||
return;
|
||||
} else {
|
||||
// the workingtree entry exists and is not a folder
|
||||
if (!idEqual(h, m)) {
|
||||
// Because HEAD and MERGE differ we will try to update the
|
||||
// workingtree with a folder -> return a conflict
|
||||
conflict(name, null, null, null);
|
||||
}
|
||||
return;
|
||||
}
|
||||
// the workingtree entry exists and is not a folder
|
||||
if (!idEqual(h, m)) {
|
||||
// Because HEAD and MERGE differ we will try to update the
|
||||
// workingtree with a folder -> return a conflict
|
||||
conflict(name, null, null, null);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if ((ffMask == 0x00F) && f != null && FileMode.TREE.equals(f.getEntryFileMode())) {
|
||||
|
@ -1083,15 +1082,15 @@ else if (m == null)
|
|||
// Something in Head
|
||||
|
||||
if (!FileMode.TREE.equals(f.getEntryFileMode())
|
||||
&& FileMode.TREE.equals(iMode))
|
||||
&& FileMode.TREE.equals(iMode)) {
|
||||
// The workingtree contains a file and the index semantically contains a folder.
|
||||
// Git considers the workingtree file as untracked. Just keep the untracked file.
|
||||
return;
|
||||
else
|
||||
// -> file is dirty and tracked but is should be
|
||||
// removed. That's a conflict
|
||||
conflict(name, dce, h, m);
|
||||
} else
|
||||
}
|
||||
// -> file is dirty and tracked but is should be
|
||||
// removed. That's a conflict
|
||||
conflict(name, dce, h, m);
|
||||
} else {
|
||||
// file doesn't exist or is clean
|
||||
// Index contains the same as Head
|
||||
// Something different from a submodule in Index
|
||||
|
@ -1099,7 +1098,8 @@ else if (m == null)
|
|||
// Something in Head
|
||||
// -> Remove from index and delete the file
|
||||
remove(name);
|
||||
} else
|
||||
}
|
||||
} else {
|
||||
// Index contains something different from Head
|
||||
// Something different from a submodule in Index
|
||||
// Nothing in Merge
|
||||
|
@ -1108,6 +1108,7 @@ else if (m == null)
|
|||
// filesystem). But Merge wants the path to be removed.
|
||||
// Report a conflict
|
||||
conflict(name, dce, h, m);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Something in Merge
|
||||
|
@ -1340,13 +1341,14 @@ private boolean isModifiedSubtree_IndexWorkingtree(String path)
|
|||
private boolean isModified_IndexTree(String path, ObjectId iId,
|
||||
FileMode iMode, ObjectId tId, FileMode tMode, ObjectId rootTree)
|
||||
throws CorruptObjectException, IOException {
|
||||
if (iMode != tMode)
|
||||
if (iMode != tMode) {
|
||||
return true;
|
||||
}
|
||||
if (FileMode.TREE.equals(iMode)
|
||||
&& (iId == null || ObjectId.zeroId().equals(iId)))
|
||||
&& (iId == null || ObjectId.zeroId().equals(iId))) {
|
||||
return isModifiedSubtree_IndexTree(path, rootTree);
|
||||
else
|
||||
return !equalIdAndMode(iId, iMode, tId, tMode);
|
||||
}
|
||||
return !equalIdAndMode(iId, iMode, tId, tMode);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -824,10 +824,10 @@ private void encodeTS(int pIdx, Instant when) {
|
|||
}
|
||||
|
||||
private int getExtendedFlags() {
|
||||
if (isExtended())
|
||||
if (isExtended()) {
|
||||
return NB.decodeUInt16(info, infoOffset + P_FLAGS2) << 16;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static void checkPath(byte[] path) {
|
||||
|
|
|
@ -82,10 +82,10 @@ public final void setNewHeads(List<Head> newHeads) {
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public List<Head> getNextHeads(char c) {
|
||||
if (matches(c))
|
||||
if (matches(c)) {
|
||||
return newHeads;
|
||||
else
|
||||
return FileNameMatcher.EMPTY_HEAD_LIST;
|
||||
}
|
||||
return FileNameMatcher.EMPTY_HEAD_LIST;
|
||||
}
|
||||
|
||||
boolean isStar() {
|
||||
|
|
|
@ -304,11 +304,11 @@ private static List<AbstractHead> createSimpleHeads(
|
|||
|
||||
private static AbstractHead createWildCardHead(
|
||||
final Character invalidWildgetCharacter, final boolean star) {
|
||||
if (invalidWildgetCharacter != null)
|
||||
if (invalidWildgetCharacter != null) {
|
||||
return new RestrictedWildCardHead(invalidWildgetCharacter
|
||||
.charValue(), star);
|
||||
else
|
||||
return new WildCardHead(star);
|
||||
}
|
||||
return new WildCardHead(star);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -293,13 +293,12 @@ public void endDocument() throws SAXException {
|
|||
String revision = defaultRevision;
|
||||
if (remote == null) {
|
||||
if (defaultRemote == null) {
|
||||
if (filename != null)
|
||||
if (filename != null) {
|
||||
throw new SAXException(MessageFormat.format(
|
||||
RepoText.get().errorNoDefaultFilename,
|
||||
filename));
|
||||
else
|
||||
throw new SAXException(
|
||||
RepoText.get().errorNoDefault);
|
||||
}
|
||||
throw new SAXException(RepoText.get().errorNoDefault);
|
||||
}
|
||||
remote = defaultRemote;
|
||||
} else {
|
||||
|
|
|
@ -761,18 +761,17 @@ public RevCommit call() throws GitAPIException {
|
|||
} catch (GitAPIException | IOException e) {
|
||||
throw new ManifestErrorException(e);
|
||||
}
|
||||
} else {
|
||||
try (Git git = new Git(repo)) {
|
||||
for (RepoProject proj : filteredProjects) {
|
||||
addSubmodule(proj.getName(), proj.getUrl(), proj.getPath(),
|
||||
proj.getRevision(), proj.getCopyFiles(),
|
||||
proj.getLinkFiles(), git);
|
||||
}
|
||||
return git.commit().setMessage(RepoText.get().repoCommitMessage)
|
||||
.call();
|
||||
} catch (GitAPIException | IOException e) {
|
||||
throw new ManifestErrorException(e);
|
||||
}
|
||||
try (Git git = new Git(repo)) {
|
||||
for (RepoProject proj : filteredProjects) {
|
||||
addSubmodule(proj.getName(), proj.getUrl(), proj.getPath(),
|
||||
proj.getRevision(), proj.getCopyFiles(),
|
||||
proj.getLinkFiles(), git);
|
||||
}
|
||||
return git.commit().setMessage(RepoText.get().repoCommitMessage)
|
||||
.call();
|
||||
} catch (GitAPIException | IOException e) {
|
||||
throw new ManifestErrorException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -422,10 +422,10 @@ public void clearLinkFiles() {
|
|||
}
|
||||
|
||||
private String getPathWithSlash() {
|
||||
if (path.endsWith("/")) //$NON-NLS-1$
|
||||
if (path.endsWith("/")) { //$NON-NLS-1$
|
||||
return path;
|
||||
else
|
||||
return path + "/"; //$NON-NLS-1$
|
||||
}
|
||||
return path + "/"; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -291,26 +291,25 @@ && isWild(matchers.get(matcher))) {
|
|||
// We had a prefix match here.
|
||||
if (!pathMatch) {
|
||||
return true;
|
||||
}
|
||||
if (right == endExcl - 1) {
|
||||
// Extra slash at the end: actually a full match.
|
||||
// Must meet directory expectations
|
||||
return !dirOnly || assumeDirectory;
|
||||
}
|
||||
// Prefix matches only if pattern ended with /**
|
||||
if (wasWild) {
|
||||
return true;
|
||||
}
|
||||
if (lastWildmatch >= 0) {
|
||||
// Consider pattern **/x and input x/x.
|
||||
// We've matched the prefix x/ so far: we
|
||||
// must try to extend the **!
|
||||
matcher = lastWildmatch + 1;
|
||||
right = wildmatchBacktrackPos;
|
||||
wildmatchBacktrackPos = -1;
|
||||
} else {
|
||||
if (right == endExcl - 1) {
|
||||
// Extra slash at the end: actually a full match.
|
||||
// Must meet directory expectations
|
||||
return !dirOnly || assumeDirectory;
|
||||
}
|
||||
// Prefix matches only if pattern ended with /**
|
||||
if (wasWild) {
|
||||
return true;
|
||||
}
|
||||
if (lastWildmatch >= 0) {
|
||||
// Consider pattern **/x and input x/x.
|
||||
// We've matched the prefix x/ so far: we
|
||||
// must try to extend the **!
|
||||
matcher = lastWildmatch + 1;
|
||||
right = wildmatchBacktrackPos;
|
||||
wildmatchBacktrackPos = -1;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else if (lastWildmatch != -1) {
|
||||
|
|
|
@ -192,22 +192,20 @@ private static boolean isComplexWildcard(String pattern) {
|
|||
}
|
||||
if (pattern.indexOf('?') != -1) {
|
||||
return true;
|
||||
} else {
|
||||
// check if the backslash escapes one of the glob special characters
|
||||
// if not, backslash is not part of a regex and treated literally
|
||||
int backSlash = pattern.indexOf('\\');
|
||||
if (backSlash >= 0) {
|
||||
int nextIdx = backSlash + 1;
|
||||
if (pattern.length() == nextIdx) {
|
||||
return false;
|
||||
}
|
||||
char nextChar = pattern.charAt(nextIdx);
|
||||
if (escapedByBackslash(nextChar)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// check if the backslash escapes one of the glob special characters
|
||||
// if not, backslash is not part of a regex and treated literally
|
||||
int backSlash = pattern.indexOf('\\');
|
||||
if (backSlash >= 0) {
|
||||
int nextIdx = backSlash + 1;
|
||||
if (pattern.length() == nextIdx) {
|
||||
return false;
|
||||
}
|
||||
char nextChar = pattern.charAt(nextIdx);
|
||||
if (escapedByBackslash(nextChar)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -132,9 +132,8 @@ KetchReplica.State check(ObjectId acceptId, ReceiveCommand acceptCmd) {
|
|||
// TODO(sop) Check term to see if my leader was deposed.
|
||||
if (rw.isMergedInto(head, remote)) {
|
||||
return AHEAD;
|
||||
} else {
|
||||
return DIVERGENT;
|
||||
}
|
||||
return DIVERGENT;
|
||||
} catch (IOException err) {
|
||||
KetchReplica.log.error(String.format(
|
||||
"Cannot compare %s", //$NON-NLS-1$
|
||||
|
|
|
@ -191,14 +191,11 @@ Ref doPeel(Ref leaf) throws MissingObjectException,
|
|||
rw.peel(obj).copy(),
|
||||
hasVersioning() ? leaf.getUpdateIndex()
|
||||
: UNDEFINED_UPDATE_INDEX);
|
||||
} else {
|
||||
return new ObjectIdRef.PeeledNonTag(
|
||||
leaf.getStorage(),
|
||||
leaf.getName(),
|
||||
leaf.getObjectId(),
|
||||
hasVersioning() ? leaf.getUpdateIndex()
|
||||
: UNDEFINED_UPDATE_INDEX);
|
||||
}
|
||||
return new ObjectIdRef.PeeledNonTag(leaf.getStorage(),
|
||||
leaf.getName(), leaf.getObjectId(),
|
||||
hasVersioning() ? leaf.getUpdateIndex()
|
||||
: UNDEFINED_UPDATE_INDEX);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -358,9 +358,8 @@ public String getIdentifier() {
|
|||
File directory = getDirectory();
|
||||
if (directory != null) {
|
||||
return directory.getPath();
|
||||
} else {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
|
|
@ -152,11 +152,10 @@ void unlock() {
|
|||
boolean commit() {
|
||||
if (nonEmpty) {
|
||||
return lock.commit();
|
||||
} else {
|
||||
logFile.delete();
|
||||
lock.unlock();
|
||||
return true;
|
||||
}
|
||||
logFile.delete();
|
||||
lock.unlock();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -109,10 +109,9 @@ private ObjectId insert(
|
|||
ObjectId id = idFor(type, data, off, len);
|
||||
if (!createDuplicate && db.has(id)) {
|
||||
return id;
|
||||
} else {
|
||||
File tmp = toTemp(type, data, off, len);
|
||||
return insertOneObject(tmp, id, createDuplicate);
|
||||
}
|
||||
File tmp = toTemp(type, data, off, len);
|
||||
return insertOneObject(tmp, id, createDuplicate);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
@ -141,12 +140,11 @@ ObjectId insert(int type, long len, InputStream is, boolean createDuplicate)
|
|||
int actLen = IO.readFully(is, buf, 0);
|
||||
return insert(type, buf, 0, actLen, createDuplicate);
|
||||
|
||||
} else {
|
||||
SHA1 md = digest();
|
||||
File tmp = toTemp(md, type, len, is);
|
||||
ObjectId id = md.toObjectId();
|
||||
return insertOneObject(tmp, id, createDuplicate);
|
||||
}
|
||||
SHA1 md = digest();
|
||||
File tmp = toTemp(md, type, len, is);
|
||||
ObjectId id = md.toObjectId();
|
||||
return insertOneObject(tmp, id, createDuplicate);
|
||||
}
|
||||
|
||||
private ObjectId insertOneObject(
|
||||
|
|
|
@ -844,19 +844,20 @@ ObjectLoader load(WindowCursor curs, long pos)
|
|||
case Constants.OBJ_TREE:
|
||||
case Constants.OBJ_BLOB:
|
||||
case Constants.OBJ_TAG: {
|
||||
if (delta != null || sz < curs.getStreamFileThreshold())
|
||||
if (delta != null || sz < curs.getStreamFileThreshold()) {
|
||||
data = decompress(pos + p, (int) sz, curs);
|
||||
}
|
||||
|
||||
if (delta != null) {
|
||||
type = typeCode;
|
||||
break SEARCH;
|
||||
}
|
||||
|
||||
if (data != null)
|
||||
if (data != null) {
|
||||
return new ObjectLoader.SmallObject(typeCode, data);
|
||||
else
|
||||
return new LargePackedWholeObject(typeCode, sz, pos, p,
|
||||
this, curs.db);
|
||||
}
|
||||
return new LargePackedWholeObject(typeCode, sz, pos, p,
|
||||
this, curs.db);
|
||||
}
|
||||
|
||||
case Constants.OBJ_OFS_DELTA: {
|
||||
|
|
|
@ -594,10 +594,9 @@ private ObjectIdRef doPeel(Ref leaf) throws MissingObjectException,
|
|||
if (obj instanceof RevTag) {
|
||||
return new ObjectIdRef.PeeledTag(leaf.getStorage(), leaf
|
||||
.getName(), leaf.getObjectId(), rw.peel(obj).copy());
|
||||
} else {
|
||||
return new ObjectIdRef.PeeledNonTag(leaf.getStorage(), leaf
|
||||
.getName(), leaf.getObjectId());
|
||||
}
|
||||
return new ObjectIdRef.PeeledNonTag(leaf.getStorage(),
|
||||
leaf.getName(), leaf.getObjectId());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -894,10 +893,9 @@ private Ref peeledPackedRef(Ref f)
|
|||
if (peeledObjectId != null) {
|
||||
return new ObjectIdRef.PeeledTag(PACKED, f.getName(),
|
||||
f.getObjectId(), peeledObjectId);
|
||||
} else {
|
||||
return new ObjectIdRef.PeeledNonTag(PACKED, f.getName(),
|
||||
f.getObjectId());
|
||||
}
|
||||
return new ObjectIdRef.PeeledNonTag(PACKED, f.getName(),
|
||||
f.getObjectId());
|
||||
}
|
||||
|
||||
void log(boolean force, RefUpdate update, String msg, boolean deref)
|
||||
|
@ -1480,10 +1478,8 @@ public LooseRef peel(ObjectIdRef newLeaf) {
|
|||
if (peeledObjectId != null) {
|
||||
return new LoosePeeledTag(snapShot, getName(),
|
||||
objectId, peeledObjectId);
|
||||
} else {
|
||||
return new LooseNonTag(snapShot, getName(),
|
||||
objectId);
|
||||
}
|
||||
return new LooseNonTag(snapShot, getName(), objectId);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -90,9 +90,8 @@ protected boolean tryLock(boolean deref) throws IOException {
|
|||
dst = database.findRef(name);
|
||||
setOldObjectId(dst != null ? dst.getObjectId() : null);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
|
|
@ -140,9 +140,9 @@ public String toString() {
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public CheckoutEntry parseCheckout() {
|
||||
if (getComment().startsWith(CheckoutEntryImpl.CHECKOUT_MOVING_FROM))
|
||||
if (getComment().startsWith(CheckoutEntryImpl.CHECKOUT_MOVING_FROM)) {
|
||||
return new CheckoutEntryImpl(this);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -139,49 +139,48 @@ static ObjectLoader open(InputStream in, File path, AnyObjectId id,
|
|||
}
|
||||
return new LargeObject(type, size, path, id, wc.db);
|
||||
|
||||
} else {
|
||||
readSome(in, hdr, 2, 18);
|
||||
int c = hdr[0] & 0xff;
|
||||
int type = (c >> 4) & 7;
|
||||
long size = c & 15;
|
||||
int shift = 4;
|
||||
int p = 1;
|
||||
while ((c & 0x80) != 0) {
|
||||
c = hdr[p++] & 0xff;
|
||||
size += ((long) (c & 0x7f)) << shift;
|
||||
shift += 7;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case Constants.OBJ_COMMIT:
|
||||
case Constants.OBJ_TREE:
|
||||
case Constants.OBJ_BLOB:
|
||||
case Constants.OBJ_TAG:
|
||||
// Acceptable types for a loose object.
|
||||
break;
|
||||
default:
|
||||
throw new CorruptObjectException(id,
|
||||
JGitText.get().corruptObjectInvalidType);
|
||||
}
|
||||
|
||||
if (path == null && Integer.MAX_VALUE < size) {
|
||||
LargeObjectException.ExceedsByteArrayLimit e;
|
||||
e = new LargeObjectException.ExceedsByteArrayLimit();
|
||||
e.setObjectId(id);
|
||||
throw e;
|
||||
}
|
||||
if (size < wc.getStreamFileThreshold() || path == null) {
|
||||
in.reset();
|
||||
IO.skipFully(in, p);
|
||||
Inflater inf = wc.inflater();
|
||||
InputStream zIn = inflate(in, inf);
|
||||
byte[] data = new byte[(int) size];
|
||||
IO.readFully(zIn, data, 0, data.length);
|
||||
checkValidEndOfStream(in, inf, id, hdr);
|
||||
return new ObjectLoader.SmallObject(type, data);
|
||||
}
|
||||
return new LargeObject(type, size, path, id, wc.db);
|
||||
}
|
||||
readSome(in, hdr, 2, 18);
|
||||
int c = hdr[0] & 0xff;
|
||||
int type = (c >> 4) & 7;
|
||||
long size = c & 15;
|
||||
int shift = 4;
|
||||
int p = 1;
|
||||
while ((c & 0x80) != 0) {
|
||||
c = hdr[p++] & 0xff;
|
||||
size += ((long) (c & 0x7f)) << shift;
|
||||
shift += 7;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case Constants.OBJ_COMMIT:
|
||||
case Constants.OBJ_TREE:
|
||||
case Constants.OBJ_BLOB:
|
||||
case Constants.OBJ_TAG:
|
||||
// Acceptable types for a loose object.
|
||||
break;
|
||||
default:
|
||||
throw new CorruptObjectException(id,
|
||||
JGitText.get().corruptObjectInvalidType);
|
||||
}
|
||||
|
||||
if (path == null && Integer.MAX_VALUE < size) {
|
||||
LargeObjectException.ExceedsByteArrayLimit e;
|
||||
e = new LargeObjectException.ExceedsByteArrayLimit();
|
||||
e.setObjectId(id);
|
||||
throw e;
|
||||
}
|
||||
if (size < wc.getStreamFileThreshold() || path == null) {
|
||||
in.reset();
|
||||
IO.skipFully(in, p);
|
||||
Inflater inf = wc.inflater();
|
||||
InputStream zIn = inflate(in, inf);
|
||||
byte[] data = new byte[(int) size];
|
||||
IO.readFully(zIn, data, 0, data.length);
|
||||
checkValidEndOfStream(in, inf, id, hdr);
|
||||
return new ObjectLoader.SmallObject(type, data);
|
||||
}
|
||||
return new LargeObject(type, size, path, id, wc.db);
|
||||
} catch (ZipException badStream) {
|
||||
throw new CorruptObjectException(id,
|
||||
JGitText.get().corruptObjectBadStream);
|
||||
|
@ -213,19 +212,18 @@ static long getSize(InputStream in, AnyObjectId id, WindowCursor wc)
|
|||
JGitText.get().corruptObjectNegativeSize);
|
||||
return size;
|
||||
|
||||
} else {
|
||||
readSome(in, hdr, 2, 18);
|
||||
int c = hdr[0] & 0xff;
|
||||
long size = c & 15;
|
||||
int shift = 4;
|
||||
int p = 1;
|
||||
while ((c & 0x80) != 0) {
|
||||
c = hdr[p++] & 0xff;
|
||||
size += ((long) (c & 0x7f)) << shift;
|
||||
shift += 7;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
readSome(in, hdr, 2, 18);
|
||||
int c = hdr[0] & 0xff;
|
||||
long size = c & 15;
|
||||
int shift = 4;
|
||||
int p = 1;
|
||||
while ((c & 0x80) != 0) {
|
||||
c = hdr[p++] & 0xff;
|
||||
size += ((long) (c & 0x7f)) << shift;
|
||||
shift += 7;
|
||||
}
|
||||
return size;
|
||||
} catch (ZipException badStream) {
|
||||
throw new CorruptObjectException(id,
|
||||
JGitText.get().corruptObjectBadStream);
|
||||
|
|
|
@ -126,17 +126,19 @@ boolean add(AnyObjectId toAdd) {
|
|||
for (int n = 0; n < MAX_CHAIN;) {
|
||||
ObjectId obj = ids.get(i);
|
||||
if (obj == null) {
|
||||
if (ids.compareAndSet(i, null, toAdd.copy()))
|
||||
if (ids.compareAndSet(i, null, toAdd.copy())) {
|
||||
return true;
|
||||
else
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (AnyObjectId.isEqual(obj, toAdd))
|
||||
if (AnyObjectId.isEqual(obj, toAdd)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (++i == ids.length())
|
||||
if (++i == ids.length()) {
|
||||
i = 0;
|
||||
}
|
||||
n++;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -1751,23 +1751,23 @@ private void writeObjectImpl(PackOutputStream out, ObjectToPack otp)
|
|||
NullProgressMonitor.INSTANCE,
|
||||
Collections.singleton(otp));
|
||||
continue;
|
||||
} else {
|
||||
// Object writing already started, we cannot recover.
|
||||
//
|
||||
CorruptObjectException coe;
|
||||
coe = new CorruptObjectException(otp, ""); //$NON-NLS-1$
|
||||
coe.initCause(gone);
|
||||
throw coe;
|
||||
}
|
||||
// Object writing already started, we cannot recover.
|
||||
//
|
||||
CorruptObjectException coe;
|
||||
coe = new CorruptObjectException(otp, ""); //$NON-NLS-1$
|
||||
coe.initCause(gone);
|
||||
throw coe;
|
||||
}
|
||||
}
|
||||
|
||||
// If we reached here, reuse wasn't possible.
|
||||
//
|
||||
if (otp.isDeltaRepresentation())
|
||||
if (otp.isDeltaRepresentation()) {
|
||||
writeDeltaObjectDeflate(out, otp);
|
||||
else
|
||||
} else {
|
||||
writeWholeObjectDeflate(out, otp);
|
||||
}
|
||||
out.endObject();
|
||||
otp.setCRC((int) crc32.getValue());
|
||||
}
|
||||
|
|
|
@ -87,16 +87,14 @@ public static ReceiveCommand toCommand(Ref oldRef, Ref newRef) {
|
|||
if (newRef.isSymbolic()) {
|
||||
return ReceiveCommand.link(oldRef.getTarget().getName(),
|
||||
newRef.getTarget().getName(), name);
|
||||
} else {
|
||||
// This should pass in oldId for compat with
|
||||
// RefDirectoryUpdate
|
||||
return ReceiveCommand.unlink(oldRef.getTarget().getName(),
|
||||
newId, name);
|
||||
}
|
||||
} else {
|
||||
// This should pass in oldId for compat with
|
||||
// RefDirectoryUpdate
|
||||
return ReceiveCommand.unlink(oldRef.getTarget().getName(),
|
||||
ObjectId.zeroId(), name);
|
||||
newId, name);
|
||||
}
|
||||
return ReceiveCommand.unlink(oldRef.getTarget().getName(),
|
||||
ObjectId.zeroId(), name);
|
||||
}
|
||||
|
||||
if (newRef != null && newRef.isSymbolic()) {
|
||||
|
@ -104,14 +102,12 @@ public static ReceiveCommand toCommand(Ref oldRef, Ref newRef) {
|
|||
if (oldRef.isSymbolic()) {
|
||||
return ReceiveCommand.link(oldRef.getTarget().getName(),
|
||||
newRef.getTarget().getName(), name);
|
||||
} else {
|
||||
return ReceiveCommand.link(oldId,
|
||||
newRef.getTarget().getName(), name);
|
||||
}
|
||||
} else {
|
||||
return ReceiveCommand.link(ObjectId.zeroId(),
|
||||
return ReceiveCommand.link(oldId,
|
||||
newRef.getTarget().getName(), name);
|
||||
}
|
||||
return ReceiveCommand.link(ObjectId.zeroId(),
|
||||
newRef.getTarget().getName(), name);
|
||||
}
|
||||
|
||||
return new ReceiveCommand(oldId, newId, name);
|
||||
|
|
|
@ -102,9 +102,8 @@ public void execute(RevWalk rw, ProgressMonitor monitor)
|
|||
if (isAtomic()) {
|
||||
ReceiveCommand.abort(getCommands());
|
||||
return;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
todo.add(new Command(rw, c));
|
||||
|
|
|
@ -82,9 +82,8 @@ private NetscapeCookieFileCache(HttpConfig config) {
|
|||
public static NetscapeCookieFileCache getInstance(HttpConfig config) {
|
||||
if (instance == null) {
|
||||
return new NetscapeCookieFileCache(config);
|
||||
} else {
|
||||
return instance;
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -384,9 +384,8 @@ protected List<String> validate(String key, List<String> value) {
|
|||
private static boolean isHostMatch(String pattern, String name) {
|
||||
if (pattern.startsWith("!")) { //$NON-NLS-1$
|
||||
return !patternMatchesHost(pattern.substring(1), name);
|
||||
} else {
|
||||
return patternMatchesHost(pattern, name);
|
||||
}
|
||||
return patternMatchesHost(pattern, name);
|
||||
}
|
||||
|
||||
private static boolean patternMatchesHost(String pattern, String name) {
|
||||
|
@ -399,10 +398,9 @@ private static boolean patternMatchesHost(String pattern, String name) {
|
|||
}
|
||||
fn.append(name);
|
||||
return fn.isMatch();
|
||||
} else {
|
||||
// Not a pattern but a full host name
|
||||
return pattern.equals(name);
|
||||
}
|
||||
// Not a pattern but a full host name
|
||||
return pattern.equals(name);
|
||||
}
|
||||
|
||||
private static String dequote(String value) {
|
||||
|
|
|
@ -302,10 +302,10 @@ public final boolean equals(AnyObjectId other) {
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final boolean equals(Object o) {
|
||||
if (o instanceof AnyObjectId)
|
||||
if (o instanceof AnyObjectId) {
|
||||
return equals((AnyObjectId) o);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -103,25 +103,29 @@ private static boolean isSymRef(byte[] ref) {
|
|||
private static File getSymRef(File workTree, File dotGit, FS fs)
|
||||
throws IOException {
|
||||
byte[] content = IO.readFully(dotGit);
|
||||
if (!isSymRef(content))
|
||||
if (!isSymRef(content)) {
|
||||
throw new IOException(MessageFormat.format(
|
||||
JGitText.get().invalidGitdirRef, dotGit.getAbsolutePath()));
|
||||
}
|
||||
|
||||
int pathStart = 8;
|
||||
int lineEnd = RawParseUtils.nextLF(content, pathStart);
|
||||
while (content[lineEnd - 1] == '\n' ||
|
||||
(content[lineEnd - 1] == '\r' && SystemReader.getInstance().isWindows()))
|
||||
(content[lineEnd - 1] == '\r'
|
||||
&& SystemReader.getInstance().isWindows())) {
|
||||
lineEnd--;
|
||||
if (lineEnd == pathStart)
|
||||
}
|
||||
if (lineEnd == pathStart) {
|
||||
throw new IOException(MessageFormat.format(
|
||||
JGitText.get().invalidGitdirRef, dotGit.getAbsolutePath()));
|
||||
}
|
||||
|
||||
String gitdirPath = RawParseUtils.decode(content, pathStart, lineEnd);
|
||||
File gitdirFile = fs.resolve(workTree, gitdirPath);
|
||||
if (gitdirFile.isAbsolute())
|
||||
if (gitdirFile.isAbsolute()) {
|
||||
return gitdirFile;
|
||||
else
|
||||
return new File(workTree, gitdirPath).getCanonicalFile();
|
||||
}
|
||||
return new File(workTree, gitdirPath).getCanonicalFile();
|
||||
}
|
||||
|
||||
private FS fs;
|
||||
|
@ -723,9 +727,8 @@ protected Config loadConfig() throws IOException {
|
|||
.getAbsolutePath(), err.getMessage()));
|
||||
}
|
||||
return cfg;
|
||||
} else {
|
||||
return new Config();
|
||||
}
|
||||
return new Config();
|
||||
}
|
||||
|
||||
private File guessWorkTreeOrFail() throws IOException {
|
||||
|
|
|
@ -232,9 +232,9 @@ private String findRemoteTrackingBranch(String remote, String mergeRef) {
|
|||
|
||||
private String getRemoteOrDefault() {
|
||||
String remote = getRemote();
|
||||
if (remote == null)
|
||||
if (remote == null) {
|
||||
return Constants.DEFAULT_REMOTE_NAME;
|
||||
else
|
||||
return remote;
|
||||
}
|
||||
return remote;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1395,12 +1395,11 @@ private static String readValue(StringReader in)
|
|||
}
|
||||
trailingSpaces.append(cc);
|
||||
continue;
|
||||
} else {
|
||||
inLeadingSpace = false;
|
||||
if (trailingSpaces != null) {
|
||||
value.append(trailingSpaces);
|
||||
trailingSpaces.setLength(0);
|
||||
}
|
||||
}
|
||||
inLeadingSpace = false;
|
||||
if (trailingSpaces != null) {
|
||||
value.append(trailingSpaces);
|
||||
trailingSpaces.setLength(0);
|
||||
}
|
||||
|
||||
if ('\\' == c) {
|
||||
|
|
|
@ -134,11 +134,9 @@ public <T extends Enum<?>> T getEnum(Config config, T[] all, String section,
|
|||
throw new IllegalArgumentException(
|
||||
MessageFormat.format(JGitText.get().enumValueNotSupported3,
|
||||
section, subsection, name, value));
|
||||
} else {
|
||||
throw new IllegalArgumentException(
|
||||
MessageFormat.format(JGitText.get().enumValueNotSupported2,
|
||||
section, name, value));
|
||||
}
|
||||
throw new IllegalArgumentException(MessageFormat.format(
|
||||
JGitText.get().enumValueNotSupported2, section, name, value));
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
|
|
@ -606,16 +606,17 @@ public boolean diff(final ProgressMonitor monitor, int estWorkTreeSize,
|
|||
}
|
||||
|
||||
// consume the remaining work
|
||||
if (monitor != null)
|
||||
if (monitor != null) {
|
||||
monitor.endTask();
|
||||
}
|
||||
|
||||
ignored = indexDiffFilter.getIgnoredPaths();
|
||||
if (added.isEmpty() && changed.isEmpty() && removed.isEmpty()
|
||||
&& missing.isEmpty() && modified.isEmpty()
|
||||
&& untracked.isEmpty())
|
||||
&& untracked.isEmpty()) {
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean hasFiles(File directory) {
|
||||
|
|
|
@ -293,9 +293,8 @@ public boolean next() throws MissingObjectException, IOException {
|
|||
if (idItr.hasNext()) {
|
||||
cur = idItr.next();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -383,9 +382,8 @@ public boolean next() throws MissingObjectException, IOException {
|
|||
cur = idItr.next();
|
||||
sz = getObjectSize(cur, OBJ_ANY);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -503,9 +503,8 @@ public ObjectId resolve(String revstr)
|
|||
if (resolved instanceof String) {
|
||||
final Ref ref = findRef((String) resolved);
|
||||
return ref != null ? ref.getLeaf().getObjectId() : null;
|
||||
} else {
|
||||
return (ObjectId) resolved;
|
||||
}
|
||||
return (ObjectId) resolved;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -527,11 +526,12 @@ public String simplify(String revstr)
|
|||
try (RevWalk rw = new RevWalk(this)) {
|
||||
rw.setRetainBody(true);
|
||||
Object resolved = resolve(rw, revstr);
|
||||
if (resolved != null)
|
||||
if (resolved instanceof String)
|
||||
if (resolved != null) {
|
||||
if (resolved instanceof String) {
|
||||
return (String) resolved;
|
||||
else
|
||||
return ((AnyObjectId) resolved).getName();
|
||||
}
|
||||
return ((AnyObjectId) resolved).getName();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -760,15 +760,15 @@ private Object resolve(RevWalk rw, String revstr)
|
|||
if (name == null)
|
||||
throw new RevisionSyntaxException(revstr);
|
||||
} else if (time.matches("^-\\d+$")) { //$NON-NLS-1$
|
||||
if (name != null)
|
||||
if (name != null) {
|
||||
throw new RevisionSyntaxException(revstr);
|
||||
else {
|
||||
String previousCheckout = resolveReflogCheckout(-Integer
|
||||
.parseInt(time));
|
||||
if (ObjectId.isId(previousCheckout))
|
||||
rev = parseSimple(rw, previousCheckout);
|
||||
else
|
||||
name = previousCheckout;
|
||||
}
|
||||
String previousCheckout = resolveReflogCheckout(
|
||||
-Integer.parseInt(time));
|
||||
if (ObjectId.isId(previousCheckout)) {
|
||||
rev = parseSimple(rw, previousCheckout);
|
||||
} else {
|
||||
name = previousCheckout;
|
||||
}
|
||||
} else {
|
||||
if (name == null)
|
||||
|
|
|
@ -166,10 +166,10 @@ private static String[] getMergeOptions(String branch, Config config) {
|
|||
String mergeOptions = config.getString(
|
||||
ConfigConstants.CONFIG_BRANCH_SECTION, branch,
|
||||
ConfigConstants.CONFIG_KEY_MERGEOPTIONS);
|
||||
if (mergeOptions != null)
|
||||
if (mergeOptions != null) {
|
||||
return mergeOptions.split("\\s"); //$NON-NLS-1$
|
||||
else
|
||||
return new String[0];
|
||||
}
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
private static class MergeConfigSectionParser implements
|
||||
|
@ -188,10 +188,10 @@ public MergeConfig parse(Config cfg) {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof MergeConfigSectionParser)
|
||||
if (obj instanceof MergeConfigSectionParser) {
|
||||
return branch.equals(((MergeConfigSectionParser) obj).branch);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -153,15 +153,16 @@ public String formatWithConflicts(String message,
|
|||
private static void addConflictsMessage(List<String> conflictingPaths,
|
||||
StringBuilder sb) {
|
||||
sb.append("Conflicts:\n"); //$NON-NLS-1$
|
||||
for (String conflictingPath : conflictingPaths)
|
||||
for (String conflictingPath : conflictingPaths) {
|
||||
sb.append('\t').append(conflictingPath).append('\n');
|
||||
}
|
||||
}
|
||||
|
||||
private static String joinNames(List<String> names, String singular,
|
||||
String plural) {
|
||||
if (names.size() == 1)
|
||||
if (names.size() == 1) {
|
||||
return singular + " " + names.get(0); //$NON-NLS-1$
|
||||
else
|
||||
return plural + " " + StringUtils.join(names, ", ", " and "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
}
|
||||
return plural + " " + StringUtils.join(names, ", ", " and "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
}
|
||||
}
|
||||
|
|
|
@ -652,42 +652,40 @@ protected boolean processEntry(CanonicalTreeParser base,
|
|||
keep(ourDce);
|
||||
// no checkout needed!
|
||||
return true;
|
||||
} else {
|
||||
// same content but different mode on OURS and THEIRS.
|
||||
// Try to merge the mode and report an error if this is
|
||||
// not possible.
|
||||
int newMode = mergeFileModes(modeB, modeO, modeT);
|
||||
if (newMode != FileMode.MISSING.getBits()) {
|
||||
if (newMode == modeO)
|
||||
// ours version is preferred
|
||||
keep(ourDce);
|
||||
else {
|
||||
// the preferred version THEIRS has a different mode
|
||||
// than ours. Check it out!
|
||||
if (isWorktreeDirty(work, ourDce))
|
||||
return false;
|
||||
// we know about length and lastMod only after we have written the new content.
|
||||
// This will happen later. Set these values to 0 for know.
|
||||
DirCacheEntry e = add(tw.getRawPath(), theirs,
|
||||
DirCacheEntry.STAGE_0, EPOCH, 0);
|
||||
addToCheckout(tw.getPathString(), e, attributes);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
// same content but different mode on OURS and THEIRS.
|
||||
// Try to merge the mode and report an error if this is
|
||||
// not possible.
|
||||
int newMode = mergeFileModes(modeB, modeO, modeT);
|
||||
if (newMode != FileMode.MISSING.getBits()) {
|
||||
if (newMode == modeO) {
|
||||
// ours version is preferred
|
||||
keep(ourDce);
|
||||
} else {
|
||||
// FileModes are not mergeable. We found a conflict on modes.
|
||||
// For conflicting entries we don't know lastModified and length.
|
||||
add(tw.getRawPath(), base, DirCacheEntry.STAGE_1, EPOCH, 0);
|
||||
add(tw.getRawPath(), ours, DirCacheEntry.STAGE_2, EPOCH, 0);
|
||||
add(tw.getRawPath(), theirs, DirCacheEntry.STAGE_3, EPOCH,
|
||||
0);
|
||||
unmergedPaths.add(tw.getPathString());
|
||||
mergeResults.put(
|
||||
tw.getPathString(),
|
||||
new MergeResult<>(Collections
|
||||
.<RawText> emptyList()));
|
||||
// the preferred version THEIRS has a different mode
|
||||
// than ours. Check it out!
|
||||
if (isWorktreeDirty(work, ourDce)) {
|
||||
return false;
|
||||
}
|
||||
// we know about length and lastMod only after we have
|
||||
// written the new content.
|
||||
// This will happen later. Set these values to 0 for know.
|
||||
DirCacheEntry e = add(tw.getRawPath(), theirs,
|
||||
DirCacheEntry.STAGE_0, EPOCH, 0);
|
||||
addToCheckout(tw.getPathString(), e, attributes);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
// FileModes are not mergeable. We found a conflict on modes.
|
||||
// For conflicting entries we don't know lastModified and
|
||||
// length.
|
||||
add(tw.getRawPath(), base, DirCacheEntry.STAGE_1, EPOCH, 0);
|
||||
add(tw.getRawPath(), ours, DirCacheEntry.STAGE_2, EPOCH, 0);
|
||||
add(tw.getRawPath(), theirs, DirCacheEntry.STAGE_3, EPOCH, 0);
|
||||
unmergedPaths.add(tw.getPathString());
|
||||
mergeResults.put(tw.getPathString(),
|
||||
new MergeResult<>(Collections.<RawText> emptyList()));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (modeB == modeT && tw.idEqual(T_BASE, T_THEIRS)) {
|
||||
|
@ -716,21 +714,20 @@ protected boolean processEntry(CanonicalTreeParser base,
|
|||
addToCheckout(tw.getPathString(), e, attributes);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
// we want THEIRS ... but THEIRS contains a folder or the
|
||||
// deletion of the path. Delete what's in the working tree,
|
||||
// which we know to be clean.
|
||||
if (tw.getTreeCount() > T_FILE && tw.getRawMode(T_FILE) == 0) {
|
||||
// Not present in working tree, so nothing to delete
|
||||
return true;
|
||||
}
|
||||
if (modeT != 0 && modeT == modeB) {
|
||||
// Base, ours, and theirs all contain a folder: don't delete
|
||||
return true;
|
||||
}
|
||||
addDeletion(tw.getPathString(), nonTree(modeO), attributes);
|
||||
}
|
||||
// we want THEIRS ... but THEIRS contains a folder or the
|
||||
// deletion of the path. Delete what's in the working tree,
|
||||
// which we know to be clean.
|
||||
if (tw.getTreeCount() > T_FILE && tw.getRawMode(T_FILE) == 0) {
|
||||
// Not present in working tree, so nothing to delete
|
||||
return true;
|
||||
}
|
||||
if (modeT != 0 && modeT == modeB) {
|
||||
// Base, ours, and theirs all contain a folder: don't delete
|
||||
return true;
|
||||
}
|
||||
addDeletion(tw.getPathString(), nonTree(modeO), attributes);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (tw.isSubtree()) {
|
||||
|
@ -1310,10 +1307,9 @@ protected boolean mergeTrees(AbstractTreeIterator baseTree,
|
|||
if (getUnmergedPaths().isEmpty() && !failed()) {
|
||||
resultTree = dircache.writeTree(getObjectInserter());
|
||||
return true;
|
||||
} else {
|
||||
resultTree = null;
|
||||
return false;
|
||||
}
|
||||
resultTree = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -143,17 +143,17 @@ public ObjectId getBaseCommitId() {
|
|||
* @throws java.io.IOException
|
||||
*/
|
||||
protected AbstractTreeIterator mergeBase() throws IOException {
|
||||
if (baseTree != null)
|
||||
if (baseTree != null) {
|
||||
return openTree(baseTree);
|
||||
}
|
||||
RevCommit baseCommit = (baseCommitId != null) ? walk
|
||||
.parseCommit(baseCommitId) : getBaseCommit(sourceCommits[0],
|
||||
sourceCommits[1]);
|
||||
if (baseCommit == null) {
|
||||
baseCommitId = null;
|
||||
return new EmptyTreeIterator();
|
||||
} else {
|
||||
baseCommitId = baseCommit.toObjectId();
|
||||
return openTree(baseCommit.getTree());
|
||||
}
|
||||
baseCommitId = baseCommit.toObjectId();
|
||||
return openTree(baseCommit.getTree());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -167,10 +167,10 @@ public boolean hasNext() {
|
|||
|
||||
@Override
|
||||
public Note next() {
|
||||
if (hasNext())
|
||||
if (hasNext()) {
|
||||
return itr.next();
|
||||
else
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -214,30 +214,31 @@ InMemoryNoteBucket set(AnyObjectId noteOn, AnyObjectId noteData,
|
|||
NoteBucket b = table[cell];
|
||||
|
||||
if (b == null) {
|
||||
if (noteData == null)
|
||||
if (noteData == null) {
|
||||
return this;
|
||||
}
|
||||
|
||||
LeafBucket n = new LeafBucket(prefixLen + 2);
|
||||
table[cell] = n.set(noteOn, noteData, or);
|
||||
cnt++;
|
||||
return this;
|
||||
|
||||
} else {
|
||||
NoteBucket n = b.set(noteOn, noteData, or);
|
||||
if (n == null) {
|
||||
table[cell] = null;
|
||||
cnt--;
|
||||
|
||||
if (cnt == 0)
|
||||
return null;
|
||||
|
||||
return contractIfTooSmall(noteOn, or);
|
||||
|
||||
} else if (n != b) {
|
||||
table[cell] = n;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
NoteBucket n = b.set(noteOn, noteData, or);
|
||||
if (n == null) {
|
||||
table[cell] = null;
|
||||
cnt--;
|
||||
|
||||
if (cnt == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return contractIfTooSmall(noteOn, or);
|
||||
|
||||
} else if (n != b) {
|
||||
table[cell] = n;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
InMemoryNoteBucket contractIfTooSmall(AnyObjectId noteOn, ObjectReader or)
|
||||
|
|
|
@ -129,10 +129,10 @@ public boolean hasNext() {
|
|||
|
||||
@Override
|
||||
public Note next() {
|
||||
if (hasNext())
|
||||
if (hasNext()) {
|
||||
return notes[idx++];
|
||||
else
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -156,25 +156,23 @@ InMemoryNoteBucket set(AnyObjectId noteOn, AnyObjectId noteData,
|
|||
notes[p].setData(noteData.copy());
|
||||
return this;
|
||||
|
||||
} else {
|
||||
System.arraycopy(notes, p + 1, notes, p, cnt - p - 1);
|
||||
cnt--;
|
||||
return 0 < cnt ? this : null;
|
||||
}
|
||||
System.arraycopy(notes, p + 1, notes, p, cnt - p - 1);
|
||||
cnt--;
|
||||
return 0 < cnt ? this : null;
|
||||
|
||||
} else if (noteData != null) {
|
||||
if (shouldSplit()) {
|
||||
return split().set(noteOn, noteData, or);
|
||||
|
||||
} else {
|
||||
growIfFull();
|
||||
p = -(p + 1);
|
||||
if (p < cnt)
|
||||
System.arraycopy(notes, p, notes, p + 1, cnt - p);
|
||||
notes[p] = new Note(noteOn, noteData.copy());
|
||||
cnt++;
|
||||
return this;
|
||||
}
|
||||
growIfFull();
|
||||
p = -(p + 1);
|
||||
if (p < cnt) {
|
||||
System.arraycopy(notes, p, notes, p + 1, cnt - p);
|
||||
}
|
||||
notes[p] = new Note(noteOn, noteData.copy());
|
||||
cnt++;
|
||||
return this;
|
||||
|
||||
} else {
|
||||
return this;
|
||||
|
@ -234,12 +232,10 @@ void parseOneEntry(AnyObjectId noteOn, AnyObjectId noteData) {
|
|||
InMemoryNoteBucket append(Note note) {
|
||||
if (shouldSplit()) {
|
||||
return split().append(note);
|
||||
|
||||
} else {
|
||||
growIfFull();
|
||||
notes[cnt++] = note;
|
||||
return this;
|
||||
}
|
||||
growIfFull();
|
||||
notes[cnt++] = note;
|
||||
return this;
|
||||
}
|
||||
|
||||
private void growIfFull() {
|
||||
|
|
|
@ -278,10 +278,10 @@ public boolean contains(AnyObjectId id) throws IOException {
|
|||
public byte[] getCachedBytes(AnyObjectId id, int sizeLimit)
|
||||
throws LargeObjectException, MissingObjectException, IOException {
|
||||
ObjectId dataId = get(id);
|
||||
if (dataId != null)
|
||||
if (dataId != null) {
|
||||
return reader.open(dataId).getCachedBytes(sizeLimit);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -307,10 +307,10 @@ private static boolean sameContent(Note a, Note b) {
|
|||
|
||||
private static InMemoryNoteBucket addIfNotNull(InMemoryNoteBucket result,
|
||||
Note note) {
|
||||
if (note != null)
|
||||
if (note != null) {
|
||||
return result.append(note);
|
||||
else
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private NonNoteEntry mergeNonNotes(NonNoteEntry baseList,
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue