diff options
author | Andrey Loskutov <loskutov@gmx.de> | 2016-01-03 16:15:34 +0100 |
---|---|---|
committer | Andrey Loskutov <loskutov@gmx.de> | 2016-01-06 17:27:15 -0500 |
commit | fb5056c2c5e96b815abe568af588157083c66197 (patch) | |
tree | 9b23312d5405f590f26d95925e42babba59787b4 /org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm | |
parent | 24468f09e3fb991ea5a6af293f84c7fe37e78b95 (diff) | |
download | jgit-fb5056c2c5e96b815abe568af588157083c66197.tar.gz jgit-fb5056c2c5e96b815abe568af588157083c66197.zip |
branch command: print help if requested, even if arguments are wrong
git branch -d -h reports an error (because of missing -d option value)
but does not print the help as expected.
To fix this, CmdLineParser must catch, print but do not propagate
exceptions if help is requested.
Bug: 484951
Change-Id: I51265ebe295f22da540792c6a1980b8bdb295a02
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
Diffstat (limited to 'org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm')
-rw-r--r-- | org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/BranchTest.java | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/BranchTest.java b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/BranchTest.java index 74506bc944..f1a53d7dcc 100644 --- a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/BranchTest.java +++ b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/BranchTest.java @@ -53,6 +53,7 @@ import org.eclipse.jgit.api.Git; import org.eclipse.jgit.lib.CLIRepositoryTestCase; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.RefUpdate; +import org.eclipse.jgit.pgm.internal.CLIText; import org.eclipse.jgit.revwalk.RevCommit; import org.junit.Before; import org.junit.Test; @@ -66,6 +67,15 @@ public class BranchTest extends CLIRepositoryTestCase { } @Test + public void testHelpAfterDelete() throws Exception { + String err = toString(executeUnchecked("git branch -d")); + String help = toString(executeUnchecked("git branch -h")); + String errAndHelp = toString(executeUnchecked("git branch -d -h")); + assertEquals(CLIText.fatalError(CLIText.get().branchNameRequired), err); + assertEquals(toString(err, help), errAndHelp); + } + + @Test public void testList() throws Exception { assertEquals("* master", toString(execute("git branch"))); assertEquals("* master 6fd41be initial commit", |