if (paths == null) {
paths = new JSONArray().put(pattern.isEmpty() ? ADD_ALL_PATTERN : pattern);
}
Git git = new Git(db);
AddCommand add = git.add();
for (int i = 0; i < paths.length(); i++) {
add.addFilepattern(paths.getString(i));
}
// "git add {pattern}"
try {
add.call();
} catch (GitAPIException e) {
return statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage(),
e));
}
// TODO: we're calling "add" twice, this is inefficient, see bug 349299
// "git add -u {pattern}"
add = git.add().setUpdate(true);
for (int i = 0; i < paths.length(); i++) {
add.addFilepattern(paths.getString(i));
}
try {
add.call();
} catch (GitAPIException e) {
return statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage(),
e));
}
return true;