Skip to content

Commit

Permalink
Align the native git status lists with standard git
Browse files Browse the repository at this point in the history
Signed-off-by: Tareq Sharafy <tareq.sharafy@sap.com>
  • Loading branch information
tareksha committed Jun 1, 2015
1 parent d2cd4ff commit 4cc1476
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
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,13 +294,15 @@ public void load() throws GitException {
* @param y
* second template parameter
*/
private void addIfMatches(List<String> container, String statusLine, char x, char y) {
private 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) {
Expand Down
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

0 comments on commit 4cc1476

Please sign in to comment.