Replace "size() > 0" with "!isEmpty()" where appropriate. In the Status implementation we can drop the check; the subsequent loop will only execute when the list is non-empty anyway. Change-Id: I355aff551a603373e702a9d44304f087b476263c Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>tags/v5.4.0.201906121030-r
@Override | @Override | ||||
Body process() throws IOException { | Body process() throws IOException { | ||||
Response.Body body = new Response.Body(); | Response.Body body = new Response.Body(); | ||||
if (objects.size() > 0) { | |||||
if (!objects.isEmpty()) { | |||||
body.objects = new ArrayList<>(); | body.objects = new ArrayList<>(); | ||||
for (LfsObject o : objects) { | for (LfsObject o : objects) { | ||||
addObjectInfo(body, o); | addObjectInfo(body, o); | ||||
@Override | @Override | ||||
Body process() throws IOException { | Body process() throws IOException { | ||||
Response.Body body = new Response.Body(); | Response.Body body = new Response.Body(); | ||||
if (objects.size() > 0) { | |||||
if (!objects.isEmpty()) { | |||||
body.objects = new ArrayList<>(); | body.objects = new ArrayList<>(); | ||||
for (LfsObject o : objects) { | for (LfsObject o : objects) { | ||||
addObjectInfo(body, o); | addObjectInfo(body, o); |
try (Git git = new Git(db)) { | try (Git git = new Git(db)) { | ||||
CheckoutCommand command = git.checkout() | CheckoutCommand command = git.checkout() | ||||
.setProgressMonitor(new TextProgressMonitor(errw)); | .setProgressMonitor(new TextProgressMonitor(errw)); | ||||
if (paths.size() > 0) { | |||||
if (!paths.isEmpty()) { | |||||
command.setStartPoint(name); | command.setStartPoint(name); | ||||
if (paths.size() == 1 && paths.get(0).equals(".")) { //$NON-NLS-1$ | if (paths.size() == 1 && paths.get(0).equals(".")) { //$NON-NLS-1$ | ||||
command.setAllPaths(true); | command.setAllPaths(true); |
CanonicalTreeParser p = new CanonicalTreeParser(); | CanonicalTreeParser p = new CanonicalTreeParser(); | ||||
p.reset(rw.getObjectReader(), c.getTree()); | p.reset(rw.getObjectReader(), c.getTree()); | ||||
tw.reset(); // drop the first empty tree, which we do not need here | tw.reset(); // drop the first empty tree, which we do not need here | ||||
if (paths.size() > 0) { | |||||
if (!paths.isEmpty()) { | |||||
tw.setFilter(PathFilterGroup.createFromStrings(paths)); | tw.setFilter(PathFilterGroup.createFromStrings(paths)); | ||||
} | } | ||||
tw.addTree(p); | tw.addTree(p); |
protected void run() { | protected void run() { | ||||
try (TreeWalk walk = new TreeWalk(db)) { | try (TreeWalk walk = new TreeWalk(db)) { | ||||
walk.reset(); // drop the first empty tree, which we do not need here | walk.reset(); // drop the first empty tree, which we do not need here | ||||
if (paths.size() > 0) { | |||||
if (!paths.isEmpty()) { | |||||
walk.setFilter(PathFilterGroup.createFromStrings(paths)); | walk.setFilter(PathFilterGroup.createFromStrings(paths)); | ||||
} | } | ||||
walk.setRecursive(recursive); | walk.setRecursive(recursive); |
try (Git git = new Git(db)) { | try (Git git = new Git(db)) { | ||||
ResetCommand command = git.reset(); | ResetCommand command = git.reset(); | ||||
command.setRef(commit); | command.setRef(commit); | ||||
if (paths.size() > 0) { | |||||
if (!paths.isEmpty()) { | |||||
for (String path : paths) { | for (String path : paths) { | ||||
command.addPath(path); | command.addPath(path); | ||||
} | } |
protected void run() { | protected void run() { | ||||
try (Git git = new Git(db)) { | try (Git git = new Git(db)) { | ||||
StatusCommand statusCommand = git.status(); | StatusCommand statusCommand = git.status(); | ||||
if (filterPaths != null && filterPaths.size() > 0) { | |||||
if (filterPaths != null) { | |||||
for (String path : filterPaths) { | for (String path : filterPaths) { | ||||
statusCommand.addPath(path); | statusCommand.addPath(path); | ||||
} | } |
StatusCommand command = git.status(); | StatusCommand command = git.status(); | ||||
Status status = command.call(); | Status status = command.call(); | ||||
Set<String> files = status.getUntracked(); | Set<String> files = status.getUntracked(); | ||||
assertTrue(files.size() > 0); | |||||
assertFalse(files.isEmpty()); | |||||
// run clean | // run clean | ||||
Set<String> cleanedFiles = git.clean().call(); | Set<String> cleanedFiles = git.clean().call(); | ||||
StatusCommand command = git.status(); | StatusCommand command = git.status(); | ||||
Status status = command.call(); | Status status = command.call(); | ||||
Set<String> files = status.getUntracked(); | Set<String> files = status.getUntracked(); | ||||
assertTrue(files.size() > 0); | |||||
assertFalse(files.isEmpty()); | |||||
// run clean | // run clean | ||||
Set<String> cleanedFiles = git.clean().setCleanDirectories(true).call(); | Set<String> cleanedFiles = git.clean().setCleanDirectories(true).call(); | ||||
StatusCommand command = git.status(); | StatusCommand command = git.status(); | ||||
Status status = command.call(); | Status status = command.call(); | ||||
Set<String> files = status.getUntracked(); | Set<String> files = status.getUntracked(); | ||||
assertTrue(files.size() > 0); | |||||
assertFalse(files.isEmpty()); | |||||
// run clean with setPaths | // run clean with setPaths | ||||
Set<String> paths = new TreeSet<>(); | Set<String> paths = new TreeSet<>(); | ||||
StatusCommand command = git.status(); | StatusCommand command = git.status(); | ||||
Status status = command.call(); | Status status = command.call(); | ||||
Set<String> files = status.getUntracked(); | Set<String> files = status.getUntracked(); | ||||
assertTrue(files.size() > 0); | |||||
assertFalse(files.isEmpty()); | |||||
// run clean | // run clean | ||||
Set<String> cleanedFiles = git.clean().setDryRun(true).call(); | Set<String> cleanedFiles = git.clean().setDryRun(true).call(); | ||||
StatusCommand command = git.status(); | StatusCommand command = git.status(); | ||||
Status status = command.call(); | Status status = command.call(); | ||||
Set<String> files = status.getUntracked(); | Set<String> files = status.getUntracked(); | ||||
assertTrue(files.size() > 0); | |||||
assertFalse(files.isEmpty()); | |||||
// run clean | // run clean | ||||
Set<String> cleanedFiles = git.clean().setDryRun(true) | Set<String> cleanedFiles = git.clean().setDryRun(true) |
@Override | @Override | ||||
public Iterable<RevCommit> call() throws GitAPIException, NoHeadException { | public Iterable<RevCommit> call() throws GitAPIException, NoHeadException { | ||||
checkCallable(); | checkCallable(); | ||||
if (pathFilters.size() > 0) | |||||
if (!pathFilters.isEmpty()) | |||||
walk.setTreeFilter(AndTreeFilter.create( | walk.setTreeFilter(AndTreeFilter.create( | ||||
PathFilterGroup.create(pathFilters), TreeFilter.ANY_DIFF)); | PathFilterGroup.create(pathFilters), TreeFilter.ANY_DIFF)); | ||||
if (skip > -1 && maxCount > -1) | if (skip > -1 && maxCount > -1) |
resetSoftToParent(); | resetSoftToParent(); | ||||
List<RebaseTodoLine> steps = repo.readRebaseTodo( | List<RebaseTodoLine> steps = repo.readRebaseTodo( | ||||
rebaseState.getPath(GIT_REBASE_TODO), false); | rebaseState.getPath(GIT_REBASE_TODO), false); | ||||
RebaseTodoLine nextStep = steps.size() > 0 ? steps.get(0) : null; | |||||
RebaseTodoLine nextStep = steps.isEmpty() ? null : steps.get(0); | |||||
File messageFixupFile = rebaseState.getFile(MESSAGE_FIXUP); | File messageFixupFile = rebaseState.getFile(MESSAGE_FIXUP); | ||||
File messageSquashFile = rebaseState.getFile(MESSAGE_SQUASH); | File messageSquashFile = rebaseState.getFile(MESSAGE_SQUASH); | ||||
if (isSquash && messageFixupFile.exists()) | if (isSquash && messageFixupFile.exists()) | ||||
repo.writeRebaseTodoFile(rebaseState.getPath(GIT_REBASE_TODO), | repo.writeRebaseTodoFile(rebaseState.getPath(GIT_REBASE_TODO), | ||||
todoLines, false); | todoLines, false); | ||||
if (poppedLines.size() > 0) { | |||||
if (!poppedLines.isEmpty()) { | |||||
repo.writeRebaseTodoFile(rebaseState.getPath(DONE), poppedLines, | repo.writeRebaseTodoFile(rebaseState.getPath(DONE), poppedLines, | ||||
true); | true); | ||||
} | } |
* otherwise | * otherwise | ||||
*/ | */ | ||||
public boolean failed() { | public boolean failed() { | ||||
return failingPaths.size() > 0; | |||||
return !failingPaths.isEmpty(); | |||||
} | } | ||||
/** | /** |
exc.add(r.getId()); | exc.add(r.getId()); | ||||
packWriter.setIndexDisabled(true); | packWriter.setIndexDisabled(true); | ||||
packWriter.setDeltaBaseAsOffset(true); | packWriter.setDeltaBaseAsOffset(true); | ||||
packWriter.setThin(exc.size() > 0); | |||||
packWriter.setThin(!exc.isEmpty()); | |||||
packWriter.setReuseValidatingObjects(false); | packWriter.setReuseValidatingObjects(false); | ||||
if (exc.isEmpty()) { | if (exc.isEmpty()) { | ||||
packWriter.setTagTargets(tagTargets); | packWriter.setTagTargets(tagTargets); |