aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse/jgit/api/PushCommand.java
Commit message (Collapse)AuthorAgeFilesLines
* [errorprone] Rename method parameter to silence InvalidParamMatthias Sohn2023-09-251-3/+3
| | | | | | See https://errorprone.info/bugpattern/InvalidParam Change-Id: I53279bc5e0fc59788d42994be9931857b918414b
* PushCommand: allow users to disable use of bitmaps for pushkylezhao2022-10-211-0/+28
| | | | | | | | | | | | | | | | Reachability bitmaps are designed to speed up the "counting objects" phase of generating a pack during a clone or fetch. They are not optimized for Git clients sending a small topic branch via "git push". In some cases (see [1]), using reachability bitmaps during "git push" can cause significant performance regressions. Add PushCommand#setUseBitmaps(boolean) to allow users to tell "git push" not to use bitmaps. [1]: https://lore.kernel.org/git/87zhoz8b9o.fsf@evledraar.gmail.com/ Change-Id: I7fb7d26084ec63ddfa7249cf58abb85929b30e56 Signed-off-by: kylezhao <kylezhao@tencent.com>
* I/O redirection for the pre-push hookThomas Wolf2022-10-201-0/+47
| | | | | | | | | | | Fix and complete the implementation of calling the pre-push hook. Add the missing error stream redirect, and add the missing setters in Transport and in PushCommand. In Transport, delay setting up a PrePushHook such that it happens only on a push. Previously, the hook was set up also for fetches. Bug: 549246 Change-Id: I64a576dfc6b139426f05d9ea6654027ab805734e Signed-off-by: Thomas Wolf <twolf@apache.org>
* [push] support the "matching" RefSpecs ":" and "+:"Thomas Wolf2022-03-061-1/+1
| | | | | | | | | | | | | | | | | | | The implementation of push.default=matching was not correct. It used the RefSpec "refs/heads/*:refs/heads/*", which would push _all_ local branches. But "matching" must push only those local branches for which a remote branch with the same name already exists at the remote. This RefSpec can be expanded only once the advertisement from the remote has been received. Enhance RefSpec so that ":" and "+:" can be represented. Introduce a special RemoteRefUpdate for such a RefSpec; it must carry through the fetch RefSpecs to be able to fill in the remote tracking updates as needed. Implement the expansion in PushProcess. Bug: 353405 Change-Id: I54a4bfbb0a6a7d77b9128bf4a9c951d6586c3df4 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* PushCommand: determine remote from git config if not givenThomas Wolf2022-02-141-1/+31
| | | | | | | | | | Add ConfigConstants and expose branch.<name>.pushRemote in the BranchConfig. Use the branch configuration and remote.pushDefault if no remote is given explicitly. If nothing is configured, fall back to "origin". Bug: 578676 Change-Id: I6bb141ff02c8b04980ec34b26ef248b72614c3c9 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* PushCommand: consider push.default when no RefSpecs are givenRolf Theunissen2022-02-141-12/+117
| | | | | | | | | | | | | | | | | | When no RefSpecs are given, PushCommand until now simply fell back to pushing the current branch to an upstream branch of the same name. This corresponds to push.default=current. Any setting from the git config for push.default was simply ignored. Implement the other modes (nothing, matching, upstream, and simple), too. Add a setter and getter for the PushDefault so that an application can force a particular mode to be used. For backwards compatibility, use "current" as the default setting; to figure out the value from the git config, which defaults to "simple", call setPushDefault(null). Bug: 351314 Change-Id: I86c5402318771e47d80b137e99947762e1150bb4 Signed-off-by: Rolf Theunissen <rolf.theunissen@gmail.com> Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* Prevent that an instance of PushCommand is reusedThomas Wolf2022-02-141-0/+1
| | | | | | | We checked if the command instance is called but missed to set the flag tracking if it actually was used. Change-Id: I0f9fb85c47945a4d91eab01ec5e1abc1ab83332a
* ErrorProne: Enable and fix UnusedException checkDavid Pursehouse2020-01-271-2/+3
| | | | | | | | | | | | | | | | | | | | | Enable UnusedException at ERROR level which causes the build to fail in many places with: [UnusedException] This catch block catches an symbol and re-throws another, but swallows the caught symbol rather than setting it as a cause. This can make debugging harder. Fix it by setting the caught exception as cause on the subsequently thrown exception. Note: The grammatically incorrect error message is copy-pasted as-is from the version of ErrorProne currently used in Bazel; it has been fixed by [1] in the latest version. [1] https://github.com/google/error-prone/commit/d57a39c Change-Id: I11ed38243091fc12f64f1b2db404ba3f1d2e98b5 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Update EDL 1.0 license headers to new short SPDX compliant formatMatthias Sohn2020-01-041-38/+5
| | | | | | | | | | This is the format given by the Eclipse legal doc generator [1]. [1] https://www.eclipse.org/projects/tools/documentation.php?id=technology.jgit Bug: 548298 Change-Id: I8d8cabc998ba1b083e3f0906a8d558d391ffb6c4 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* PushCommand: Suppress resource warning for Transport in for loopDavid Pursehouse2018-03-161-1/+2
| | | | | | | | | | | | A list of Transport instances is provided by Transport.openAll, and then iterated over in a for loop. Eclipse warns that the Transport in the for-loop should be managed by try-with-resource. The Transport is explicitly closed in the finally block, so just suppress the warning. Change-Id: I92b73cd90902637cf1ac1ab7b02b5ee5ed6bdb1e Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* Fix remaining javadoc errors raised by doclintMatthias Sohn2017-12-211-2/+1
| | | | | | | For now ignore doclint "missing" warnings. Change-Id: I0e5af7a757f4d92ffeeb113f30576a35414d6781 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Fix javadoc in org.eclipse.jgit annotations and api packagesMatthias Sohn2017-12-181-18/+53
| | | | Change-Id: I2761ea91f8dfed16ea54e7a6646af03a30c15ec9 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Enable and fix warnings about redundant specification of type argumentsDavid Pursehouse2017-02-201-3/+3
| | | | | | | | | | 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 <david.pursehouse@gmail.com>
* Enable and fix 'Should be tagged with @Override' warningDavid Pursehouse2017-02-191-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: http://stackoverflow.com/a/94411/381622 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 <david.pursehouse@gmail.com>
* push: support per-ref force-with-leaseDavid Turner2017-02-081-1/+45
| | | | | | | | | | When rebasing, force-pushing has a race condition: someone else might have pushed a commit since the one you just rewrote. The force-with-lease option prevents this by ensuring that the ref's old value is the one that you expected. Change-Id: I97ca9f8395396c76332bdd07c486e60549ca4401 Signed-off-by: David Turner <dturner@twosigma.com>
* Push implementation of option stringsDan Wang2016-07-221-1/+23
| | | | | | | | | | | | | Example usage: $ ./jgit push \ --push-option "Reviewer=j.doe@example.org" \ --push-option "<arbitrary string>" \ origin HEAD:refs/for/master Stefan Beller has also made an equivalent change to CGit: http://thread.gmane.org/gmane.comp.version-control.git/299872 Change-Id: I6797e50681054dce3bd179e80b731aef5e200d77 Signed-off-by: Dan Wang <dwwang@google.com>
* Replace use of deprecated method Repository.getRef()Matthias Sohn2016-05-311-2/+2
| | | | Change-Id: Iecf2b8deafc4991cc3333702fb9fa0638be7b914 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Better report on client side if push failed due to too large objectMatthias Sohn2016-05-301-0/+4
| | | | | | | | | | | | | | | | | JGits PushCommand and BasePackPushConnection were throwing a generic exception when the pushed pack-file was rejected by the server since it contained too large objects. Teach JGit to better analyze the server's response to detect this situation and throw a more specific exception. Detect this situation by parsing the status line sent by the server. This change only recognizes the response sent by a JGit based server. All other servers which report such problems in a different way still lead to a generic TransportExceptions. Also see https://git.eclipse.org/r/#/c/46348/ Change-Id: I8d6d65e4585ebb3846f7207e7d1a2f82fa9cbd86 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Support atomic push in JGit clientShawn Pearce2015-12-021-2/+25
| | | | | | | | | | | | | This should mirror the behavior of `git push --atomic` where the client asks the server to apply all-or-nothing. Some JGit servers already support this based on a custom DFS backend. InMemoryRepository is extended to support atomic push for unit testing purposes. Local disk server side support inside of JGit is a more complex animal due to the excessive amount of file locking required to protect every reference as a loose reference. Change-Id: I15083fbe48447678e034afeffb4639572a32f50c
* Handle null in ProgressMonitor settersJonathan Nieder2015-06-111-0/+3
| | | | | | | | | | | These commands' monitor fields can never be null unless someone passes null to setProgressMonitor. Anyone passing null probably meant to disable the ProgressMonitor, so do that (by falling back to NullProgressMonitor.INSTANCE) instead of saving a null and eventually producing NullPointerException. Change-Id: I63ad93ea8ad669fd333a5fd40880e7583ba24827 Signed-off-by: Jonathan Nieder <jrn@google.com>
* Better report too large pack-files from PushCommandChristian Halstrick2015-05-271-0/+4
| | | | | | | | | | | | | | JGits PushCommand and BasePackPushConnection were throwing generic TransportExceptions when the pushed pack-file was rejected by the server since it was too big. Let JGit better interprete the server's response to detect this situation and throw a more specific exception. This detection works by parsing the status line sent by the server. This change only recognizes the response sent by a JGit based server. All other servers which report such problems in a different way still lead to a generic TransportExceptions. Change-Id: Ic075764ea152939ce72c446252464620dd54edea Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Allow users to show server messages while pushingAndré Dietisheim2013-03-211-1/+16
| | | | | | | | | | | | Allow users to provide their OutputStream (via Transport# push(monitor, refUpdates, out)) so that server messages can be written to it (in SideBandInputStream) while they're coming in. CQ: 7065 Bug: 398404 Change-Id: I670782784b38702d52bca98203909aca0496d1c0 Signed-off-by: Andre Dietisheim <andre.dietisheim@gmail.com> Signed-off-by: Chris Aniszczyk <zx@twitter.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Further cleanup of exceptions in Git APIRobin Rosenberg2012-06-051-4/+10
| | | | | | | | | - Translate internal exceptions to corresponding API exception - Do not catch GitAPI exceptions internally to an internal exception. Just pass them to caller - Mention thrown exceptions in javadoc Change-Id: I9044cf86d2b0bcc8b63b7cc016e1bf0055a62053 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Git API does not declare GitAPIException call() and related cleanupsRobin Rosenberg2012-05-301-6/+3
| | | | | | | | | | | | | | | | | | | | | | | | All commands should throw a GitAPIException so new exceptions can be added without breaking the builds of old code, i.e. anyone that calls a Git API should catch GitAPIException and not just the currently known exceptions. Now the only checked exceptions on Git API calls are GitException and subclasses of it. New checked exceptions that are subclasses of GitException may be added without breaking the API. Javadoc for GitAPIException is declared on GitCommand and inherited to subclasses. JGitInternalException is not explicitly documented anymore. Unfortunately this change itself breaks the API. The intention is that it shall be possible to add new checked subclasses of GitAPIException without breaking the API. Bug: 366914 EGit-Change-Id: I50380f13fc82c22d0036f47c7859cc3a77e767c5 Change-Id: I50380f13fc82c22d0036f47c7859cc3a77e767c5 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Move JGitText to an internal packageRobin Rosenberg2012-03-121-1/+1
| | | | Change-Id: I763590a45d75f00a09097ab6f89581a3bbd3c797
* Support a configured credentials provider in LsRemoteCommandKevin Sawicki2011-11-101-52/+3
| | | | | | | | | | | | Refactored the three common transport configuration options: credentials provider, timeout, and transport config callback into a new TransportCommand base class which is now extended by all commands that use a Transport object during execution. Bug: 349188 Change-Id: I90c2c14fb4e3cc4712905158f9047153a0c235c2 Signed-off-by: Kevin Sawicki <kevin@github.com> Signed-off-by: Chris Aniszczyk <zx@twitter.com>
* Enable full Transport configuration for JGit API commandsRoberto Tyley2011-09-161-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a TransportConfigCallback parameter to JGit API commands, to allow consumers of the JGit command API to perform custom Transport configuration that would be otherwise difficult to anticipate & expose on the API command builders. My specific use-case is configuring additional properties on SshTransport - I need to take over the SshSessionFactory used by the transport. Using TransportConfigCallback I can simply do this (rather than reimplement the API command classes): public void configure(Transport tn) { if (tn instanceof SshTransport) { ((SshTransport) tn).setSshSessionFactory(factoryProvider.get()); } } Adding an explicit setSshSessionFactory() method to the JGit command classes would bloat the API. Also, creating the replacement SshSessionFactory is unnecessary if the transport is not SSH, but the type of the Transport is only known once the remote has been resolved and the URI parsed - consequently it makes sense to perform this step in a callback, where the transport instance can be inspected to determine if it's of a relevant type. A note about where this leaves the API - there are now 4 commands: CloneCommand PullCommand FetchCommand PushCommand -that share 3 identical transport-related parameters: timeout credentialsProvider transportConfigurator I think there's potential for introducing an interface or val-object to identify/encapsulate this repetition, which I'd be happy to do in a subsequent commit. Change-Id: I8983c3627cdd7d7b2aeb0b6a3dadee553378b951 Signed-off-by: Roberto Tyley <roberto.tyley@gmail.com>
* Add lookup to remote config if the refSpec is not explicitly setStefan Lay2011-07-041-0/+5
| | | | | | | | If no refSpec is explicitly set, the PushCommand should first check the remote config and then as a fallback use the current behavior. Change-Id: I2bc648abc517b1d01b2de15d383423ace2081e72 Signed-off-by: Stefan Lay <stefan.lay@sap.com>
* PushCommand: Allow adding any reference stringShawn O. Pearce2011-03-151-0/+39
| | | | | | | | | The simplified form of add(String) makes it easier for applications to pass down user input and allow PushCommand to convert it to the internal RefSpec object. Change-Id: Ibd2e95852db0e52ea4a36032942c4c42a7fb4261 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* PushCommand: Add utilities for --all, --tagsShawn O. Pearce2011-03-151-0/+20
| | | | | | | | | | | The --all flag on the command line implies using refs/heads/* as a push specification. Add this to the standard command object. The --tags flag on the command line implies using refs/tags/* as a push specification. Add this to the standard command object. Change-Id: Iaef200b17cce77604548dbfb15cf2499b10687b5 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* PushCommand: Default to pushing HEADShawn O. Pearce2011-03-141-0/+7
| | | | | | | | If no RefSpec was specified, push the branch that is currently checked out as HEAD. Change-Id: I6f13ef6346188698a14e000fc590850afbc34b21 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* PushCommand: Set force-update in-placeShawn O. Pearce2011-03-141-5/+3
| | | | | | | | Rather than copying the entire list, just replace each element with the version that has setForceUpdate(true) invoked on it. Change-Id: I2eaa4466d497cb2408ce61dc62ca26e0c32fe841 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* PushCommand: do not set a null credentials providerJens Baumgart2011-02-021-1/+2
| | | | | | | | | | | PushCommand now does not set a null credentials provider on Transport because in this case the default provider is replaced with null and the default mechanism for providing credentials is not working. Bug: 336023 Change-Id: I7a7a9221afcfebe2e1595a5e59641e6c1ae4a207 Signed-off-by: Jens Baumgart <jens.baumgart@sap.com>
* Make setCredentialsProvider more convenient to useMathias Kinzler2011-01-261-1/+5
| | | | | Change-Id: I984836ea7d6a67fd2d1d05f270afa7c29f30971c Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
* Allow to set a CredentialsProvider on relevant API commandsMathias Kinzler2011-01-251-0/+11
| | | | | | | | This is needed for commands that use Transport internally. Change-Id: I9417c85255b160723968c647063b9c7e05995ea4 Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com> Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
* Add PushCommand APIChris Aniszczyk2010-10-051-0/+349
Change-Id: Iff144a51fdc9a1112a21492c390a873a2b293bc9 Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>