summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.pgm/src/org
Commit message (Collapse)AuthorAgeFilesLines
* Binary and CR-LF detection: lone CRs -> binaryThomas Wolf2021-10-312-3/+3
| | | | | | | | | | | | | | | | | | | C git considers not only files containing NUL bytes as binary but also files containing lone CRs. Implement this also for JGit. C git additionally counts printable vs. non-printable characters and considers files that have non_printable_count > printable_count / 128 also as binary. This is not implemented because such counting probably only makes sense if one looks at the full file or blob content. The Auto[CR]LF* streams in JGit look only at the first few KiB of a stream in order not to buffer too much. For the C git implementation, see [1]. [1] https://github.com/git/git/blob/7e27bd589d/convert.c#L35 Bug: 576971 Change-Id: Ia169b59bdbf1477f32ee2014eeb8406f81d4b1ab Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* Fix split package in bundle org.eclipse.jgit.ssh.jschMatthias Sohn2021-09-291-1/+1
| | | | | | | | The package org.eclipse.jgit.transport was split between org.eclipse.jgit and org.eclipse.jgit.ssh.jsch. Bug: 564544 Change-Id: I91d38e67c65ed97a880f8dc8f9559663b9eec33b
* Ignore IllegalStateException if JVM is already shutting downMatthias Sohn2021-08-291-2/+6
| | | | | | | | | Trying to register/unregister a shutdown hook when the JVM is already in shutdown throws an IllegalStateException. Ignore this exception since we can't do anything about it. Bug: 575367 Change-Id: Ic967c16c7f566c84778795315ab369e76668b364
* Fix typo in javadoc of PathTreeFilterHandlerMatthias Sohn2021-06-281-1/+1
| | | | Change-Id: Icf0dc814baf0dc44addd102d9c03b821b4022a84
* pgm: rewrite parents when --parents flag is passedkylezhao2021-05-261-0/+3
| | | | | | | | | | According to [1], we should rewrite parents in RevWalkTextBuiltin when variable parents is true. [1] https://git-scm.com/docs/git-rev-list#Documentation/git-rev-list.txt---parents Change-Id: If5dca3b280366969d0488fa895bc37253a797394 Signed-off-by: kylezhao <kylezhao@tencent.com>
* Implement ours/theirs content conflict resolutionThomas Wolf2021-04-192-2/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | Git has different conflict resolution strategies: * There is a tree merge strategy "ours" which just ignores any changes from theirs ("-s ours"). JGit also has the mirror strategy "theirs" ignoring any changes from "ours". (This doesn't exist in C git.) Adapt StashApplyCommand and CherrypickCommand to be able to use those tree merge strategies. * For the resolve/recursive tree merge strategies, there are content conflict resolution strategies "ours" and "theirs", which resolve any conflict hunks by taking the "ours" or "theirs" hunk. In C git those correspond to "-Xours" or -Xtheirs". Implement that in MergeAlgorithm, and add API to set and pass through such a strategy for resolving content conflicts. * The "ours/theirs" content conflict resolution strategies also apply for binary files. Handle these cases in ResolveMerger. Note that the content conflict resolution strategies ("-X ours/theirs") do _not_ apply to modify/delete or delete/modify conflicts. Such conflicts are always reported as conflicts by C git. They do apply, however, if one side completely clears a file's content. Bug: 501111 Change-Id: I2c9c170c61c440a2ab9c387991e7a0c3ab960e07 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* init: allow specifying the initial branch name for the new repositoryMatthias Sohn2021-02-221-0/+8
| | | | | | | | | | | Add option --initial-branch/-b to InitCommand and the CLI init command. This is the first step to implement support for the new option init.defaultBranch. Both were added to git in release 2.28. See https://git-scm.com/docs/git-init#Documentation/git-init.txt--bltbranch-namegt Bug: 564794 Change-Id: Ia383b3f90b5549db80f99b2310450a7faf6bce4c Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Fail clone if initial branch doesn't exist in remote repositoryMatthias Sohn2021-02-221-0/+3
| | | | | | | | | | jgit clone --branch foo <url> did not fail if the remote branch "foo" didn't exist in the remote repository being cloned. Bug: 546580 Change-Id: I55648ad3a39da4a5711dfa8e6d6682bb8190a6d6 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* GPG signature verification via BouncyCastleThomas Wolf2021-02-165-16/+219
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a GpgSignatureVerifier interface, plus a factory to create instances thereof that is provided via the ServiceLoader mechanism. Implement the new interface for BouncyCastle. A verifier maintains an internal LRU cache of previously found public keys to speed up verifying multiple objects (tag or commits). Mergetags are not handled. Provide a new VerifySignatureCommand in org.eclipse.jgit.api together with a factory method Git.verifySignature(). The command can verify signatures on tags or commits, and can be limited to accept only tags or commits. Provide a new public WrongObjectTypeException thrown when the command is limited to either tags or commits and a name resolves to some other object kind. In jgit.pgm, implement "git tag -v", "git log --show-signature", and "git show --show-signature". The output is similar to command-line gpg invoked via git, but not identical. In particular, lines are not prefixed by "gpg:" but by "bc:". Trust levels for public keys are read from the keys' trust packets, not from GPG's internal trust database. A trust packet may or may not be set. Command-line GPG produces more warning lines depending on the trust level, warning about keys with a trust level below "full". There are no unit tests because JGit still doesn't have any setup to do signing unit tests; this would require at least a faked .gpg directory with pre-created key rings and keys, and a way to make the BouncyCastle classes use that directory instead of the default. See bug 547538 and also bug 544847. Tested manually with a small test repository containing signed and unsigned commits and tags, with signatures made with different keys and made by command-line git using GPG 2.2.25 and by JGit using BouncyCastle 1.65. Bug: 547751 Change-Id: If7e34aeed6ca6636a92bf774d893d98f6d459181 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* [pgm] add option --timeout to clone commandMatthias Sohn2021-01-291-3/+5
| | | | Change-Id: I2ee74755045a8d9971ea0d9426db405829c7c679 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Merge changes I36d9b63e,I8c5db581,I2c02e89cJonathan Tan2021-01-271-1/+53
|\ | | | | | | | | | | | | * changes: Compare getting all refs except specific refs with seek and with filter Add getsRefsByPrefixWithSkips (excluding prefixes) to ReftableDatabase Add seekPastPrefix method to RefCursor
| * Compare getting all refs except specific refs with seek and with filterGal Paikin2021-01-271-1/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are currently two ways to get all refs except a specific ref, we add two methods that perform both and compare the two different approaches. This change adds two methods that compares the two different approaches of such query: 1. Get all the refs, and then filter by refs that don't start with the prefix (current approach). 2. Get all refs until encountering a ref that is part of the prefix we should exclude, skip using seekPastPrefix, and continue (new approach). This works since the refs are sorted. Specifically in Gerrit, we often have thousands of refs that are not refs/changes, and millions of refs/changes, hence the second approach should be much faster. In Jgit in general it's still expected to provide a better result even if we're skipping a smaller chunk of the refs since the complexity here is O(logn) with a binary search, rather than O(number of skipped refs). We ran this benchmark on a big chunk of chromium/src's reftable. To run it, we first create the reftable: git ls-remote https://chromium.googlesource.com/chromium/src > lsr bazel build org.eclipse.jgit.pgm:jgit && rm -rf /tmp/reftable* && \ ./bazel-bin/org.eclipse.jgit.pgm/jgit debug-benchmark-reftable \ --test write_stack lsr /tmp/reftable Then, we actually test the created reftable. Note that we can't test all of them at once since there are multiple ones, but below is a good example. bazel build org.eclipse.jgit.pgm:jgit && \ ./bazel-bin/org.eclipse.jgit.pgm/jgit debug-benchmark-reftable \ --test get_refs_excluding_ref --ref refs/changes \ lsr /tmp/reftable/000000000001-0000001e0371.ref Result: total time the action took using seek: 36925 usec total time the action took using filter: 874382 usec number of refs that start with prefix: 4266. number of refs that don't start with prefix: 1962695. Similarly for Android's biggest repository, platform/frameworks/base (still only partial result): total time the action took using seek: 9020 usec total time the action took using filter: 143166 usec number of refs that start with prefix: 296. number of refs that don't start with prefix: 60400. In conclusion, it's easy to see an improvement of a factor of 15-20x for large Gerrit repositories! Signed-off-by: Gal Paikin <paiking@google.com> Change-Id: I36d9b63eb259804c774864429cf2c761cd099cc3
* | [pgm] Use Apache sshd by defaultThomas Wolf2021-01-151-2/+2
|/ | | | Change-Id: I2a00059415fc2674469bc921827362801583af83 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* Tag message must not include the signatureThomas Wolf2021-01-101-5/+10
| | | | | | | | | | | | Signatures on tags are just tacked onto the end of the message. Getting the message must not return the signature. Compare [1] and [2] in C git, which both drop a signature at the end of an object body. [1] https://github.com/git/git/blob/21bf933/builtin/tag.c#L173 [2] https://github.com/git/git/blob/21bf933/ref-filter.c#L1276 Change-Id: Ic8a1062b8bc77f2d7c138c3fe8a7fd13b1253f38 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* Remove reftree and ketchHan-Wen Nienhuys2020-12-152-183/+3
| | | | | | | This was experimental code and never used in production. Change-Id: Ia3da7f2b82d9e365cec2ccf9397cbc47439cd150 Signed-off-by: Han-Wen Nienhuys <hanwen@google.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* LsRemote: suppress warning for non-externalized stringMatthias Sohn2020-12-151-1/+1
| | | | Change-Id: Ic1d8f2eef4a8de0a75d5b523b584b1ac275a8811 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* TagCommand: support signing annotated tagsThomas Wolf2020-12-071-2/+30
| | | | | | | | | | | | | | | | | | | | | Add the two config constants from C git that can switch on signing of annotated tags. Add them to the GpgConfig, and implement actually signing a tag in TagCommand. The interactions between command line options for "git tag" and config options is a bit murky in C git. There are two config settings for it: * tag.gpgSign is the main option, if set to true, it kicks in if neither -s nor -u are given on the command line. * tag.forceSignAnnotated signs only tags created via "git tag -m", but only if command-line option "-a" is not present. It applies even if tag.gpgSign is set explicitly to false. Giving -s or -u on the command line also forces an annotated tag since lightweight tags cannot be signed. Bug: 386908 Change-Id: Ic8a1a44b5f12f47d5cdf3aae2456c1f6ca9ef057 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* Add support for reading symrefs from pack capabilitiesLee Worrall2020-11-261-0/+15
| | | | | | | | | | | | | | | A SymbolicRef is added to the advertised refs for any symref in capabilities whose target is an advertised ref; this may replace an existing entry, such as HEAD. When cloning, if any advertised HEAD is symbolic then use the target rather than looking for an advertised ref with a matching objectId. Add --symref option to LsRemote command. Bug: 514052 Change-Id: Idfb48e6f6e8dcfe57a6896883fe6d84d533aa9d0 Signed-off-by: Lee Worrall <worrall.la@gmail.com>
* Implement git describe --allJason Yeo2020-10-131-0/+4
| | | | | | | | This enables jgit to use any refs in the refs/ namespace when describing commits. Signed-off-by: Jason Yeo <jasonyeo88@gmail.com> Change-Id: I1fa22d1c39c0e2f5e4c2938c9751d8556494ac26
* Decouple JSch from JGit CoreMatthias Sohn2020-06-011-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | Motivation: JSch serves as 'default' implementations of the SSH transport. If a client application does not use it then there is no need to pull in this dependency. Move the classes depending on JSch to an OSGi fragment extending the org.eclipse.jgit bundle and keep them in the same package as before since moving them to another package would break API. Defer moving them to a separate package to the next major release. Add a new feature org.eclipse.jgit.ssh.jsch feature to enable installation. With that users can now decide which of the ssh client integrations (JCraft JSch or Apache Mina SSHD) they want to install. We will remove the JCraft JSch integration in a later step due to the reasons discussed in bug 520927. Bug: 553625 Change-Id: I5979c8a9dbbe878a2e8ac0fbfde7230059d74dc2 Also-by: Michael Dardis <git@md-5.net> Signed-off-by: Michael Dardis <git@md-5.net> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com> Signed-off-by: David Ostrovsky <david@ostrovsky.org>
* Merge branch 'stable-5.6'Matthias Sohn2020-02-224-6/+6
|\ | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.6: Revert "Prepend hostname to subsection used to store file timestamp resolution" SimilarityRenameDetector: Fix inconsistent indentation Use indexOf(char) and lastIndexOf(char) rather than String versions Reorder modifiers to follow Java Language Specification GitmoduleEntry: Remove redundant import of class from same package Remove redundant "static" qualifier from enum declarations Change-Id: Ibb66bef7e8373f81e3e653c9843d986243446d68 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| * Reorder modifiers to follow Java Language SpecificationDavid Pursehouse2020-02-192-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Java Language Specification recommends listing modifiers in the following order: 1. Annotations 2. public 3. protected 4. private 5. abstract 6. static 7. final 8. transient 9. volatile 10. synchronized 11. native 12. strictfp Not following this convention has no technical impact, but will reduce the code's readability because most developers are used to the standard order. This was detected using SonarLint. Change-Id: I9cddecb4f4234dae1021b677e915be23d349a380 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
| * Remove redundant "static" qualifier from enum declarationsDavid Pursehouse2020-02-192-3/+3
| | | | | | | | | | | | | | Nested enum types are implicitly static. Change-Id: Id3d7886087494fb67bc0d080b4a3491fb4baac19 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* | Merge branch 'stable-5.7'Matthias Sohn2020-02-011-7/+22
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.7: Fix string format parameter for invalidRefAdvertisementLine WindowCache: add metric for cached bytes per repository pgm daemon: fallback to user and system config if no config specified WindowCache: add option to use strong refs to reference ByteWindows Replace usage of ArrayIndexOutOfBoundsException in treewalk Add config constants for WindowCache configuration options Change-Id: I0538bcba259f7229790a602ac9de120464a1260d
| * | Merge branch 'stable-5.6' into stable-5.7Matthias Sohn2020-02-011-7/+22
| |\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.6: Fix string format parameter for invalidRefAdvertisementLine WindowCache: add metric for cached bytes per repository pgm daemon: fallback to user and system config if no config specified WindowCache: add option to use strong refs to reference ByteWindows Replace usage of ArrayIndexOutOfBoundsException in treewalk Add config constants for WindowCache configuration options Change-Id: I79d615dff66493b60d3a4bcbdc57b9455e8d6673
| | * Merge branch 'stable-5.5' into stable-5.6Matthias Sohn2020-02-011-7/+22
| | |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.5: Fix string format parameter for invalidRefAdvertisementLine WindowCache: add metric for cached bytes per repository pgm daemon: fallback to user and system config if no config specified WindowCache: add option to use strong refs to reference ByteWindows Replace usage of ArrayIndexOutOfBoundsException in treewalk Add config constants for WindowCache configuration options Change-Id: I73d16b53df02bf735c2431588143efe225a4b5b4
| | | * Merge branch 'stable-5.4' into stable-5.5Matthias Sohn2020-02-011-7/+22
| | | |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.4: Fix string format parameter for invalidRefAdvertisementLine WindowCache: add metric for cached bytes per repository pgm daemon: fallback to user and system config if no config specified WindowCache: add option to use strong refs to reference ByteWindows Replace usage of ArrayIndexOutOfBoundsException in treewalk Add config constants for WindowCache configuration options Change-Id: I76a62da98182f0c504b1ea8b7d37cecdf4eea7e0
| | | | * Merge branch 'stable-5.3' into stable-5.4Matthias Sohn2020-02-011-7/+22
| | | | |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.3: Fix string format parameter for invalidRefAdvertisementLine WindowCache: add metric for cached bytes per repository pgm daemon: fallback to user and system config if no config specified WindowCache: add option to use strong refs to reference ByteWindows Replace usage of ArrayIndexOutOfBoundsException in treewalk Add config constants for WindowCache configuration options Change-Id: I12002dbfed9dff14fc6d2df9787d92eab5b1fa78
| | | | | * Merge branch 'stable-5.2' into stable-5.3Matthias Sohn2020-02-011-7/+22
| | | | | |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.2: Fix string format parameter for invalidRefAdvertisementLine WindowCache: add metric for cached bytes per repository pgm daemon: fallback to user and system config if no config specified WindowCache: add option to use strong refs to reference ByteWindows Replace usage of ArrayIndexOutOfBoundsException in treewalk Add config constants for WindowCache configuration options Change-Id: I790098be00ff3f9b8278d54ae4fb7c11311816e9
| | | | | | * Merge branch 'stable-5.1' into stable-5.2David Pursehouse2020-02-011-7/+22
| | | | | | |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.1: Fix string format parameter for invalidRefAdvertisementLine WindowCache: add metric for cached bytes per repository pgm daemon: fallback to user and system config if no config specified WindowCache: add option to use strong refs to reference ByteWindows Change-Id: I741059a1d0d5950ab5bc16ec70352655ee926a24 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| | | | | | | * pgm daemon: fallback to user and system config if no config specifiedMatthias Sohn2020-01-281-7/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If a config file is passed via option --config-file then use only the options defined in that file. This helps to concisely configure the daemon without side effects from global and system level git configs. Otherwise fallback to user and system level configs. Change-Id: I242de248f257579874ad0bfe4882a22502353b1f Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | | | | | | | ErrorProne: Enable and fix UnusedException checkDavid Pursehouse2020-01-2710-11/+21
|/ / / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-0477-2926/+385
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | | | | | | pgm: add option if reflogs should be written when converting to reftableMatthias Sohn2019-12-151-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Change-Id: Ie1c38121005965e63015d9a2af26a1caa88d73fa Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | | | | | | pgm: add option to configure if convert-ref-storage should create backupMatthias Sohn2019-12-151-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Change-Id: I926f116797508a5982961dfd30c2f765d9536eee Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | | | | | | Set config "extensions" option when converting ref storage formatMatthias Sohn2019-12-151-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | | | | | | Fix indentation in ConvertRefStorageMatthias Sohn2019-12-141-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Change-Id: Icd007b035e728f641c70cda68befa11a6197003f Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | | | | | | Replace chain of if statements with switchCarsten Hammer2019-12-142-33/+40
|/ / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | | | | | JGit pgm: Format blame output to match canonical gitThomas Wolf2019-11-271-23/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Canonical git shows the zero-Id for lines without commit, and uses the current time stamp for such lines. Also consider lines without commit when calculating the field widths. Change-Id: If0bee9b3e7f90861ad0f387f68e52ecc4a53dfd7 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* | | | | | Make blame work correctly on merge conflictsThomas Wolf2019-11-271-25/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | | | | | pgm: add write stats to BenchmarkReftableHan-Wen Nienhuys2019-11-161-1/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Usage: git ls-remote https://gerrit.googlesource.com/gerrit > lsr bazel build org.eclipse.jgit.pgm:jgit && rm -rf /tmp/reftable* && \ ./bazel-bin/org.eclipse.jgit.pgm/jgit debug-benchmark-reftable \ --test write_stack lsr /tmp/reftable On my Lenovo x250 laptop, this yields about 1ms per ref write. Signed-off-by: Han-Wen Nienhuys <hanwen@google.com> Change-Id: I31c74a08026ba188a3256ef6862dae9d85e6d5ef
* | | | | | pgm: add command to convert repo to reftableHan-Wen Nienhuys2019-11-161-0/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change-Id: I2f870699995da164a3e7adec430301ac7a53c425 Signed-off-by: Han-Wen Nienhuys <hanwen@google.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | | | | | [pgm] Add --mirror option to clone commandMatthias Sohn2019-10-211-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bug: 552173 Change-Id: Ic8a98b2e0f8f29afd599723f93e51b06b9f13314 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | | | | | Enable and fix "Statement unnecessarily nested within else clause" warningsDavid Pursehouse2019-10-175-31/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since [1] the gerrit project includes jgit as a submodule, and has this warning enabled, resulting in 100s of warnings in the console. Also enable the warning here, and fix them. At the same time, add missing braces around adjacent and nearby one-line blocks. [1] https://gerrit-review.googlesource.com/c/gerrit/+/227897 Change-Id: I81df3fc7ed6eedf6874ce1a3bedfa727a1897e4c Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* | | | | | reftable: pass OutputStream at construction timeHan-Wen Nienhuys2019-09-201-2/+2
|/ / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This makes the intended use of the classes more clear. It also simplifies generic functions that write reftables: they only need a ReftableWriter as argument, as the stream is carried within the ReftableWriter. Change-Id: Idbb06f89ae33100f0c0b562cc38e5b3b026d5181 Signed-off-by: Han-Wen Nienhuys <hanwen@google.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | | | | Merge branch 'stable-5.4' into stable-5.5Matthias Sohn2019-09-081-3/+0
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.4: Format BUILD files with buildifier Format BUILD files with buildifier [error prone] Suppress NonAtomicVolatileUpdate in SimpleLruCache Bazel: Format BUILD files with buildifier Bazel: Add fixes for --incompatible_load_java_rules_from_bzl Bazel: Fix warning about deprecated lib.bzl Format lib/BUILD with buildifier Bazel: Add fixes for --incompatible_load_java_rules_from_bzl Bazel: Bump minimum supported version to 0.29.0 Bazel: Bump skylib library version to 0.8.0 Use bazelisk to switch between used bazel version Bazel: Require minimum bazel version 0.17.1 Fix wrong placeholder index in error message packInaccessible JGitText: Remove unused externalized strings RepoText: Remove unused externalized string CLI: Remove unused externalized strings Change-Id: Idf3abd80ad3b00188f655e638d9908228770911f Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| * | | | Merge branch 'stable-5.3' into stable-5.4Matthias Sohn2019-09-081-3/+0
| |\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.3: Format BUILD files with buildifier [error prone] Suppress NonAtomicVolatileUpdate in SimpleLruCache Bazel: Format BUILD files with buildifier Bazel: Add fixes for --incompatible_load_java_rules_from_bzl Bazel: Fix warning about deprecated lib.bzl Format lib/BUILD with buildifier Bazel: Add fixes for --incompatible_load_java_rules_from_bzl Bazel: Bump minimum supported version to 0.29.0 Bazel: Bump skylib library version to 0.8.0 Use bazelisk to switch between used bazel version Bazel: Require minimum bazel version 0.17.1 Fix wrong placeholder index in error message packInaccessible JGitText: Remove unused externalized strings RepoText: Remove unused externalized string CLI: Remove unused externalized strings Change-Id: Iaea77a89fcd821df5dbb24f5e3e39e6d1dfc0bd4 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| | * | | Merge branch 'stable-5.2' into stable-5.3Matthias Sohn2019-09-081-4/+0
| | |\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.2: [error prone] Suppress NonAtomicVolatileUpdate in SimpleLruCache Bazel: Format BUILD files with buildifier Bazel: Add fixes for --incompatible_load_java_rules_from_bzl Bazel: Fix warning about deprecated lib.bzl Format lib/BUILD with buildifier Bazel: Add fixes for --incompatible_load_java_rules_from_bzl Bazel: Bump minimum supported version to 0.29.0 Bazel: Bump skylib library version to 0.8.0 Use bazelisk to switch between used bazel version Bazel: Require minimum bazel version 0.17.1 Fix wrong placeholder index in error message packInaccessible JGitText: Remove unused externalized strings RepoText: Remove unused externalized string CLI: Remove unused externalized strings Change-Id: I0d8b7f79177a20dc00c89e2cf0005eb3d3039532 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| | | * | Merge branch 'stable-5.1' into stable-5.2Matthias Sohn2019-09-071-4/+0
| | | |\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.1: Bazel: Fix warning about deprecated lib.bzl Format lib/BUILD with buildifier Bazel: Add fixes for --incompatible_load_java_rules_from_bzl Bazel: Bump minimum supported version to 0.29.0 Bazel: Bump skylib library version to 0.8.0 Use bazelisk to switch between used bazel version Bazel: Require minimum bazel version 0.17.1 Fix wrong placeholder index in error message packInaccessible JGitText: Remove unused externalized strings RepoText: Remove unused externalized string CLI: Remove unused externalized strings Change-Id: Iea37a8e39e9d4872dc607c9222dcf191ce4e4757 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| | | | * CLI: Remove unused externalized stringsDavid Pursehouse2019-09-071-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | Change-Id: Id44117dd72b0e71e9bf0046a3c965eeae64cf3ea Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>