Commit Graph

6646 Commits

Author SHA1 Message Date
Matthias Sohn 23affa6c77 Prepare 5.3.0-SNAPSHOT builds
Change-Id: I9f0bf3ff2b26f4a8300c98206beb19c2b9d4946a
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-01-17 04:23:42 +01:00
Matthias Sohn 05159ed656 JGit v5.3.0.201901162155-m1
Change-Id: I350925ff3b1fba2c83a448bc4e6d67368573693e
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-01-17 04:17:18 +01:00
Matthias Sohn 13f9aae49a Fix tools/version.sh
The script missed to update all but the first version in
org.eclipse.jgit.coverage/pom.xml

Change-Id: If8021accf07d7b57b477992cc0f1ba8ddc7db9a6
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-01-17 03:10:09 +01:00
Matthias Sohn 8fc2aef89e JGit v5.3.0.201901161700-m1
Change-Id: I935cae5ae09ee5598ebdf6d9209048afec0d42dc
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-01-17 02:39:39 +01:00
Medha Bhargav Prabhala 137e91a465 Implement signing commits using BouncyCastle
This also includes a change to generating the jgit CLI jar. Shading is
no longer possible because it breaks the signature of BouncyCastle.
Instead, the Spring Boot Loader Maven plug-in is now used to generate an
executable jar.

Bug: 382212
Change-Id: I35ee3d4b06d9d479475ab2e51b29bed49661bbdc
Also-by: Gunnar Wagenknecht <gunnar@wagenknecht.org>
Signed-off-by: Gunnar Wagenknecht <gunnar@wagenknecht.org>
Signed-off-by: Medha Bhargav Prabhala <mprabhala@salesforce.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-01-16 10:05:10 +01:00
Medha Bhargav Prabhala 9150f5d836 Add signing options to commit CLI
Bug: 382212
Change-Id: I02194fc566dd5baa963424b1bac78607964436a3
Also-by: Gunnar Wagenknecht <gunnar@wagenknecht.org>
Signed-off-by: Medha Bhargav Prabhala <mprabhala@salesforce.com>
Signed-off-by: Gunnar Wagenknecht <gunnar@wagenknecht.org>
2019-01-16 10:05:10 +01:00
Gunnar Wagenknecht 2343c688b1 Allow CommitCommand to sign commits
This change introduces the concept of a GpgSigner which will sign
commits. The GpgSigner will be of a specific implementation (eg.,
Bouncycastle or OpenPgP executable). The actual implementation is not
part of this change.

Bug: 382212
Change-Id: Iea5da1e885c039e06bc8d679d46b124cbe504c8e
Also-by: Medha Bhargav Prabhala <mprabhala@salesforce.com>
Signed-off-by: Medha Bhargav Prabhala <mprabhala@salesforce.com>
Signed-off-by: Gunnar Wagenknecht <gunnar@wagenknecht.org>
2019-01-16 10:05:09 +01:00
Matthias Sohn 159968abc4 pgm: propagate generic exceptions when throwing Die exception
If a command is stopped by throwing a Die exception since a generic
exception was caught this exception contains additional information
which is not available in the error message. Hence chain it to the Die
exception in order to allow printing a complete stacktrace including
causes to the error stream of the JGit command line by adding option
--show-stack-trace, e.g.

$ jgit --show-stack-trace commit -m "test"

Change-Id: I7ad8c56b997ab60d2bd08f4e7b4d0b80c84021c3
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-01-16 02:22:32 +01:00
Matthias Sohn d4d9625d4b Update Eclipse Java compiler
Update
- orb.eclipse.jdt:ecj to 3.16.0
- plexus-compiler-eclipse to 2.8.5

Change-Id: I56d6d57c4c49646a9c98d2d1ca01b1b1d92280cf
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-01-15 09:59:13 +01:00
Matthias Sohn 91e533a441 Update Jetty to 9.4.14
Change-Id: I255d4d03a35bf7701b021339623dfb8c28d24c35
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-01-15 09:59:06 +01:00
Jonathan Nieder 1131f35cd1 dfs: Remove synchronization in BlockBasedFile#LazyChannel
As explained in 'The "Double-Checked Locking is Broken"
Declaration'[*], Java's memory model does not support double-checked
locking:

 class LazyReadableChannel {
   private ReachableChannel rc = null;

   public ReadableChannel get() {
     if (rc == null) {
       synchronized (this) {
         if (rc == null) {
           rc = new ReadableChannel();
	 }
       }
     }
     return rc;
   }
 }

With JDK 5 and newer, there is a formal memory model that ensures this
works if "rc" is volatile, but it is still not thread-safe without
that.

Fortunately, this ReadableChannelSupplier is never passed between
threads, so it does not need to be thread-safe.  Simplify by removing
the synchronization.

[*] https://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html

Change-Id: I0698ee6618d734fc129dd4f63fc047c1c17c94a9
Signed-off-by: Jonathan Nieder <jrn@google.com>
2019-01-14 10:55:28 -08:00
Jonathan Nieder 5f355ed4ad UploadPack: Read wanted refs in one shot
This allows scanning through refs once instead of once per ref, which
should make the lookup less expensive for some RefDatabase
implementations.

Change-Id: I1434f834186cc9a6b4e52659e692b1000c926995
Signed-off-by: Jonathan Nieder <jrn@google.com>
2019-01-11 11:58:08 -08:00
Jonathan Nieder ec94268fd4 Merge branch 'stable-5.2'
* stable-5.2:
  Prepare 5.2.2-SNAPSHOT builds
  JGit v5.2.1.201812262042-r
  Prepare 5.1.6-SNAPSHOT builds
  JGit v5.1.5.201812261915-r
  UploadPack: Filter refs used for deepen-not resolution
  UploadPack: Avoid calling AdvertiseRefsHook twice
  Prepare 5.1.5-SNAPSHOT builds
  JGit v5.1.4.201812251853-r
  UploadPack: Filter refs used for want-ref resolution
  UploadPack: Defer want-ref resolution to after parsing
  Call AdvertiseRefsHook for protocol v2
  Prepare 4.11.7-SNAPSHOT builds
  JGit v4.11.6.201812241910-r
  Prepare 4.9.9-SNAPSHOT builds
  JGit v4.9.8.201812241815-r
  UploadPack: Test filtering by AdvertiseRefsHook in stateless transports
  Prepare 4.7.8-SNAPSHOT builds
  JGit v4.7.7.201812240805-r
  Fix feature versions imported by feature org.eclipse.jgit.pgm
  Prepare 4.5.6-SNAPSHOT builds
  JGit v4.5.5.201812240535-r
  Call AdvertiseRefsHook before validating wants

Change-Id: Ia56348e54d62630d7c50a4747df89516fc5afad9
Signed-off-by: Jonathan Nieder <jrn@google.com>
2019-01-10 20:23:33 -08:00
David Pursehouse 9150caa835 Bazel: Automatically format build file with buildifier 0.20.0
Version 0.20.0 of buildifier has a lint mode that can fix the
formatting issues automatically:

  buildifier --lint=fix

Apply this to BUILD files.

Change-Id: I1120a0f15771d0bbea4daa34037be0b860385389
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2019-01-10 20:48:42 -05:00
Terry Parker 01f8e53b26 Merge "Lazily open ReadableChannel in BlockBasedFile.getOrLoadBlock" 2019-01-10 19:01:57 -05:00
Minh Thai 513d80db10 Lazily open ReadableChannel in BlockBasedFile.getOrLoadBlock
To avoid opening the readable channel in case of DfsBlockCache
hits. Also cleaning up typos around DfsBlockCache.

Change-Id: I615e349cb4838387c1e6743cdc384d1b81b54369
Signed-off-by: Minh Thai <mthai@google.com>
2019-01-10 14:22:54 -08:00
Jackson Toeniskoetter 8ed59c511c Make TestRepository AutoCloseable
Currently, unit tests need to either close the Repository underlying a
TestRepository manually, or not close it at all. Both are error prone.

The TestRepository holds a reference to 4 AutoCloseable objects:
Repository, ObjectInserter, Git, and RevWalk. The last two can escape
the TestRepository scope, so they are not closed when TestRepository is
closed.

Change-Id: I4461bb9104d517bd6bef09c38507c7c2ef5c31d4
Signed-off-by: Jackson Toeniskoetter <jackdt@google.com>
2019-01-10 12:10:43 -08:00
Matthias Sohn 23c30c6310 Fix warnings for usage of deprecated RefDatabase#getRef
Change-Id: I22a244114ef973b3801cf3b639ff782f21c02f98
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-01-08 18:41:11 -05:00
Minh Thai 4207b8d6ae DfsBlockCache: Consolidate where ReadableChannel is opened
Opening a readable channel can be expensive and the number of channels
can be limited in DFS. Ensure that caller of
BlockBasedFile.readOneBlock() is responsible for opening and closing
the file, and that the ReadableChannel is reused in the request. As a side
effect, this makes the code easier to read, with better use of
try-with-resources.

The downside is that this means a readable channel is always opened, even
when the entire pack is already available for copying from cache. This
should be an acceptable cost: it's rare enough not to overload the server
and from a client latency perspective, the latency cost is in the noise
relative to the data transfer cost involved in a clone. If this turns out
to be a problem in practice, we can reintroduce that optimization in a
followup change.

Change-Id: I340428ee4bacd2dce019d5616ef12339a0c85f0b
Signed-off-by: Minh Thai <mthai@google.com>
Signed-off-by: Jonathan Nieder <jrn@google.com>
2019-01-08 14:31:56 -05:00
Minh Thai 8bc9acf264 DfsBlockCache to lock while loading object references
We see the same index being loaded by multiple threads. Each is
hundreds of MB and takes several seconds to load, causing server to
run out of memory.  This change introduces a lock to avoid these
duplicate works.  It uses a new set of locks similar in implementation
to the loadLocks for getOrLoad of blocks.  The locks are kept separate
to prevent long-running index loading from blocking out fast block
loading. The cache instance can be configured with a consumer to
monitor the wait time of the new locks.

Change-Id: I44962fe84093456962d5981545e3f7851ecb6e43
Signed-off-by: Minh Thai <mthai@google.com>
2019-01-08 09:59:40 -08:00
Christian Halstrick e406d500de Fix "jgit checkout -f" to overwrite dirty worktree files
CheckoutCommand had a setForce() method. But this didn't correspond
to native git's 'git checkout -f' option. Deprecate the old setForce()
method and move its implementation to a new method setForceRefUpdate()
and use it to implement the -B option in the CLI class Checkout.

Add a setForced() method and use it to fix the associated '-f' option of
the CLI Checkout class to behave like native git's 'git checkout -f'
which overwrites dirty worktree files during checkout.

This is still not fully matching native git's behavior: updating
additionally dirty index entries is not done yet.

Bug: 530771
Change-Id: I776b78eb623b6ea0aca42f681788f2e4b1667f15
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-01-08 10:01:09 +01:00
Mario Molina 6c8240a751 Return 'this' from setters in commands
To avoid breaking ABI, take the opportunity to give these setters
(hopefully sometimes better) names and deprecate their old names.

Change-Id: Ib45011678c3d941f8ecc1a1e0fdf4c09cdc337e3
Signed-off-by: Mario Molina <mmolimar@gmail.com>
Signed-off-by: Jonathan Nieder <jrn@google.com>
2019-01-07 20:00:11 -05:00
David Pursehouse 062822dc41 Upgrade wagon-ssh to 3.3.1
Change-Id: I7428e55302e673380b1ab024b5ee2fd71308b40f
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2019-01-07 17:21:30 -05:00
David Pursehouse fd693a69b1 Upgrade spotbugs-maven-plugin to 3.1.10
Change-Id: I800930d34491ae5568d47ccc59271b6ad4a24c3d
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2019-01-07 17:20:41 -05:00
Jonathan Nieder d83e85736e Don't swallow IOException
Swallowing intermittent errors and trying to recover from them
makes JGit's behavior hard to predict and difficult to debug.

Propagate the errors instead.  This doesn't violate JGit's usual
backward compatibility promise for clients because in these
contexts an IOException indicates either repository corruption or
a true I/O error.  Let's consider these cases one at a time.

In the case of repository corruption, falling back e.g. to an empty
set of refs or a missing ref will not serve a caller well.  The
fallback does not indicate the nature of the corruption, so they are
not in a good place to recover from the error.  This is analogous to
Git, which attempts to provide sufficient support to recover from
corruption (by ensuring commands like "git branch -D" cope with
corruption) but little else.

In the case of an I/O error, the best we can do is to propagate the
error so that the user sees a dialog and has an opportunity to try
again.  As in the corruption case, the fallback behavior does not
provide enough information for a caller to rely on the current error
handling, and callers such as EGit already need to be able to handle
runtime exceptions.

To be conservative, keep the existing behavior for the deprecated
Repository#peel method.  In this example, the fallback behavior is to
return an unpeeled ref, which is distinguishable from the ref not
existing and should thus at least be possible to debug.

Change-Id: I0eb58eb8c77519df7f50d21d1742016b978e67a3
Signed-off-by: Jonathan Nieder <jrn@google.com>
2019-01-07 14:00:28 -05:00
Jonathan Nieder 752d5547e4 Merge "Deprecate Repository#hasObject" 2019-01-07 13:46:36 -05:00
Thomas Wolf 5663b67575 Apache MINA sshd client: less aggressive key file name caching
Don't use the ~/.ssh directory as cache key for the key provider
but the configured paths of the default keys. Otherwise changes
in that list of paths are not picked up.

This is in particular a problem for EGit, where the user can modify
this list of keys interactively in the preferences. Without this
change, Eclipse needs to be restarted to pick up such changes.

Bug: 542845
Change-Id: I63432fb10729a90b3c5e14f13e39bf482aef811b
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2019-01-05 17:59:32 +01:00
Jonathan Nieder 3f9a5ce13f Deprecate Repository#hasObject
Its implementation contains

		} catch (IOException e) {
			// Legacy API, assume error means "no"
			return false;
		}

Better to use ObjectDatabase#has, which throws IOException to report
errors.

Change-Id: I7de02f7ceb8f57b2a8ebdb16d2aa4376775ff933
Signed-off-by: Jonathan Nieder <jrn@google.com>
2019-01-04 17:21:20 -08:00
Dave Borowitz b952d9e65a Correct target name for jgit-4.10-staging
Change-Id: I130c7f1420b6b3753f4d419a37d16633755da21c
2019-01-04 15:06:23 -08:00
Michael Keppler d8bb1d09d2 Deprecate RawParseUtils.UTF8-CHARSET
That constant is just a redirection to a java standard constant
meanwhile. It is not referenced anymore in jgit code (and egit is just
removing it). Clients can use the redirection target directly.

Change-Id: I058d013f61da8d7b771c499d8743aafb8faa5ea8
Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-01-04 03:05:39 +01:00
Christian Halstrick 530812d936 Fix detection of "initial checkout"
A checkout done directly after cloning (the "initial
checkout") has a different semantic as a default
checkout. That is defined in the documentation of
"git read-tree" [1]. JGit was detecting that it is
doing an initial checkout differently from native
git: jgit used to check that the index is empty
but native git required that the index file does
not exist [2]. Teach JGit to behave like native
git.

[1] https://github.com/git/git/blob/master/Documentation/git-read-tree.txt#L187
[2] https://marc.info/?t=154150811200001&r=1&w=2

Change-Id: I1dd0f1ede7cd7ea60d28607916d0165269a9f628
2019-01-02 21:18:29 -05:00
David Pursehouse 1168ab0f37 Upgrade plexus-compiler-javac-errorprone to 2.8.5
Change-Id: I2898eef32472216a5fb33f5a036588dd022445cb
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2019-01-02 20:06:47 -05:00
Michael Keppler 0d9e486714 Replace deprecated FirstLine by FirstCommand
and allow package org.eclipse.jgit.http.server to use package
org.eclipse.jgit.internal.transport.parser.

Change-Id: Ief330c3e75a735853d0a5a265a9ff56fb5128b99
Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-12-31 16:31:37 +01:00
Jonathan Nieder dbf6f9f692 Move BaseReceivePack#advertisedRefs getter and setter to ReceivePack
Another step toward merging BaseReceivePack into ReceivePack.

Change-Id: If861e28ce512f556e574352fa7d4a0df0984693f
Signed-off-by: Jonathan Nieder <jrn@google.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-12-29 11:59:27 +01:00
Jonathan Nieder 939723807e Move BaseReceivePack#walk getter to ReceivePack
Another step toward merging BaseReceivePack into ReceivePack.

Change-Id: I43cf2e36e2d5b0cd85bf23c81469909c14757b63
Signed-off-by: Jonathan Nieder <jrn@google.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-12-29 11:59:27 +01:00
Jonathan Nieder aaf41a51b7 Move BaseReceivePack#db getter to ReceivePack
Another step toward eliminating BaseReceivePack as a separate API.

Change-Id: If7b7d5c65a043607a2424211adb479fa33a9077b
Signed-off-by: Jonathan Nieder <jrn@google.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-12-29 11:59:27 +01:00
Jonathan Nieder 937beaa1ae Move BaseReceivePack#pushCert getter and setter to ReceivePack
This is a first step toward eliminating the BaseReceivePack API.

Inspired by a larger change by Dan Wang <dwwang@google.com>.

Change-Id: I5c876a67d8db24bf808823d9ea44d991b1ce5277
Signed-off-by: Jonathan Nieder <jrn@google.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-12-29 11:59:26 +01:00
Matthias Sohn e78776fa5b Remove unused API problem filters
Change-Id: I8ed98ac60362ba071506b0bdacd2941ab72b6bf4
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-12-29 11:55:02 +01:00
Matthias Sohn bd6aa22333 Silence API error for RefDatabase.getRef declared final
RefDatabase.getRef was declared final in
c1954f6c36
which only affects implementers.

Change-Id: I4c14232a119670d263d88db2b8d725dcdd36ab2a
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-12-29 01:07:24 +01:00
Matthias Sohn 7b989eed72 Suppress API errors and add missing @since tags caused by 6ea888a
Change-Id: Id042d46ba078af35b9c22a079da4ae14fc5fa231
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-12-29 00:17:33 +01:00
Jonathan Nieder 2f9ebeacc8 Merge changes Id3bb9443,I1be1948b
* changes:
  RefDatabase: Introduce findRef synonym for getRef
  RefDirectory: Look up several exact refs in one shot
2018-12-28 15:57:51 -05:00
Jonathan Nieder b4e415f8a9 Move first line parsing for v0 push out of BaseReceivePack
This simplifies the BaseReceivePack class and decreases its API
surface, which should make merging with ReceivePack easier.

Inspired by 6aca8899a5 (Move first line
parsing for v0/v1 pack negotiation out of UploadPack, 2018-09-17).

Change-Id: I1fc175d15aa7cb5968c26fc83a95480403af617c
2018-12-27 14:07:41 -08:00
Jonathan Nieder c1954f6c36 RefDatabase: Introduce findRef synonym for getRef
Using findRef instead of getRef makes it clearer that the caller wants
to search for the ref in the search path, instead of looking for a ref
that exactly matches the input.

This change introduces the new findRef method and deprecates getRef.
It updates Repository#findRef to use the new method, ensuring some
test coverage.  Other callers will be updated in followup changes.

A nice side effect of introducing the new findRef method is that it is
final and based on firstExactRef, so implementers can focus on
implementing the latter efficiently and do not have to carefully write
custom path search code respecting SEARCH_PATH.

Change-Id: Id3bb944344a9743705fd1f20193ab679298fa51c
Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-12-26 20:49:35 -08:00
Jonathan Nieder d2bab65470 RefDirectory: Look up several exact refs in one shot
Override exactRef(String...) and firstExactRef(String...) with
implementations specific to FileRepository.

The specialized implementations are similar to the generic ones from
RefDatabase, but because these use readRef directly instead of
exactRef, they only need to call fireRefsChanged once.

This will allow replacing RefDirectory#getRef with a generic
implementation that uses firstExactRef without hurting performance.

Change-Id: I1be1948bd6121c1a1e8152e201aab97e7fb308bb
Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-12-26 20:48:40 -08:00
Jonathan Nieder b2ec6405e4 RefDirectory: Do not use search path to find additional refs
Psuedorefs like FETCH_HEAD and MERGE_HEAD are supposed to be directly
under the .git directory, not in other locations in the SEARCH_PATH
like refs/ and refs/heads/.  Use exactRef to access them.

Change-Id: Iab8ac47008822fa78fc0691e239e518c34d7a98e
Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-12-26 19:29:27 -08:00
Matthias Sohn 56562221d6 Prepare 5.2.2-SNAPSHOT builds
Change-Id: I9487f6a59ed684ad13bcfbff7d6c730ae4f37030
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-12-27 03:32:48 +01:00
Matthias Sohn 24e89950e7 JGit v5.2.1.201812262042-r
Change-Id: Idfefc54e898f364407a931b787a26db2489b031c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-12-27 02:44:17 +01:00
Matthias Sohn a26bf7231e Merge branch 'stable-5.1' into stable-5.2
* stable-5.1:
  Prepare 5.1.6-SNAPSHOT builds
  JGit v5.1.5.201812261915-r

Change-Id: Idab456457200ec46f0e4e22bc6e54401b5b57285
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-12-27 01:42:13 +01:00
Matthias Sohn fafad4196d Prepare 5.1.6-SNAPSHOT builds
Change-Id: If3313d602aa57cfa031ba2c9ec03bd51b464dc19
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-12-27 01:35:30 +01:00
Matthias Sohn 510011b05c JGit v5.1.5.201812261915-r
Change-Id: I249a440d1ca1c997343da942ae55fcb27a645b92
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-12-27 01:16:15 +01:00