Commit Graph

5315 Commits

Author SHA1 Message Date
Thomas Wolf d661b9f43a TLS support on IBM JDKs
SSLContext.getInstance("TLS") by default behaves differently on IBM
JDK than on Oracle or OpenJDK.[1] On IBM JDK one gets sockets that
have only TLSv1 enabled, which makes HTTPS connections fail since most
servers refuse this old protocol version. On Oracle JDK/OpenJDK, one
gets sockets with all available protocol versions enabled.

Explicitly enable all available TLS protocol versions to make
HTTPS connections work also on IBM JDK.

[1] https://www.ibm.com/support/knowledgecenter/en/SSYKE2_8.0.0/com.ibm.java.security.component.80.doc/security-component/jsse2Docs/matchsslcontext_tls.html#matchsslcontext_tls

Bug: 558709
Change-Id: I5ffc57a78e67a6239b9dad54840a49a8ed28930a
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2020-01-03 20:48:25 +01:00
Matthias Sohn 9e6f09c700 Merge branch 'stable-5.6'
* stable-5.6:
  Hooks: avoid problems with backslashes in paths

Change-Id: Ia9e4aca11de5a465b60898a37441a17133f6355b
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-12-26 00:19:20 +01:00
Thomas Wolf 2323d7a1ef Hooks: avoid problems with backslashes in paths
Calling sh -c with a script path containing backslashes may fail since
the shell may try to process them as escape characters.

Instead of calling

  sh.exe -c 'C:\path\script "$@"' 'C:\path\script' other args

call

  sh.exe -c '$0 "$@"' 'C:\path\script' other args

which avoids this escape processing.

Note that this is not specific to Windows. If the path or the script
name contain backslashes, this also occurs on Unix.

Bug: 558577
Change-Id: I47d63db6f8644f956c55c42b07dbcad7d7f305aa
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2019-12-24 13:31:23 +01:00
Lars Vogel ccd68dc1dc Using StringBuilder in StringUtils#capitalize method
StringBuffer is synchronized which is slower and should be replaced with
StringBuilder according to its Javadoc.

Change-Id: If4d4a5a49da289ded34bbec97132ab7636b937cc
Signed-off-by: Lars Vogel <Lars.Vogel@vogella.com>
2019-12-18 00:18:41 +01:00
Matthias Sohn 83f90a274c Set config "extensions" option when converting ref storage format
When converting to reftable format the option extensions.refStorage must
be set to "reftable" [1]. When converting back to refdir format this
config option needs to be removed.

Introduce constants for refStorage config options, also for the
"reftree" format.

[1] https://git.eclipse.org/r/plugins/gitiles/jgit/jgit/+/master/Documentation/technical/reftable.md#Version-1

Change-Id: I190222fa5edc1ad7309daa9be17ca934ff7971e3
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-12-15 10:15:46 +01:00
Matthias Sohn 57f22d6db1 Externalize error message in FileRepository#convertRefStorage
Change-Id: I5d3acaa883ee7eb8d244b55b3e708cbe018690c6
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-12-14 22:10:12 +01:00
Carsten Hammer 74bc50125d Replace chain of if statements with switch
and switch over strings where possible. Sometimes if statements are
chained and form a series of comparisons against constants. Using switch
statements improves readability.

Bug: 545856
Change-Id: Iacb78956ee5c20db4d793e6b668508ec67466606
Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-12-14 20:42:03 +01:00
Lars Vogel de234106b4 Minor - Removes unnecessary whitespace in ReftableReader
Change-Id: Id0c3463d1b03e258d8633298828ef7cfcd44e13f
Signed-off-by: Lars Vogel <Lars.Vogel@vogella.com>
2019-12-11 15:36:52 -05:00
Matthias Sohn 4cb80f897f Prepare 5.6.1-SNAPSHOT builds
Change-Id: Iaa72d2ea6764ccd4fb6a124b51d89fe6492c602d
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-12-11 02:04:21 +01:00
Matthias Sohn 9710c6292a JGit v5.6.0.201912101111-r
Change-Id: Icbb3b46f9d04e45da53936860e07e69fde12971c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-12-10 17:35:05 +01:00
Yunjie Li ba7f9c0612 Change the wildcard import to explicit ones.
Change-Id: Ia7bc1c4b6b82c127e1e4e0e657f69d249684e8e6
Signed-off-by: Yunjie Li <yunjieli@google.com>
2019-12-09 14:39:50 -08:00
Matthias Sohn 23c5ebff79 Merge branch 'stable-5.6'
* stable-5.6:
  Add ability to redirect stderr from git hooks
  Add possibility to get pure stderr output from AbortedByHookException

Change-Id: Ifc02675542dad6ced25fdd8b9fae80b5736db688
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-12-09 10:15:05 +01:00
Tim Neumann 23125abc20 Add ability to redirect stderr from git hooks
This will change the behavior in the CLI to resemble that of C-Git more
closely by printing the stderr of the hooks to the CLI stderr
independently of the exit code of the hook.

This is also useful for the corresponding EGIT-Change, which will add
the ability to show the hook output in eclipse.
With this also the stderr can be shown even if the exit code is 0.

Bug: 553471
Change-Id: Ie7bc503fe39e270e9b93dd1108b5879f02a12b4c
Signed-off-by: Tim Neumann <Tim.Neumann@advantest.com>
2019-12-09 00:56:40 +01:00
Tim Neumann d1bdfcd0a8 Add possibility to get pure stderr output from AbortedByHookException
This is a preparation for the corresponding EGit change to remove
redundant output in the aborted by commit hook popup.

Bug: 553469
Change-Id: Id5f39a4df659fafc9d951668e6f53fed4380de9d
Signed-off-by: Tim Neumann <Tim.Neumann@advantest.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-12-09 00:55:09 +01:00
David Pursehouse 8a633bde8a Merge branch 'stable-5.6'
* stable-5.6:
  Cleanup CommitAndLogCommandTest
  CLI: Add support for excluding paths from Git log command

Change-Id: I2f48e16640ab1b13f0c32779422add3162260c50
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2019-12-06 10:20:07 +09:00
Matthias Sohn c42f314b6d Fix API check errors introduced in ReceivePack in 945d43d5
- add missing @since tag on new field connectivityChecker
- suppress warning for this added field which may affect subclasses
which is ok

Change-Id: Id6c22258efd10fa3847290f3dcfa42893b6ae882
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-12-05 23:34:40 +01:00
John Tipper 5bf226d50c CLI: Add support for excluding paths from Git log command
Git log supports the exclude pathspec, which allows for excluding paths
from the log command. JGit only supports adding paths to the log
command. See the following StackOverflow question for details:
https://stackoverflow.com/questions/59143934/java-jgit-how-to-get-git-
commits-not-affecting-certain-directories
This commit adds an excludePath() method to the log command. It does not
yet support regex or glob wildcards.

Change-Id: I8cd59950b87850b55a15c7e2ea5470145c9aae28
Signed-off-by: John Tipper <john_tipper@hotmail.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-12-05 22:38:12 +01:00
Demetr Starshov 945d43d507 ReceivePack: Moves connectivity check to separate class
Move all connectivity check to separate classes. Set default to be
FullConnectivityChecker i.e. checker which will check connectivity
from all advertised refs. Add ability to set other connectivity
checker which can use different approach.

Signed-off-by: Demetr Starshov <dstarshov@google.com>
Change-Id: Ibb107dbfbdde8ad109be25b5ecf42be7660ef736
2019-12-05 11:46:36 -08:00
David Pursehouse f350e889d6 Merge branch 'stable-5.6'
* stable-5.6:
  ReftableTest: Clean up boxing warnings on usage of String.format
  MergedReftable: Remove unnecessary semicolon

Change-Id: Id35406acfdd91c3ddf17ce4e1023395f774774f2
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2019-12-05 10:46:44 +09:00
Matthias Sohn a4ad83c96c Suppress API error for RefDatabase.hasFastTipsWithSha1()
This method was added in stable-5.6 after 5.6 RC1 was tagged. It's shown
as an API error when using 5.6.0 RC1 as the API baseline for master.
This suppression can be removed when 5.6 is released which will serve as
the API baseline for 5.7.

Change-Id: Ic6359fe59ed2d2a9431583b0854ec86bbac76880
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-12-05 01:56:31 +01:00
Matthias Sohn 1cb37e89d2 Remove API filters which became obsolete after bumping version to 5.7.0
Change-Id: I00b8d3e2e1023794f24d9447e3b0214c50353838
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-12-05 01:55:04 +01:00
Matthias Sohn e2c12c3910 Add missing @since tag for ReceivePack#receiveWithExceptionPropagation
Change-Id: Ie64abc3e5bcf6dbaecfa8f2cb50796703ebd1f39
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-12-05 01:51:29 +01:00
David Pursehouse 62d16a9146 MergedReftable: Remove unnecessary semicolon
Change-Id: I67d2b8ba3cd8f94363cea864918c8ed6026f2d18
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2019-12-05 09:42:52 +09:00
Matthias Sohn f487a9eb2e Prepare 5.7.0-SNAPSHOT builds
Change-Id: I7efa0cd08dee711d6fefc3e6bb478a3cb11fe85c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-12-05 01:32:59 +01:00
Matthias Sohn 08d4c63b6d Merge branch 'stable-5.6'
* stable-5.6:
  Introduce RefDatabase#hasFastTipsWithSha1
  Update Orbit to R20191126223242 for 2019-12
  Prepare 5.6.0-SNAPSHOT builds
  JGit v5.6.0.201912041214-rc1
  Prepare 5.6.0-SNAPSHOT builds
  JGit v5.6.0.201911271000-m3

Change-Id: Id33b054131bbcd27a0ae7200f564775049698d2c
2019-12-05 01:31:32 +01:00
Han-Wen Nienhuys 5185d288c1 Introduce RefDatabase#hasFastTipsWithSha1
The reftable format supports fast inverse (SHA1 => ref) queries.

If the ref database does not support fast inverse queries, it may be
advantageous to build a complete SHA1 to ref map in advance for
multiple uses. To let applications decide, this function indicates
whether the inverse map is available.

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Change-Id: Idaf7e01075906972ec21332cade285289619c2b3
2019-12-04 23:35:32 +01:00
Matthias Sohn 473527e42c Prepare 5.6.0-SNAPSHOT builds
Change-Id: I5e737ff7f262fdd43fc975a0b3594c8b33919663
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-12-04 22:13:56 +01:00
Matthias Sohn a7e454bc51 JGit v5.6.0.201912041214-rc1
Change-Id: I5ed21fbc5f83096bf0b79f2aa751db415cbcc7e8
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-12-04 18:14:43 +01:00
Masaya Suzuki e75e95e535 transport: Add methods that do not handle exceptions
Same as UploadPack. These methods do not handle exceptions and the
caller can handle them. This makes it possible to customize the error
handling.

Change-Id: Ia5203f80133cb5b3e5d754859b4167ac920eaf14
Signed-off-by: Masaya Suzuki <masayasuzuki@google.com>
2019-12-02 14:09:55 -08:00
Masaya Suzuki 6ccff81428 transport: Let users specify an error handler for unpacking a pack file
Currently, there's no way for a user to customize the error handler for
the exception happened during unpacking an incoming pack file. Create an
error handler class and let them specify one.

Change-Id: Id07638ee58c88e1365181c3ddd17ee0266f3934d
Signed-off-by: Masaya Suzuki <masayasuzuki@google.com>
2019-12-02 14:03:46 -08:00
Masaya Suzuki 224746e0f2 ReceivePack: Use try-with-resources for PostReceiveHook
Instead of dropping a second exception, use try-with-resources so that
exception thrown by a hook is attached as a suppressed exception.

This removes a need of holding an exception that is thrown while
unpacking an incoming packfile.

Change-Id: I74d8b944931abbf53d9d1ae5db2e889639fba027
Signed-off-by: Masaya Suzuki <masayasuzuki@google.com>
2019-12-02 14:01:49 -08:00
Masaya Suzuki 4fcc43a1de transport: Consolidate status reporting code
BaseReceivePack#sendStatusReport anyway needs to know
CAPABILITY_REPORT_STATUS. By moving this flag to BaseReceivePack,
simplify the status reporting code.

Change-Id: Iaa0878b1fc13057b687a7f01d25c85fd78c0423e
Signed-off-by: Masaya Suzuki <masayasuzuki@google.com>
2019-12-02 12:56:17 -08:00
Masaya Suzuki a91489f4a8 transport: Add ReceiveCommandErrorHandler
This gives a chance to handle an exception for a user. For example, when
an IOException is thrown while executing
`walk.parseAny(cmd.getNewId())`, it's always handled as
REJECTED_MISSING_OBJECT. However, IOException can mean a Git storage IO
error. By introducing an error handler class, a user can add a custom
error handler for these cases.

Change-Id: I3e03a536e1d8e137cb0f6e596d71642e72adde9e
Signed-off-by: Masaya Suzuki <masayasuzuki@google.com>
2019-12-02 12:49:15 -08:00
Masaya Suzuki 19293add84 transport: Move exception handler to the caller
Move exception handling code to the caller side. This is a preparation
for adding a custom error handler that is similar to UploadPack.

Note that `catch (Throwable t)` will not affect the exception spec since
Java will do an analysis of rethrown exceptions. See
https://docs.oracle.com/javase/8/docs/technotes/guides/language/catch-multiple.html.

Change-Id: I973a63d4b079c2cd1402afb3f2956e18b7d5a00c
Signed-off-by: Masaya Suzuki <masayasuzuki@google.com>
2019-12-02 12:33:11 -08:00
Masaya Suzuki 6bc3665764 transport: Move handling code to the caller side
This removes a raw IOException at one level. Later we'll add a custom
exception handling mechanism like UploadPack.

Change-Id: I52a7423798c97b032d848351be8b6f144776b017
Signed-off-by: Masaya Suzuki <masayasuzuki@google.com>
2019-12-02 12:25:03 -08:00
Matthias Sohn 4ea42bc816 Prepare 5.6.0-SNAPSHOT builds
Change-Id: I1e52d2dfb202b87ecb9d0273deaa2c8d8ce1864e
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-11-27 21:25:38 +01:00
Matthias Sohn 6c9aa82f70 JGit v5.6.0.201911271000-m3
Change-Id: I3810892c2bed947e4dfaa615a7b4d93eeb46abb9
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-11-27 16:01:20 +01:00
Jonathan Nieder 853098e13e Merge "ReceivePack: Open visibility for some methods" 2019-11-26 23:56:40 -05:00
Ivan Frade 5897bc4306 ReceivePack: Open visibility for some methods
This partially reverts Ic6bb5e66. It made private some methods in
ReceivePack that were protected before. At least two of those methods
(#init and #receivePackAndCheckConnectivity) are used by out-of-tree
subclasses for tracing and testing.

Make ReceivePack#init() and ReceivePack#receivePackAndCheckConnectivity
protected again to allow tracing and testing.

Change-Id: I7ff22c091fbfc2d94009c449d58e7c5ac9f4f759
Signed-off-by: Ivan Frade <ifrade@google.com>
2019-11-26 20:23:38 -08:00
Thomas Wolf 59f9d206c9 Make blame work correctly on merge conflicts
When a conflicting file was blamed, JGit would not identify lines
coming from the merge parents. The main cause for this was that
Blame and BlameCommand simply added the first DirCacheEntry found
for a file to its queue of candidates (blobs or commits) to consider.
In case of a conflict this typically is the merge base commit, and
comparing a auto-merged contents against that base would yield
incorrect results.

Such cases have to be handled specially. The candidate to be
considered by the blame must use the working tree contents, but
at the same time behave like a merge commit/candidate with HEAD
and the MERGE_HEADs as parents. Canonical git does something very
similar, see [1].

Implement that and add tests.

I first did this for the JGit pgm Blame command. When I then tried
to do the same in BlameCommand, I noticed that the latter also
included some fancy but incomplete CR-LF handling. In order to
be able to use the new BlameGenerator.prepareHead() also in
BlameCommand this CR-LF handling was also moved into BlameGenerator
and corrected in doing so.

(Just considering the git config settings was not good enough,
CR-LF behavior can also be influenced by .gitattributes, and even
by whether the file in the index has CR-LF. To correctly determine
CR-LF handling for check-in one needs to do a TreeWalk with at
least a FileTreeIterator and a DirCacheIterator.)

[1] https://github.com/git/git/blob/v2.22.0/blame.c#L174

Bug: 434330
Change-Id: I9d763dd6ba478b0b6ebf9456049d6301f478ef7c
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2019-11-27 03:03:06 +01:00
Jonathan Nieder aab5ee18fe Merge changes I8698001d,I5c1177ac
* changes:
  Add missing license header to ReftableDatabase
  Add missing license header to UploadPackRefSortingForReachabilityTest
2019-11-25 20:56:23 -05:00
Jonathan Nieder ffb979bef4 Add missing license header to ReftableDatabase
When this class was split from DfsReftableDatabase in commit
2b1e942729 (reftable: split off generic
code from DFS code, 2019-09-26), we forgot to carry over the license
header.

Change-Id: I8698001dfb69f58784df643ef0185ab2d55e52aa
Reported-by: Masaya Suzuki <masayasuzuki@google.com>
Signed-off-by: Jonathan Nieder <jrn@google.com>
2019-11-25 17:42:59 -08:00
Han-Wen Nienhuys 9cb8e2f310 RepositoryCache: don't require HEAD in git repositories
Reftable-enabled repositories don't have a file called HEAD. Check for
reftable/ instead.

This fixes repository creation on reftable in Gerrit.

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Change-Id: I778c2be01d96aaf135affae4b457b5fe5b483bee
2019-11-26 01:57:19 +01:00
Han-Wen Nienhuys e0744891fe FileRepository: cleanup refs outside refs/ on reftable conversion
Change-Id: Iab7d3a08906e826e26572f534512a09d3a5876b0
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-11-26 01:57:19 +01:00
Matthias Sohn 75038afc8e Silence API error for new method in ReachabilityChecker
Following OSGi semantic versioning which tolerates breaking implementers
in a minor release.

Change-Id: I4600c5ee9cd4ae209b69870a5d1367f83678617e
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-11-25 23:43:22 +01:00
Ivan Frade f5f5c80bf5 BitmappedReachabilityChecker: Use only one bitmap for the whole check
The checker is creating a new bitmap per branch leading to excessive
memory consumption. For the reachability check one bitmap with the
reachability of all branches aggregated is enough.

Build the reachability bitmap with a filter. The filter itself uses it
to emit only commits not reached before and the caller to check what
targets have been reached already.

BitmapCalculator is not required anymore.

Change-Id: Ic5c62f77fe0f188913215b7eaa51d849a9aae6a5
Signed-off-by: Ivan Frade <ifrade@google.com>
2019-11-21 14:07:04 -08:00
Ivan Frade 989a927a5f checkNotAdvertisedWants: Be lazy converting Ref to RevCommit
The ref points to an ObjectId that then is translated into a RevCommit.
This translation can be costly and with the incremental reachability
check is probably not needed for most of the elements.

Delay the translation from ObjectId to RevCommit to when it is needed.
Use Streams, that have the laziness built-in, all the way from Ref to
RevCommit.

This should reduce the latency for reachability checks over big sets of
references.

Change-Id: I28693087321b2beff3eaa1f3d2e7840ab0eedc6d
Signed-off-by: Ivan Frade <ifrade@google.com>
2019-11-21 09:30:19 -08:00
Ivan Frade a0204a4727 ReachabilityChecker: Receive a Stream instead of a Collection
Preparatory change. Converting ObjectIds to RevCommits is potentially
expensive and in the incremental reachability check, it is probably not
required for all elements in the collection.

Pass a Stream to the reachability checker. In the follow up we make
the conversion from ObjectId to RevCommit in the stream (i.e. on
demand). This should reduce the latency of reachability checks over big
sets of references.

Change-Id: I9f310e331de5b0bf8de34143bd7dcd34316d2fba
Signed-off-by: Ivan Frade <ifrade@google.com>
2019-11-21 09:30:19 -08:00
Ivan Frade 2ff0c0abaa UploadPack: Prioritize references for non-advertised wants checks
UploadPack needs to check if object ids that weren't advertised before
are reachable from the references visible to the user. In the
bitmap-based reachability check, this is done incrementally: checking
against one reference, if anything remaining adding a second and so on.
It is more efficient to check first more common references (e.g. refs/heads/*)

Sort the references for the reachability checker. This should solve the
connectivity earlier and require less bitmap creation and less memory.

Change-Id: I48ac10d71e29fab2d346479802401eaea4aacb5c
Signed-off-by: Ivan Frade <ifrade@google.com>
2019-11-21 09:30:19 -08:00
David Pursehouse fa1566f40c ReceivePack: Fix name hiding of 'atomic' member
Change-Id: Ia357d49ca793ff1cb86e7130bc1a5f59590496a9
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2019-11-17 10:30:46 -08:00