pgm: Fix missing braces in Commit.run()

Change-Id: Ia9e7e846ba1abfdb490896e5bcb82e2c0039439c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
Matthias Sohn 2019-01-20 01:30:24 +01:00
parent 3b059f6ff6
commit 637f95b935
1 changed files with 16 additions and 9 deletions

View File

@ -89,10 +89,12 @@ class Commit extends TextBuiltin {
protected void run() { protected void run() {
try (Git git = new Git(db)) { try (Git git = new Git(db)) {
CommitCommand commitCmd = git.commit(); CommitCommand commitCmd = git.commit();
if (author != null) if (author != null) {
commitCmd.setAuthor(RawParseUtils.parsePersonIdent(author)); commitCmd.setAuthor(RawParseUtils.parsePersonIdent(author));
if (message != null) }
if (message != null) {
commitCmd.setMessage(message); commitCmd.setMessage(message);
}
if (noGpgSign) { if (noGpgSign) {
commitCmd.setSign(Boolean.FALSE); commitCmd.setSign(Boolean.FALSE);
} else if (gpgSigningKey != null) { } else if (gpgSigningKey != null) {
@ -101,13 +103,17 @@ protected void run() {
commitCmd.setSigningKey(gpgSigningKey); commitCmd.setSigningKey(gpgSigningKey);
} }
} }
if (only && paths.isEmpty()) if (only && paths.isEmpty()) {
throw die(CLIText.get().pathsRequired); throw die(CLIText.get().pathsRequired);
if (only && all) }
if (only && all) {
throw die(CLIText.get().onlyOneOfIncludeOnlyAllInteractiveCanBeUsed); throw die(CLIText.get().onlyOneOfIncludeOnlyAllInteractiveCanBeUsed);
if (!paths.isEmpty()) }
for (String p : paths) if (!paths.isEmpty()) {
for (String p : paths) {
commitCmd.setOnly(p); commitCmd.setOnly(p);
}
}
commitCmd.setAmend(amend); commitCmd.setAmend(amend);
commitCmd.setAll(all); commitCmd.setAll(all);
Ref head = db.exactRef(Constants.HEAD); Ref head = db.exactRef(Constants.HEAD);
@ -122,13 +128,14 @@ protected void run() {
} }
String branchName; String branchName;
if (!head.isSymbolic()) if (!head.isSymbolic()) {
branchName = CLIText.get().branchDetachedHEAD; branchName = CLIText.get().branchDetachedHEAD;
else { } else {
branchName = head.getTarget().getName(); branchName = head.getTarget().getName();
if (branchName.startsWith(Constants.R_HEADS)) if (branchName.startsWith(Constants.R_HEADS)) {
branchName = branchName.substring(Constants.R_HEADS.length()); branchName = branchName.substring(Constants.R_HEADS.length());
} }
}
outw.println("[" + branchName + " " + commit.name() + "] " //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ outw.println("[" + branchName + " " + commit.name() + "] " //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ commit.getShortMessage()); + commit.getShortMessage());
} catch (IOException e) { } catch (IOException e) {