From c466809a09d835a35eaac4ed6254655854659bbd Mon Sep 17 00:00:00 2001 From: Georg Seibt <seibt@fim.uni-passau.de> Date: Wed, 26 Oct 2016 11:03:24 +0200 Subject: [PATCH] add options to include ignored/untracked files --- .../fim/seibt/gitwrapper/repo/Repository.java | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/de/uni_passau/fim/seibt/gitwrapper/repo/Repository.java b/src/de/uni_passau/fim/seibt/gitwrapper/repo/Repository.java index c544a13..fa585f9 100644 --- a/src/de/uni_passau/fim/seibt/gitwrapper/repo/Repository.java +++ b/src/de/uni_passau/fim/seibt/gitwrapper/repo/Repository.java @@ -552,14 +552,37 @@ public class Repository { return Optional.of(conflicts); } + /** + * Parses and returns the current output of 'git status' for this {@link Repository}. This includes untracked files + * but excludes ignored files. If there is an exception parsing or obtaining the status output, an empty + * {@link Optional} will be returned. + * + * @return optionally the {@link Status} of this {@link Repository} + */ + public Optional<Status> getStatus() { + return getStatus(false, true); + } + /** * Parses and returns the current output of 'git status' for this {@link Repository}. * If there is an exception parsing or obtaining the status output, an empty {@link Optional} will be returned. * + * @param ignored + * whether to include ignored files in the {@link Status} + * @param untracked + * whether to include untracked files in the {@link Status} * @return optionally the {@link Status} of this {@link Repository} */ - public Optional<Status> getStatus() { - Optional<ExecRes> output = git.exec(dir, "status", "-z"); + public Optional<Status> getStatus(boolean ignored, boolean untracked) { + Optional<ExecRes> output; + String untrackedPar = "--untracked=" + (untracked ? "all" : "no"); + + if (ignored) { + output = git.exec(dir, "status", untrackedPar, "--ignored", "-z"); + } else { + output = git.exec(dir, "status", untrackedPar, "-z"); + } + Function<ExecRes, Optional<Status>> toStatus = execRes -> { if (git.failed(execRes)) { -- GitLab