Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Align the native git status lists with standard git #133

Merged
merged 1 commit into from Jun 23, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -259,21 +259,18 @@ public void load() throws GitException {
conflicting = new ArrayList<>();
for (String statusLine : statusOutput) {
//add conflict files AA, UU, any of U
addIfMatches(conflicting, statusLine, 'A', 'A');
addIfMatches(conflicting, statusLine, 'U', '*');
addIfMatches(conflicting, statusLine, '*', 'U');
//add Added files
addIfMatches(added, statusLine, 'A', 'M');
addIfMatches(added, statusLine, 'A', ' ');
//add Changed
addIfMatches(changed, statusLine, 'M', '*');
//add removed
addIfMatches(removed, statusLine, 'D', '*');
addIfMatches(removed, statusLine, ' ', 'D');
//add missing
addIfMatches(missing, statusLine, 'A', 'D');
//add modified
addIfMatches(modified, statusLine, '*', 'M');
if (!(addIfMatches(conflicting, statusLine, 'A', 'A') //
|| addIfMatches(conflicting, statusLine, 'D', 'D') //
|| addIfMatches(conflicting, statusLine, 'U', '*') //
|| addIfMatches(conflicting, statusLine, '*', 'U'))) {
// Add index-based entries
addIfMatches(added, statusLine, 'A', '*');
addIfMatches(removed, statusLine, 'D', '*');
addIfMatches(changed, statusLine, 'M', '*');
// Add working tree - based entries
addIfMatches(missing, statusLine, '*', 'D');
addIfMatches(modified, statusLine, '*', 'M');
}
if (statusLine.endsWith("/")) {
//add untracked folders
addIfMatches(untrackedFolders, statusLine.substring(0, statusLine.length() - 1), '?', '?');
Expand All @@ -297,18 +294,19 @@ public void load() throws GitException {
* @param y
* second template parameter
*/
private void addIfMatches(List<String> container, String statusLine, char x, char y) {
private static boolean addIfMatches(List<String> container, String statusLine, char x, char y) {
if (matches(statusLine, x, y)) {
final String filename = statusLine.substring(3);
if (!container.contains(filename)) {
container.add(filename);
}
return true;
}
return false;
}

private boolean matches(String statusLine, char x, char y) {
return x == '*' && statusLine.charAt(1) == y ||
y == '*' && statusLine.charAt(0) == x ||
x == statusLine.charAt(0) && y == statusLine.charAt(1);
private static boolean matches(String statusLine, char x, char y) {
return (x == '*' || x == statusLine.charAt(0)) &&
(y == '*' || y == statusLine.charAt(1));
}
}
Expand Up @@ -185,7 +185,7 @@ public void testMissing() throws Exception {
final Status status = getConnection().status(SHORT);

assertEquals(status.getMissing(), asList("a"));
assertTrue(status.getAdded().isEmpty());
assertEquals(status.getAdded(), asList("a"));
assertTrue(status.getChanged().isEmpty());
assertTrue(status.getConflicting().isEmpty());
assertTrue(status.getRemoved().isEmpty());
Expand All @@ -206,11 +206,11 @@ public void testRemovedFromFilesSystem() throws Exception {

final Status status = getConnection().status(SHORT);

assertEquals(status.getRemoved(), asList("a"));
assertTrue(status.getRemoved().isEmpty());
assertTrue(status.getAdded().isEmpty());
assertTrue(status.getChanged().isEmpty());
assertTrue(status.getConflicting().isEmpty());
assertTrue(status.getMissing().isEmpty());
assertEquals(status.getMissing(), asList("a"));
assertTrue(status.getUntracked().isEmpty());
assertTrue(status.getUntrackedFolders().isEmpty());
}
Expand Down