Skip to content

Commit

Permalink
Remove the logging we used to show that the test was exhaustive (wish…
Browse files Browse the repository at this point in the history
… we could do code-coverage on all tests, including testkit integration tests)
  • Loading branch information
nedtwigg committed May 31, 2020
1 parent 87e466f commit eac82d2
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ public static boolean isClean(Project project, ObjectId treeSha, File file) thro
Repository repo = instance.repositoryFor(project);
String path = repo.getWorkTree().toPath().relativize(file.toPath()).toString();

System.out.print("isClean " + path + " ");
// TODO: should be cached-per-repo if it is thread-safe, or per-repo-per-thread if it is not
DirCache dirCache = repo.readDirCache();

Expand All @@ -75,7 +74,6 @@ public static boolean isClean(Project project, ObjectId treeSha, File file) thro
new IndexDiffFilter(INDEX, WORKDIR)));

if (!treeWalk.next()) {
System.out.println("A yes");
// the file we care about is git clean
return true;
} else {
Expand All @@ -88,29 +86,24 @@ public static boolean isClean(Project project, ObjectId treeSha, File file) thro

if (!hasTree) {
// it's not in the tree, so it was added
System.out.println("B no");
return false;
} else {
if (hasDirCache) {
boolean treeEqualsIndex = treeIterator.idEqual(dirCacheIterator) && treeIterator.getEntryRawMode() == dirCacheIterator.getEntryRawMode();
boolean indexEqualsWC = !workingTreeIterator.isModified(dirCacheIterator.getDirCacheEntry(), true, treeWalk.getObjectReader());
if (treeEqualsIndex != indexEqualsWC) {
// if one is equal and the other isn't, then it has definitely changed
System.out.println("C no");
return false;
} else if (treeEqualsIndex) {
System.out.println("D yes"); // NEED
// this means they are all equal to each other, which should never happen
// the IndexDiffFilter should keep those out of the TreeWalk entirely
throw new IllegalStateException("Index status for " + file + " against treeSha " + treeSha + " is invalid.");
} else {
// they are all unique
System.out.print("E ");
// we have to check manually
return worktreeIsCleanCheckout(treeWalk);
}
} else {
System.out.print("F ");
// no dirCache, so we will compare the tree to the workdir manually
return worktreeIsCleanCheckout(treeWalk);
}
Expand All @@ -121,9 +114,7 @@ public static boolean isClean(Project project, ObjectId treeSha, File file) thro

/** Returns true if the worktree file is a clean checkout of head (possibly smudged). */
private static boolean worktreeIsCleanCheckout(TreeWalk treeWalk) {
boolean result = treeWalk.idEqual(TREE, WORKDIR);
System.out.println(result ? "yes" : "no");
return result;
return treeWalk.idEqual(TREE, WORKDIR);
}

private final static int TREE = 0;
Expand Down Expand Up @@ -202,7 +193,6 @@ public static ObjectId treeShaOf(Project project, String reference) {
}
instance.shaCache.put(repo, reference, treeSha);
}
System.out.println("treeSha of " + reference + " is " + treeSha);
return treeSha;
} catch (Exception e) {
throw Errors.asRuntime(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ public File toLines(String... lines) throws IOException {
}

public File toContent(String content) throws IOException {
System.out.print("toContent(" + content + ") ");
return toContent(content, StandardCharsets.UTF_8);
}

Expand Down

0 comments on commit eac82d2

Please sign in to comment.