Skip to main content
AgeCommit message (Collapse)AuthorFilesLines
2017-12-21Fix remaining javadoc errors raised by doclintMatthias Sohn1-2/+4
For now ignore doclint "missing" warnings. Change-Id: I0e5af7a757f4d92ffeeb113f30576a35414d6781 Signed-off-by: Matthias Sohn <>
2017-12-07ArchiveTest: Check result of BufferedInputStream#skipDavid Pursehouse1-1/+5
Change-Id: I5168c75ca2dda6d1e8c8a6c29043ac781fe9295a Signed-off-by: David Pursehouse <>
2017-10-01Checkout now reports failures through exceptions.Ned Twigg1-3/+21
Checkout sometimes throws an exception, and other times it writes an error message to outw and returns normally, even though the command failed. This commit now reports all failures through a die() exception. Change-Id: I038a5d976d95020fea3faac68e9178f923c25b28 Signed-off-by: Ned Twigg <>
2017-09-21Added API to TextBuiltin for piped usage.Ned Twigg1-0/+110
Added a public method to TextBuiltin which makes it possible for clients to initialize all of its state, including output and error streams. This gives clients the ability to customize the way in which a command is run. Change-Id: If718236964d2c5cf869e120c74f1a12965f4812e Signed-off-by: Ned Twigg <>
2017-08-30Update args4j to 2.33Matthias Sohn2-2/+2
CQ: 11068 Change-Id: I7d52cddacff05477f646fda5f7b9f2de844922f6 Signed-off-by: Matthias Sohn <> Signed-off-by: David Pursehouse <>
2017-08-30Fix compilation errors with args4j 2.0.23 and laterRobin Stocker1-0/+80
The multiValued attribute on @Option was removed. When the field is a List, it's not actually needed (even with earlier versions of args4j), see RmTest. In other cases, we have a custom handler, where it's also not needed. Bug: 413163 Change-Id: I4bb951e9fab5f4ae4271bd7e11be799dc234ab80
2017-07-25Add missing newlines at ends of Java filesDavid Pursehouse1-1/+1
Change-Id: Iead36f53d57ead0eb3edd3f9efb63b6630c9c20c Signed-off-by: David Pursehouse <>
2017-06-22Add --match option for `jgit describe` to CLIOliver Lockwood1-3/+49
This adds --match option for glob(7) matchers on git tags to jgit describe in CLI. Bug: 518377 Change-Id: I745988d565dd4391e8b3e5a91bbfbae575333819 Signed-off-by: Oliver Lockwood <>
2017-06-05ArchiveCommand: Create prefix entry with commit timeYasuhiro Takagi1-4/+4
The cgit archive command creates a prefix (root) directory entry in the archive file. That entry's time is set to the commit time. This patch makes jgit's behavior consistent with with cgit: prefix: hoge/ -> creates prefix directory "hoge/" entry. prefix: hoge//// -> creates prefix directory "hoge/" entry. prefix: hoge/foo -> does not create prefix directory entry, but for each file/directory entry, prefix is added. Change-Id: I2610e40ce37972c5f7456fdca6337e7fb07176e5 Signed-off-by: Yasuhiro Takagi <>
2017-06-05Run auto GC in the backgroundDavid Turner1-0/+1
When running an automatic GC on a FileRepository, when the caller passes a NullProgressMonitor, run the GC in a background thread. Use a thread pool of size 1 to limit the number of background threads spawned for background gc in the same application. In the next minor release we can make the thread pool configurable. In some cases, the auto GC limit is lower than the true number of unreachable loose objects, so auto GC will run after every (e.g) fetch operation. This leads to the appearance of poor fetch performance. Since these GCs will never make progress (until either the objects become referenced, or the two week timeout expires), blocking on them simply reduces throughput. In the event that an auto GC would make progress, it's still OK if it runs in the background. The progress will still happen. This matches the behavior of regular git. Git (and now jgit) uses the lock file for gc.log to prevent simultaneous runs of background gc. Further, it writes errors to gc.log, and won't run background gc if that file is present and recent. If gc.log is too old (according to the config gc.logexpiry), it will be ignored. Change-Id: I3870cadb4a0a6763feff252e6eaef99f4aa8d0df Signed-off-by: David Turner <> Signed-off-by: Matthias Sohn <>
2017-02-20Enable and fix warnings about redundant specification of type argumentsDavid Pursehouse2-7/+7
Since the introduction of generic type parameter inference in Java 7, it's not necessary to explicitly specify the type of generic parameters. Enable the warning in Eclipse, and fix all occurrences. Change-Id: I9158caf1beca5e4980b6240ac401f3868520aad0 Signed-off-by: David Pursehouse <>
2017-02-20Enable and fix 'Should be tagged with @Override' warningDavid Pursehouse1-0/+1
Set missingOverrideAnnotation=warning in Eclipse compiler preferences which enables the warning: The method <method> of type <type> should be tagged with @Override since it actually overrides a superclass method Justification for this warning is described in: Enabling this causes in excess of 1000 warnings across the entire code-base. They are very easy to fix automatically with Eclipse's "Quick Fix" tool. Fix all of them except 2 which cause compilation failure when the project is built with mvn; add TODO comments on those for further investigation. Change-Id: I5772061041fd361fe93137fd8b0ad356e748a29c Signed-off-by: David Pursehouse <>
2016-11-14Organize importsDavid Pursehouse2-5/+9
Change-Id: I7c545d06b1bced678c020fab9af1382bc4416b6e Signed-off-by: David Pursehouse <>
2016-10-23Preserve backslashes within double quotes in CLIGitCommand::split()Rüdiger Herrmann1-0/+2
Change-Id: Ia6a56512baa6a0f27e2eef1b19ebb60291ba377f Signed-off-by: Rüdiger Herrmann <>
2016-10-22Checkout: Add the ability to checkout all paths.Ned Twigg1-1/+24
Change-Id: Ie1e59c566b63d0dfac231e44e7ebd7f3f08f3e9f Signed-off-by: Ned Twigg <> Signed-off-by: David Pursehouse <>
2016-10-19ArchiveTest: Don't use string concatenation in loopDavid Pursehouse1-12/+12
According to FindBugs: In each iteration, the String is converted to a StringBuffer/ StringBuilder, appended to, and converted back to a String. This can lead to a cost quadratic in the number of iterations, as the growing string is recopied in each iteration. Replace string concatenation with StringBuffer. Change-Id: I60e09f274bed6722f4e0e4d096b0f2b1b31ec1b4 Signed-off-by: David Pursehouse <>
2016-10-14Fix JGit CLI to follow native git's interpretation of http_proxy...Christian Halstrick1-0/+232
Native git (as many other tools) interprets the environment variables http_proxy, HTTP_PROXY, ... in a specific way. "http_proxy" has to be lowercase while "https_proxy" can be lowercase or uppercase (means: "HTTPS_PROXY"). Lowercase has precedence. This can be looked up in "ENVIRONMENT" section of [1]. Teach JGit CLI to behave similar. Additionally teach JGit not to interpret the environment variables if the java process was explicitly started with the system properties telling JVM which proxy to use. A call like "http_proxy=proxy1 java -Dhttp.proxyHost=proxy2 ..." should use proxy2 as proxy. [1] Change-Id: I2ad78f209792bf8f1285cf2f8ada8ae0c28f8e5a
2016-08-30CLI: implement option -d for deleting tagsNed Twigg1-0/+23
Change-Id: I438456b76aefd361384729686271288186d3be3b Signed-off-by: Ned Twigg <> Signed-off-by: Matthias Sohn <>
2016-08-30Added a clean command.Ned Twigg1-0/+136
Change-Id: I05d5392789b5b64e6ee44f678556cf25dc30d7ba Signed-off-by: Ned Twigg <>
2016-06-23Fix DirCacheCheckout to return CheckoutConflictExceptionChristian Halstrick1-7/+12
Problem occurs when the checkout wants to create a file 'd/f' but the workingtree contains a dirty file 'd'. In order to create d/f the file 'd' would have to be deleted and since the file is dirty that content would be lost. This should lead to a CheckoutConflictException for d/f when failOnConflict was set to true. This fix also changes jgit checkout semantics to be more like native gits checkout semantics. If during a checkout jgit wants to delete a folder but finds that the working tree contains a dirty file at this path then JGit will now throw an exception instead of silently keeping the dirty file. Like in this example: git init touch b git add b git commit -m addB mkdir a touch a/c git add a/c git commit -m addAC rm -fr a touch a git checkout HEAD~ Change-Id: I9089123179e09dd565285d50b0caa308d290cccd Signed-off-by: Rüdiger Herrmann <> Also-by: Rüdiger Herrmann <>
2016-06-01Add missing @Test annotationsHugo Arès1-0/+1
Change-Id: Ie5ffcbf18233dc9b3eb232f714b5b58b6b93f4e0 Signed-off-by: Hugo Arès <>
2016-05-22JGit CLI: allow to call git init with specific directoryRüdiger Herrmann1-0/+90
With this change it is possible to initialize repositories with 'git init /path/to/new/repo' Change-Id: Ia9b288b4fb34887e8f5e2f3f270e521c44d41b6a Signed-off-by: Rüdiger Herrmann <> Signed-off-by: Matthias Sohn <>
2016-02-12ReflogTest: Open Git instances in try-with-resourceDavid Pursehouse1-13/+16
Change-Id: I950b6f16148cfe11de729b04904f88d6e4c28b9a Signed-off-by: David Pursehouse <>
2016-02-05RepoTest: Open Git in try-with-resourcesDavid Pursehouse1-16/+20
Allocate a new Git for each part of the test, rather than reassigning to the same variable. Change-Id: Ic83778bbff0b2f57d37b95aef70324859d42cd58 Signed-off-by: David Pursehouse <>
2016-01-21Merge branch 'master' into stable-4.2Matthias Sohn11-84/+484
Change-Id: Ieec4f51aedadf5734ae0e3f4e8713248a3c4fc52 Signed-off-by: Matthias Sohn <>
2016-01-21ConfigTest: Create Git instance in try-with-resourceDavid Pursehouse1-1/+3
Change-Id: Ie65c69e0f1aed95bcdf68ebd68d21b3e2590b41c Signed-off-by: David Pursehouse <>
2016-01-20Merge branch 'stable-4.2'David Pursehouse2-292/+317
* stable-4.2: CheckoutCommandTest: Create Git instances in try-with-resource BranchCommandTest: Create Git instances in try-with-resource CheckoutTest: Create Git instances in try-with-resource BranchTest: Create Git instances in try-with-resource URIishTest: Use @Test annotation's `expected` argument Suppress "The allocated object is never used" warning in tests Add $NON-NLS to suppress "Non-externalized string literal" warnings Don't use deprecated constructors of CmdLineException Prepare 4.2.0-SNAPSHOT builds Remove org.eclipse.jgit.updatesite project from tools/ RevParse: Remove superfluous semicolon RefUpdateTest: Use try-with-resource for auto-closable types RefUpdateTest: Add null check to prevent potential NPE CommitCommand: Remove redundant null check JGit v4.2.0.201512141825-rc1 Change-Id: I2179859289b2f2e3d0b7c6d02ef7e7890c467f7b Signed-off-by: David Pursehouse <>
2016-01-19CheckoutTest: Create Git instances in try-with-resourceDavid Pursehouse1-285/+306
Change-Id: I49a03f7bee0b61c062ce160674f9aa0cd1bcc8ba Signed-off-by: David Pursehouse <>
2016-01-19BranchTest: Create Git instances in try-with-resourceDavid Pursehouse1-8/+12
Change-Id: I8becee479fab91a18e6daffd6f4fd57338c9d120 Signed-off-by: David Pursehouse <>
2016-01-06Make sure CLIGitCommand and Main produce (almost) same resultsAndrey Loskutov1-41/+42
Currently execution of tests in pgm uses CLIGitCommand which re-implements few things from Main. Unfortunately this can results in a different test behavior compared to the real CLI runtime. The change let CLIGitCommand extend Main and only slightly modifies the runtime (stream redirection and undesired exit() termination). Change-Id: I87b7b61d1c84a89e5917610d84409f01be90b70b Signed-off-by: Andrey Loskutov <>
2016-01-06branch command: print help if requested, even if arguments are wrongAndrey Loskutov1-0/+10
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 <>
2016-01-06Added CLIText.fatalError(String) API for testsAndrey Loskutov2-8/+10
In different places (Main, TextBuiltin, CLIGitCommand) we report fatal errors and at same time want to check for fatal errors in the tests. Using common API simplifies the error testing and helps to navigate to the actual error check implementation. Change-Id: Iecde79beb33ea595171f168f46b0b10ab2f339bb Signed-off-by: Andrey Loskutov <>
2016-01-02branch command: provide convenient and meaningful options helpAndrey Loskutov1-8/+176
Added tests for all options, fixed multi-valued options parsing. Bug: 484951 Change-Id: I5558589049544ea6c84932bc01f1f9df09e1f682 Signed-off-by: Andrey Loskutov <>
2016-01-02Simplify pgm tests: allow varargs and trim output for toString()Andrey Loskutov1-20/+19
Change-Id: Ia5bcd9e560b90cf872fef75c2800c889ef1cc85a Signed-off-by: Andrey Loskutov <>
2016-01-02Fixed few locale dependent pgm testsAndrey Loskutov2-5/+14
See Change-Id: If51f3c750684d82cb6443f1578636c9f5ca56e2b Signed-off-by: Andrey Loskutov <>
2015-12-30Make sure tests don't blindly continue if a command is "silently" failedAndrey Loskutov9-24/+13
Make the default execute() function fail fast on first command printed "fatal: " to output. Introduced executeUnchecked() for few tests which wanted to test fatal output. Change-Id: I5b09aad9443515636811fc4d00bf8b8b9587a626 Signed-off-by: Andrey Loskutov <>
2015-12-29Sort "eager" path-like options to the end of the helpAndrey Loskutov2-0/+15
The "--" path option (and all other similar options consuming all remaining arguments) should be placed at the end of the command line help. Currently jgit reset -h shows this: jgit reset [commit-ish] [path ... ...] [-- path ... ...] [--hard] [--help (-h)] [--mixed] [--soft] After the patch the help shows this: jgit reset [commit-ish] [path ... ...] [--hard] [--help (-h)] [--mixed] [--soft] [-- path ... ...] Bug: 484951 Change-Id: I3db332bf293ca8d6bfaab0d546cd35af689bd46e Signed-off-by: Andrey Loskutov <>
2015-12-29reset command: provide convenient and meaningful options helpAndrey Loskutov1-5/+27
This commit changes the jgit "reset" command line options help from this: jgit reset name [VAL ...] [-- path ... ...] [--hard] [--help (-h)] [--mixed] [--soft] name : Reset current HEAD to the specified state [...] to this: jgit reset [commit-ish] [path ... ...] [-- path ... ...] [--hard] [--help (-h)] [--mixed] [--soft] commit-ish : Reset to given reference name [...] Bug: 484951 Change-Id: I614e71101b4f9f46ef8f02379d1a9d135f3292d2 Signed-off-by: Andrey Loskutov <>
2015-12-29commit command: allow to specify path(s) argument(s)Andrey Loskutov1-0/+113
This fixes the command below: jgit commit a -m "added file a" which currently fails with: org.eclipse.jgit.api.errors.JGitInternalException: The combination of arguments --all and --only is not allowed Bug: 484973 Change-Id: I37a4ccd68101a66520ef99110f7aa0cbdcc8beba Signed-off-by: Andrey Loskutov <>
2015-12-29repo command: properly name the required 'path' argumentAndrey Loskutov1-0/+24
Fixes point 4 in bug 484951, where "jgit repo" or "jgit repo -h" dumps a stack trace. Bug: 484951 Change-Id: Ic8b362e07a40ad923dc9acde0c0983a1e7932a02 Signed-off-by: Andrey Loskutov <>
2015-12-29Un-ignored existing CLI tests which run just fine on Java 7+Andrey Loskutov2-13/+2
Change-Id: I5ef334a49fb2d88d5e856b443687f3dcb126a77a Signed-off-by: Andrey Loskutov <>
2015-12-29Don't treat command termination due '-h' option as a fatal errorAndrey Loskutov1-0/+22
Signal early command termination due '-h' or '--help' option via TerminatedByHelpException. This allows tests using CLIGitCommand differentiate between unexpected command parsing errors and expected command cancellation "on help" (which also allows validation of expected/unexpected help messages). Additional side-effect: jgit supports now git style of handling help option: any unexpected command line options before help are reported as errors, but after help ignored. Bug: 484951 Change-Id: If45c41c0d32895ab6822a7ff9d851877dcef5771 Signed-off-by: Andrey Loskutov <>
2015-12-28Allow checkout paths without specifying branch nameAndrey Loskutov1-0/+37
JGit CLI should allow to do this: checkout -- <path> Currently, even if "a" is a valid path in the git repo, jgit CLI can't checkout it: $jgit checkout -- a error: pathspec 'a' did not match any file(s) known to git. The fix also fixes at same time "unnamed" zombie "[VAL ...]" argument shown on the command line. Before fix: $jgit -h jgit checkout name [VAL ...] [-- path ... ...] [--force (-f)] [--help (-h)] [--orphan] [-b] After fix: $jgit -h jgit checkout [name] [-- path ... ...] [--force (-f)] [--help (-h)] [--orphan] [-b] Bug: 475765 Change-Id: I2b0e77959a72e4aac68452dc3846adaa745b0831 Signed-off-by: Andrey Loskutov <>
2015-12-11Add remote command to JGit CLIKaloyan Raev1-0/+159
Supported subcommands are: - <none> (lists available remotes) - add - remove - set-url - update Supported options are: --verbose --push --prune Bug: 481316 Change-Id: I57c34ed6daabb7d308bc383b17c1ef4af433e714 Signed-off-by: Kaloyan Raev <> Signed-off-by: Matthias Sohn <>
2015-11-25Repository: Introduce exactRef and findRef, deprecate getRefJonathan Nieder3-7/+9
The Repository class provides only one method to look up a ref by name, getRef. If I request refs/heads/master and that ref does not exist, getRef will look further in the search path: ref/refs/heads/master refs/heads/refs/heads/master refs/remotes/refs/heads/master This behavior is counterintuitive, needlessly inexpensive, and usually not what the caller expects. Allow callers to specify whether to use the search path by providing two separate methods: - exactRef, which looks up a ref when its exact name is known - findRef, which looks for a ref along the search path For backward compatibility, keep getRef as a deprecated synonym for findRef. This change introduces findRef and exactRef but does not update callers outside tests to use them yet. Change-Id: I35375d942baeb3ded15520388f8ebb9c0cc86f8c Signed-off-by: Jonathan Nieder <>
2015-10-29reset command should support the -- <paths> parametersKaloyan Raev2-9/+133
Bug: 480750 Change-Id: Ia85b1aead03dcf2fcb50ce0391b656f7c60a08d4 Signed-off-by: Kaloyan Raev <>
2015-09-16Fix integer boxing eclipse warningHugo Arès1-19/+18
There was this warning because private assertEquals(Object, Object) method was shadowing JUnit assertEquals methods. Change-Id: I889bfe1d8c48210d9a42147a523c4829c5b5d1e3 Signed-off-by: Hugo Arès <>
2015-05-27archive: Drop unnecessary empty comments and 'final' qualifiers on localsJonathan Nieder1-75/+75
Early JGit code used comments to inform the Eclipse formatter about where to break lines and used final in the hope of making code faster. The ArchiveCommand command implementation imitated that style. Nowadays the project relies less on the Eclipse formatter and relies more on Java having sane performance with local variables that are not explicitly marked 'final'. Removing the unnecessary empty comments and 'final' qualifiers makes this code more readable and more consistent with recent JGit code. Change-Id: I7a181432eda7e18bd32cf110d89c0efbe490c4f1 Signed-off-by: Jonathan Nieder <>
2015-03-13CLI status should support --untracked-filesKaloyan Raev1-206/+428
A special options handler is added to properly handle the short -u alias of the option. The "normal" mode is not supported by this patch, because this mode of listing untracked files is not supported by the org.eclipse.jgit.lib.IndexDiff class. This mode is not necessary for my use case. It can be added later if anyone really needs it. The StatusTest is updated to cover all possible combinations of the --porcelain and --untracked-files options. Bug: 459319 Change-Id: I305ac95739cfed0c16735e0987844e57fa27e236 Signed-off-by: Kaloyan Raev <> Signed-off-by: Matthias Sohn <>
2015-03-09Add "--long" option to JGit describeChristian Halstrick1-0/+7
Native git supports "git describe --long". This will enforce returning a long description of a commit even if a tag is directly pointing to the commit (in contrast to just returning the tag name as it is now). This commit teaches JGits DescribeCommand and the describe command in the pgm package to support "--long". Bug: 460991 Change-Id: I65e179b79e89049c6deced3c71cb3ebb08ed0a8f Signed-off-by: Matthias Sohn <>

Back to the top