Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 340679

Summary: JGit pgm should extract usage of System.exit() into a Main class wrapper to enable embedding
Product: [Technology] JGit Reporter: Lincoln Baxter, III <lincolnbaxter>
Component: JGitAssignee: Project Inbox <jgit.core-inbox>
Status: RESOLVED WONTFIX QA Contact:
Severity: enhancement    
Priority: P3 CC: caniszczyk, sop
Version: 0.12   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Lincoln Baxter, III CLA 2011-03-22 12:24:34 EDT
Build Identifier: 

It is currently impossible to use JGit PGM in embedded java applications because of the use of System.exit() in pgm class files.

For example:...



	protected void parseArguments(final String[] args) {
		final CmdLineParser clp = new CmdLineParser(this);
		try {
			clp.parseArgument(args);
		} catch (CmdLineException err) {
			if (!help) {
				System.err.println(MessageFormat.format(CLIText.get().fatalError, err.getMessage()));
				System.exit(1);
			}
		}
        ...
        }

Reproducible: Always

Steps to Reproduce:
1. Run Main.main(args...) with a bad git command
2. JVM exits, which is unrecoverable
Comment 1 Chris Aniszczyk CLA 2011-03-22 12:25:58 EDT
We'd love contributions!

http://wiki.eclipse.org/EGit/Contributor_Guide
Comment 2 Shawn Pearce CLA 2011-05-16 10:34:49 EDT
Use the api package, not the pgm package. The api package offers about the same usage, but is designed to be run from your own application code.