summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.junit/src/org/eclipse
Commit message (Collapse)AuthorAgeFilesLines
* Revert "Remove deprecatedMatthias Sohn2024-09-031-1/+22
| | | | | | | | | | | LocalDiskRepositoryTestCase#create(boolean,boolean)" This reverts commit 3682611cef41ade46cf5ac194f0674b46367a395. Reason: removing this deprecated method caused a ton of warnings about closing an already closed Repository when running tests. Change-Id: I3e9f224c55c167f92dad39caabfab5e43cf54cfb
* Remove deprecated LocalDiskRepositoryTestCase#create(boolean,boolean)Matthias Sohn2024-09-031-22/+1
| | | | Change-Id: I9eff2d405b5302753ff2ec1d0eab431bdba69fe0
* TestRepository: Add getInstant methodDavid Ostrovsky2023-10-051-0/+11
| | | | | | | | Error Prone is flagging Date-API as obsolete and recommends to migrate to Instant and LocalDate. Given that more JGit users starting to migrate to new Time API, offer getInstant method. Change-Id: Ie010b76d1c213cd0a645f716783ed2d57fc78071
* [errorprone] Add missing javadoc summaryMatthias Sohn2023-09-251-0/+2
| | | | | | see https://google.github.io/styleguide/javaguide.html#s7.2-summary-fragment Change-Id: Iaf4a6b55d4e4c59b7a2da3451164abb1bb47d4a1
* [errorprone] Fix BadImportMatthias Sohn2023-09-251-4/+4
| | | | | | See https://errorprone.info/bugpattern/BadImport Change-Id: Iea98b15862ed0bc4bcad759a7240133769680808
* [errorprone] MockSystemReader: fix CatchAndPrintStackTraceMatthias Sohn2023-09-251-1/+1
| | | | | | | See https://errorprone.info/bugpattern/CatchAndPrintStackTrace Change-Id: If1ec66ea65eaef9311a650d8a5741a03ac76cb88 Change-Id: Ic52205bab141a4e3c6a9fefecf749f1ccfc0e491
* Use ShutdownHook to gracefully handle JVM shutdownMatthias Sohn2023-09-121-17/+17
| | | | | | | | | | in all classes which already registered their own shutdown hook - CloneCommand - GC#PidLock - FS#FileStoreAttributes - LocalDiskRepositoryTestCase#Cleanup Change-Id: I3efc1f83f3cbbf43eeeaaedcd2bee1ef31971a72
* Default for global (user) git ignore fileThomas Wolf2023-06-191-5/+19
| | | | | | | | | | | | | | | | | | | | C git has a default for git config core.excludesfile: "Its default value is $XDG_CONFIG_HOME/git/ignore. If $XDG_CONFIG_HOME is either not set or empty, $HOME/.config/git/ignore is used instead." [1] Implement this in the WorkingTreeIterator$RootIgnoreNode. To make this testable, mock the "user.home" directory for all JGit tests, otherwise tests might pick up a real user's git ignore file. Also ensure that JGit code always reads "user.home" via the SystemReader. Add tests for both locations. [1] https://git-scm.com/docs/gitignore#_description Bug: 436127 Change-Id: Ie510259320286c3c13a6464a37da1bd9ca1e373a Signed-off-by: Thomas Wolf <twolf@apache.org>
* Fix all Javadoc warnings and fail on themAntoine Musso2023-06-169-36/+130
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes all the javadoc warnings, stops ignoring doclint 'missing' category and fails the build on javadoc warnings for public and protected classes and class members. Since javadoc doesn't allow access specifiers when specifying doclint configuration we cannot set `-Xdoclint:all,-missing/private` hence there is no simple way to skip private elements from doclint. Therefore we check javadoc using the Eclipse Java compiler (which is used by default) and javadoc configuration in `.settings/org.eclipse.jdt.core.prefs` files. This allows more fine grained configuration. We can reconsider this when javadoc starts supporting access specifiers in the doclint configuration. Below are detailled explanations for most modifications. @inheritDoc =========== doclint complains about explicits `{@inheritDoc}` when the parent does not have any documentation. As far as I can tell, javadoc defaults to inherit comments and should only be used when one wants to append extra documentation from the parent. Given the parent has no documentation, remove those usages which doclint complains about. In some case I have moved up the documentation from the concrete class up to the abstract class. Remove `{@inheritDoc}` on overriden methods which don't add additional documentation since javadoc defaults to inherit javadoc of overridden methods. @value to @link =============== In PackConfig, DEFAULT_SEARCH_FOR_REUSE_TIMEOUT and similar are forged from Integer.MAX_VALUE and are thus not considered constants (I guess cause the value would depends on the platform). Replace it with a link to `Integer.MAX_VALUE`. In `StringUtils.toBoolean`, @value was used to refer to the `stringValue` parameter. I have replaced it with `{@code stringValue}`. {@link <url>} to <a> ==================== @link does not support being given an external URL. Replaces them with HTML `<a>`. @since: being invalid ===================== org.eclipse.jgit/src/org/eclipse/jgit/util/Equality.java has an invalid tag `@since: ` due to the extra `:`. Javadoc does not complain about it with version 11.0.18+10 but does with 11.0.19.7. It is invalid regardless. invalid HTML syntax =================== - javadoc doesn't allow <br/>, <p/> and </p> anymore, use <br> and <p> instead - replace <tt>code</tt> by {@code code} - <table> tags don't allow summary attribute, specify caption as <caption>caption</caption> to fix this doclint visibility issue ======================== In the private abstract classes `BaseDirCacheEditor` and `BasePackConnection` links to other methods in the abstract class are inherited in the public subclasses but doclint gets confused and considers them unreachable. The HTML documentation for the sub classes shows the relative links in the sub classes, so it is all correct. It must be a bug somewhere in javadoc. Mute those warnings with: @SuppressWarnings("doclint:missing") Misc ==== Replace `<` and `>` with HTML encoded entities (`&lt; and `&gt;`). In `SshConstants` I went enclosing a serie of -> arrows in @literal. Additional tags =============== Configure maven-javad0c-plugin to allow the following additional tags defined in https://openjdk.org/jeps/8068562: - apiNote - implSpec - implNote Missing javadoc =============== Add missing @params and descriptions Change-Id: I840056389aa59135cfb360da0d5e40463ce35bd0 Also-By: Matthias Sohn <matthias.sohn@sap.com>
* BatchingProgressMonitor: expose time spent per taskMatthias Sohn2023-02-271-0/+5
| | | | | | | | | | | | | | | | | | | Display elapsed time per task if enabled via ProgressMonitor#showDuration or if system property or environment variable GIT_TRACE_PERFORMANCE is set to "true". If both the system property and the environment variable are set the system property takes precedence. E.g. using jgit CLI: $ GIT_TRACE_PERFORMANCE=true jgit clone https://foo.bar/foobar Cloning into 'foobar'... remote: Counting objects: 1 [0.002s] remote: Finding sources: 100% (15531/15531) [0.006s] Receiving objects: 100% (169737/169737) [13.045s] Resolving deltas: 100% (67579/67579) [1.842s] Change-Id: I4d624e7858b286aeddbe7d4e557589986d73659e
* Merge branch 'stable-6.2' into stable-6.3Matthias Sohn2022-11-201-0/+2
|\ | | | | | | | | | | | | | | | | | | | | | | * stable-6.2: Remove unused imports Suppress non-externalized String warnings Remove unused API problem filters Silence API errors Silence API errors Silence API warnings Change-Id: I71aa9f890c5eb05849ad16a00b9974da5e51171e
| * Silence API errorsMatthias Sohn2022-11-201-0/+2
| | | | | | | | Change-Id: I07c42fe9417edb0570dd475a7e935112a878a93b
* | [merge] Fix merge conflicts with symlinksThomas Wolf2022-09-071-0/+18
|/ | | | | | | | | | | | | | | | | | | | | Previous code would do a content merge on symlinks, and write the merge result to the working tree as a file. C git doesn't do this; it leaves a symlink in the working tree unchanged, or in a delete-modify conflict it would check out "theirs". Moreover, previous code would write the merge result to the link target, not to the link. This would overwrite an existing link target, or fail if the link pointed to a directory. In link/file conflicts or file/link conflicts, C git always puts the file into the working tree. Change conflict handling accordingly. Add tests for all the conflict cases. Bug: 580347 Change-Id: I3cffcb4bcf8e336a85186031fff23f0c4b6ee19d Signed-off-by: Thomas Wolf <twolf@apache.org>
* [test] Fix closing of test repositoriesNail Samatov2022-01-301-2/+19
| | | | | | | | | | | | | | | | Fix tests failing on Windows because Repository instance is created but not closed on tear down. Fix repositories closed twice, except in tests that test this behavior explicitly. Name the temporary directories the tests run in after the test method; that makes it easier to figure out in which tests repositories are closed twice if it should occur again in the future. Bug: 550111 Change-Id: I9398b58f0f36d2c29236d2a9a8599117d9083980 Signed-off-by: Nail Samatov <sanail@yandex.ru> Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* Merge branch 'stable-5.11' into stable-5.12Matthias Sohn2021-12-046-0/+11
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.11: Add missing @since tags Add missing @since tag Add missing @since tags Remove unused import in ApacheSshTest Update maven plugins Ignore missing javadoc in test bundles storage: file: De-duplicate File.exists()+File.isFile() RefDirectory.scanRef: Re-use file existence check done in snapshot creation FileSnapshot: Lazy load file store attributes cache Update eclipse-jarsigner-plugin to 1.3.2 Fix p2 repository URLs Change-Id: I72f39fbe82dd578d71aa2e3ceccebb39a25c4e00
| * Merge branch 'stable-5.10' into stable-5.11Matthias Sohn2021-12-046-0/+11
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.10: Add missing @since tags Add missing @since tag Add missing @since tags Remove unused import in ApacheSshTest Update maven plugins Ignore missing javadoc in test bundles storage: file: De-duplicate File.exists()+File.isFile() RefDirectory.scanRef: Re-use file existence check done in snapshot creation FileSnapshot: Lazy load file store attributes cache Update eclipse-jarsigner-plugin to 1.3.2 Fix p2 repository URLs Change-Id: I84c73e11381c31566a12033db94e9afdcef5b705
| | * Merge branch 'stable-5.9' into stable-5.10Matthias Sohn2021-12-046-0/+11
| | |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.9: Add missing @since tags Add missing @since tag Add missing @since tags Remove unused import in ApacheSshTest Update maven plugins Ignore missing javadoc in test bundles storage: file: De-duplicate File.exists()+File.isFile() RefDirectory.scanRef: Re-use file existence check done in snapshot creation FileSnapshot: Lazy load file store attributes cache Update eclipse-jarsigner-plugin to 1.3.2 Fix p2 repository URLs Change-Id: I971745b529ff903ea8bf9c3dbbc746fa09f41041
| | | * Merge branch 'stable-5.8' into stable-5.9Matthias Sohn2021-12-046-0/+11
| | | |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.8: Add missing @since tags Add missing @since tag Add missing @since tags Remove unused import in ApacheSshTest Update maven plugins Ignore missing javadoc in test bundles storage: file: De-duplicate File.exists()+File.isFile() RefDirectory.scanRef: Re-use file existence check done in snapshot creation FileSnapshot: Lazy load file store attributes cache Update eclipse-jarsigner-plugin to 1.3.2 Fix p2 repository URLs Change-Id: I5e7c204c0e4c428df6f3b27ba1fc06326983f27c
| | | | * Merge branch 'stable-5.6' into stable-5.7Matthias Sohn2021-12-046-0/+11
| | | | |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.6: Add missing @since tag Add missing @since tags Remove unused import in ApacheSshTest Update maven plugins Ignore missing javadoc in test bundles storage: file: De-duplicate File.exists()+File.isFile() RefDirectory.scanRef: Re-use file existence check done in snapshot creation FileSnapshot: Lazy load file store attributes cache Update eclipse-jarsigner-plugin to 1.3.2 Fix p2 repository URLs Change-Id: I53e6cb4b3a34b32d964e486c1ff3d130eed6e406
| | | | | * Merge branch 'stable-5.5' into stable-5.6Matthias Sohn2021-12-046-0/+11
| | | | | |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.5: Add missing @since tags Remove unused import in ApacheSshTest Update maven plugins Ignore missing javadoc in test bundles storage: file: De-duplicate File.exists()+File.isFile() RefDirectory.scanRef: Re-use file existence check done in snapshot creation FileSnapshot: Lazy load file store attributes cache Update eclipse-jarsigner-plugin to 1.3.2 Fix p2 repository URLs Change-Id: I007e92c12fde8d765b75f103e9d530aa0834b7d7
| | | | | | * Add missing @since tagsMatthias Sohn2021-12-046-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Change-Id: Id21e626201363dd3d0358bd709765e7fd07a0cbf
* | | | | | | Introduce getMergedInto(RevCommit commit, Collection<Ref> refs)Adithya Chakilam2021-03-141-0/+12
|/ / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In cases where we need to determine if a given commit is merged into many refs, using isMergedInto(base, tip) for each ref would cause multiple unwanted walks. getMergedInto() marks the unreachable commits as uninteresting which would then avoid walking that same path again. Using the same api, also introduce isMergedIntoAny() and isMergedIntoAll() Change-Id: I65de9873dce67af9c415d1d236bf52d31b67e8fe Signed-off-by: Adithya Chakilam <quic_achakila@quicinc.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | | | | | PackFile: Add id + ext based constructorsNasser Grainawi2021-03-071-9/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add new constructors to PackFile to improve a common use case where callers know the directory, id, and extension, but previously needed to construct a valid file name (with prefix, '.', etc) to create a PackFile. Most callers can use the variant that has id as an ObjectId, but provide an id as String variant too. Change-Id: I39e4466abe8c9509f5916d5bfe675066570b8585 Signed-off-by: Nasser Grainawi <quic_nasserg@quicinc.com>
* | | | | | Create a PackFile class for Pack filenamesNasser Grainawi2021-03-041-4/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The PackFile class is intended to be a central place to do all common pack filename manipulation and parsing to help reduce repeated code and bugs. Use the PackFile class in the Pack class and in many tests to ensure it works well in a variety of situations. Later changes will expand use of PackFiles to even more areas. Change-Id: I921b30f865759162bae46ddd2c6d669de06add4a Signed-off-by: Nasser Grainawi <quic_nasserg@quicinc.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | | | | | Rename PackFile to PackNasser Grainawi2021-02-101-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Pack better represents the purpose of the object and paves the way to add a PackFile object that extends File. Change-Id: I39b4f697902d395e9b6df5e8ce53078ce72fcea3 Signed-off-by: Nasser Grainawi <quic_nasserg@quicinc.com>
* | | | | | Fix SeparateClassloaderTestRunner on Java 9 or higherMatthias Sohn2021-02-051-4/+10
|/ / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since Java 9 the SystemClassLoader is no longer a URLClassLoader. Change-Id: I3aa834f1075e611c86fc4684fda6a50c684b3729 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* / / / / Close Repository to fix tests failing on WindowsNail Samatov2020-11-011-0/+8
|/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix tests failing on Windows because Repository instance is created but not closed on tear down. Change-Id: I72488ba5efeec95110926b1fbd56b7d96fca0d37 Signed-off-by: Nail Samatov <sanail@yandex.ru> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* / / / ResolveMerger: Adding test cases for GITLINK mergeDemetr Starshov2020-08-261-0/+16
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add test cases which cover content-merge resolve logic. Git clients try to agressively merge blobs by content, but GITLINK types of entries can't be merged with each other or with blobs. This change ensures all possible permutations which can trigger blob and GITLINK content merge are covered. Signed-off-by: Demetr Starshov <dstarshov@google.com> Change-Id: I7e83a28a14d4d2f9e0ba2b1cffbf3224fb7f3fef
* | | Merge branch 'stable-5.6'Matthias Sohn2020-02-281-1/+1
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.6: Cygwin expects forward slashes for commands to be run via sh.exe Make Logger instances final Move array designators from the variable to the type Change-Id: I9a5dc570deb478525bf48ef526d8cba5b19418bf Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| * | Make Logger instances finalDavid Pursehouse2020-02-271-1/+1
| | | | | | | | | | | | | | | Change-Id: Ibb997952917e47bc31a8cbe3863623bc959a8100 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* | | ErrorProne: Enable and fix UnusedException checkDavid Pursehouse2020-01-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-0413-494/+65
|/ / | | | | | | | | | | | | | | | | | | 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>
* | Merge branch 'stable-5.5'Matthias Sohn2019-11-112-2/+33
|\| | | | | | | | | | | | | | | | | | | | | * stable-5.5: BaseReceivePack: Fix the format Prepend hostname to subsection used to store file timestamp resolution Store filesystem timestamp resolution in extra jgit config SystemReader: extract updating config and its parents if outdated Change-Id: Iecfddce8081303af29badcdcd3d72a0da50c964f Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| * Store filesystem timestamp resolution in extra jgit configMatthias Sohn2019-11-092-2/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This avoids polluting hand-crafted user level config with auto-configured options which might disturb in environments where the user level config is replicated between different machines. Add a jgit config as parent of the system level config. Persist measured timestamp resolutions always in this jgit config and read it via the user global config. This has the effect that auto-configured timestamp resolution will be used by default and can be overridden in either the system level or user level config. Store the jgit config under the XDG_CONFIG_HOME directory following the XDG base directory specification [1] in order to ensure that we have write permissions to persist the file. This has the effect that each OS user will use its jgit config since they typically use different XDG_CONFIG_HOME directories. If the environment variable XDG_CONFIG_HOME is defined the jgit config file is located at $XDG_CONFIG_HOME/jgit/config otherwise the default is ~/.config/jgit/config. If you want to avoid redundant measurement for different OS users manually copy the values measured and auto-configured for one OS user to the system level git config. [1] https://wiki.archlinux.org/index.php/XDG_Base_Directory Bug: 551850 Change-Id: I0022bd40ae62f82e5b964c2ea25822eb55d94687 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | Enable and fix "Statement unnecessarily nested within else clause" warningsDavid Pursehouse2019-10-171-2/+1
|/ | | | | | | | | | | | | | | 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>
* Merge "RevWalk: Traverse all parents of UNINTERESTING commits"Jonathan Tan2019-08-261-1/+38
|\
| * RevWalk: Traverse all parents of UNINTERESTING commitsAlex Spradlin2019-08-261-1/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When firstParent is set, RevWalk traverses only the first parent of a commit, even though that commit is UNINTERESTING. Since we want the maximal UNINTERESTING set, we shouldn't prune any parents here. This issue is apparent only when some of the commits being traversed are unparsed, since walker.carryFlagsImpl() propagates the UNINTERESTING flag to all parsed ancestors, masking the issue. Therefore teach RevWalk to traverse all parents when a commit is UNINTERESTING and not only the first parent. Since this issue is masked by commit parsing, also test situations when the commits involved are unparsed. Signed-off-by: Alex Spradlin <alexaspradlin@google.com> Change-Id: I95e2ad9ae8f1f50fbecae674367ee7e0855519b1
* | Fix error occurring when SecurityManager is enabledNail Samatov2019-08-231-0/+94
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It's expected that jgit should work without native git installation. In such case Security Manager can be configured to deny access to the files outside of git repository. JGit tries to find cygwin installation. If Security manager restricts access to some folders in PATH, it should be considered that those folders are absent for jgit. Also JGit tries to detect if symbolic links are supported by OS. If security manager forbids creation of symlinks, it should be assumed that symlinks aren't supported. Bug: 550115 Change-Id: Ic4b243cada604bc1090db6cc1cfd74f0fa324b98 Signed-off-by: Nail Samatov <sanail@yandex.ru>
* | Merge branch 'stable-5.3' into stable-5.4Matthias Sohn2019-08-202-9/+68
|\ \ | |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.3: Fix NPE in RebaseTodoFile#parseComments Fix NPE in ObjectIdOwnerMap#get Fix NPE in CommitOnlyTest#getHead FileUtils#lastModifiedInstant should not log error if path doesn't exist Cache user global and system-wide git configurations Avoid setup and saving FileStoreAttributes compete for ~/.gitconfig lock Add missing dependencies for running FS_POSIXTest in Eclipse Fix javadoc for SystemReader#getInstance Improve retry handling when saving FileStoreAttributes fails Ensure FSTest uses MockSystemReader Make supportsAtomicCreateNewFile return true as default Update orbit to R20190602212107-2019-06 to enable backports from master Handle InvalidPathException in FS_POSIX#createNewFileAtomic Ensure root cause of lock creation failures is logged Implement toString in MockSystemReader and MockConfig LocalDiskRefTreeDatabaseTest shall use MockSystemReader Ensure LocalDiskRepositoryTestCase#setup fully uses MockSystemReader Ensure we use MockSystemReader in tests Override FileBasedConfig's save method in MockConfig Remove FileBasedConfig.load(boolean) introduced in d45219ba Disable debug log for FS in org.eclipse.jgit.test Bazel: enable logging for tests in org.eclipse.jgit.test LockFile: log exception if creation of lock file failed Stop using deprecated Constants.CHARACTER_ENCODING Change-Id: I43c2ab8b44c3e87d48e4072907ad169c81e3ffe0 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| * Merge branch 'stable-5.2' into stable-5.3Matthias Sohn2019-08-192-9/+68
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.2: Fix NPE in RebaseTodoFile#parseComments Fix NPE in ObjectIdOwnerMap#get Fix NPE in CommitOnlyTest#getHead FileUtils#lastModifiedInstant should not log error if path doesn't exist Cache user global and system-wide git configurations Avoid setup and saving FileStoreAttributes compete for ~/.gitconfig lock Add missing dependencies for running FS_POSIXTest in Eclipse Fix javadoc for SystemReader#getInstance Improve retry handling when saving FileStoreAttributes fails Ensure FSTest uses MockSystemReader Make supportsAtomicCreateNewFile return true as default Update orbit to R20190602212107-2019-06 to enable backports from master Handle InvalidPathException in FS_POSIX#createNewFileAtomic Ensure root cause of lock creation failures is logged Implement toString in MockSystemReader and MockConfig LocalDiskRefTreeDatabaseTest shall use MockSystemReader Ensure LocalDiskRepositoryTestCase#setup fully uses MockSystemReader Ensure we use MockSystemReader in tests Override FileBasedConfig's save method in MockConfig Remove FileBasedConfig.load(boolean) introduced in d45219ba Disable debug log for FS in org.eclipse.jgit.test Bazel: enable logging for tests in org.eclipse.jgit.test LockFile: log exception if creation of lock file failed Stop using deprecated Constants.CHARACTER_ENCODING Change-Id: If0c5010a2cf151ebebb2f2088fac3ee02c5007b9 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| | * Cache user global and system-wide git configurationsMatthias Sohn2019-08-182-5/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | So far the git configuration and the system wide git configuration were always reloaded when jgit accessed these global configuration files to access global configuration options which are not in the context of a single git repository. Cache these configurations in SystemReader and only reload them if their file metadata observed using FileSnapshot indicates a modification. Change-Id: I092fe11a5d95f1c5799273cacfc7a415d0b7786c Signed-off-by: Matthias Sohn <matthias.sohn@sap.com> Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
| | * Avoid setup and saving FileStoreAttributes compete for ~/.gitconfig lockMatthias Sohn2019-08-161-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | FS determines FileStore attributes in a background thread and tries to save the results to the global git configuration. This competed with LocalDiskRepositoryTestCase#setup trying to save changes to the same file requiring the same lock. This frequently led to one of the threads failing to acquire the lock. Fix this by first initiating determination of FileStore attributes which then uses a MockSystemReader not using a userConfig stored to disk which avoids this race for the lock. Change-Id: I30fcd96bc15100f8ef9b2a9eb3320bb5ace97c67 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| | * Implement toString in MockSystemReader and MockConfigMatthias Sohn2019-08-111-0/+11
| | | | | | | | | | | | | | | | | | This helps when debugging. Change-Id: I3d72e1ea207ba60be77a7a9a840abb71ade1271c Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| | * Ensure LocalDiskRepositoryTestCase#setup fully uses MockSystemReaderMatthias Sohn2019-08-111-5/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | FS#getFileStoreAttributes used the real userConfig and not the mocked one. This led to test errors when running tests with Bazel since it sandboxes tests which prevents they can write to ~/.gitconfig. Fix this by first preparing the MockedSystemReader and the mocked config before calling FS#getFileStoreAttributes. Also fix ConfigTest which broke due to this change since it inherits from LocalDiskRepositoryTestCase and calls its setup method which was changed here. We can no longer assert by comparing plain text since FS adds FileStoreAttributes to the mocked userConfig. Also the default options seen by this test changed since we now use a mocked config. Change-Id: I76bc7c94953fe979266147d3b309a68dda9d4dfe Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| | * Override FileBasedConfig's save method in MockConfigMatthias Sohn2019-08-101-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | This ensures we don't try to persist MockConfig using its superclasses save() method which fails with an NPE since MockConfig has no backing file. Change-Id: Ifba2d24c9438bb30d3828ed31a4c131f940b45eb Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | | [error prone] suppress AmbiguousMethodReference in AnyObjectIdMatthias Sohn2019-08-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Move the implementation of the static equals() method to a new method and suppress the error. Deprecate the old method to signal that we intend to remove it in the next major release. See https://errorprone.info/bugpattern/AmbiguousMethodReference Change-Id: I5e29c97f4db3e11770be589a6ccd785e2c9ac7f2 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | | Merge branch 'stable-5.3' into stable-5.4Matthias Sohn2019-08-086-38/+331
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.3: Fix OpenSshConfigTest#config FileSnapshot: fix bug with timestamp thresholding In LockFile#waitForStatChange wait in units of file time resolution Cache FileStoreAttributeCache per directory Fix FileSnapshot#save(long) and FileSnapshot#save(Instant) Persist minimal racy threshold and allow manual configuration Measure minimum racy interval to auto-configure FileSnapshot Reuse FileUtils to recursively delete files created by tests Fix FileAttributeCache.toString() Add test for racy git detection in FileSnapshot Repeat RefDirectoryTest.testGetRef_DiscoversModifiedLoose 100 times Fix org.eclipse.jdt.core.prefs of org.eclipse.jgit.junit Add missing javadoc in org.eclipse.jgit.junit Enhance RepeatRule to report number of failures at the end Fix FileSnapshotTests for filesystem with high timestamp resolution Retry deleting test files in FileBasedConfigTest Measure filesystem timestamp resolution already in test setup Refactor FileSnapshotTest to use NIO APIs Measure stored timestamp resolution instead of time to touch file Handle CancellationException in FileStoreAttributeCache Fix FileSnapshot#saveNoConfig Use Instant for smudge time in DirCache and DirCacheEntry Use Instant instead of milliseconds for filesystem timestamp handling Workaround SecurityException in FS#getFsTimestampResolution Fix NPE in FS$FileStoreAttributeCache.getFsTimestampResolution FS: ignore AccessDeniedException when measuring timestamp resolution Add debug trace for FileSnapshot Use FileChannel.open to touch file and set mtime to now Persist filesystem timestamp resolution and allow manual configuration Increase bazel timeout for long running tests Bazel: Fix lint warning flagged by buildifier Update bazlets to latest version Bazel: Add missing dependencies for ArchiveCommandTest Bazel: Remove FileTreeIteratorWithTimeControl from BUILD file Add support for nanoseconds and microseconds for Config#getTimeUnit Optionally measure filesystem timestamp resolution asynchronously Delete unused FileTreeIteratorWithTimeControl FileSnapshot#equals: consider UNKNOWN_SIZE Timeout measuring file timestamp resolution after 2 seconds Fix RacyGitTests#testRacyGitDetection Change RacyGitTests to create a racy git situation in a stable way Deprecate Constants.CHARACTER_ENCODING in favor of StandardCharsets.UTF_8 Fix non-deterministic hash of archives created by ArchiveCommand Update Maven plugins ecj, plexus, error-prone Update Maven plugins and cleanup Maven warnings Make inner classes static where possible Fix API problem filters Change-Id: Iec3ad6ccc194582cb844310dc172c3103dae4457 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| * | Merge branch 'stable-5.2' into stable-5.3Matthias Sohn2019-08-086-38/+332
| |\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.2: Fix OpenSshConfigTest#config FileSnapshot: fix bug with timestamp thresholding In LockFile#waitForStatChange wait in units of file time resolution Cache FileStoreAttributeCache per directory Fix FileSnapshot#save(long) and FileSnapshot#save(Instant) Persist minimal racy threshold and allow manual configuration Measure minimum racy interval to auto-configure FileSnapshot Reuse FileUtils to recursively delete files created by tests Fix FileAttributeCache.toString() Add test for racy git detection in FileSnapshot Repeat RefDirectoryTest.testGetRef_DiscoversModifiedLoose 100 times Fix org.eclipse.jdt.core.prefs of org.eclipse.jgit.junit Add missing javadoc in org.eclipse.jgit.junit Enhance RepeatRule to report number of failures at the end Fix FileSnapshotTests for filesystem with high timestamp resolution Retry deleting test files in FileBasedConfigTest Measure filesystem timestamp resolution already in test setup Refactor FileSnapshotTest to use NIO APIs Measure stored timestamp resolution instead of time to touch file Handle CancellationException in FileStoreAttributeCache Fix FileSnapshot#saveNoConfig Use Instant for smudge time in DirCache and DirCacheEntry Use Instant instead of milliseconds for filesystem timestamp handling Workaround SecurityException in FS#getFsTimestampResolution Fix NPE in FS$FileStoreAttributeCache.getFsTimestampResolution FS: ignore AccessDeniedException when measuring timestamp resolution Add debug trace for FileSnapshot Use FileChannel.open to touch file and set mtime to now Persist filesystem timestamp resolution and allow manual configuration Increase bazel timeout for long running tests Bazel: Fix lint warning flagged by buildifier Update bazlets to latest version Bazel: Add missing dependencies for ArchiveCommandTest Bazel: Remove FileTreeIteratorWithTimeControl from BUILD file Add support for nanoseconds and microseconds for Config#getTimeUnit Optionally measure filesystem timestamp resolution asynchronously Delete unused FileTreeIteratorWithTimeControl FileSnapshot#equals: consider UNKNOWN_SIZE Timeout measuring file timestamp resolution after 2 seconds Fix RacyGitTests#testRacyGitDetection Change RacyGitTests to create a racy git situation in a stable way Deprecate Constants.CHARACTER_ENCODING in favor of StandardCharsets.UTF_8 Fix non-deterministic hash of archives created by ArchiveCommand Update Maven plugins ecj, plexus, error-prone Update Maven plugins and cleanup Maven warnings Make inner classes static where possible Fix API problem filters Change-Id: I238adfd3080a5fed9d64c3c757297da6ea893918 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| | * Persist minimal racy threshold and allow manual configurationMatthias Sohn2019-08-062-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To enable persisting the minimal racy threshold per FileStore add a new config option to the user global git configuration: - Config section is "filesystem" - Config subsection is concatenation of - Java vendor (system property "java.vendor") - Java version (system property "java.version") - FileStore's name, on Windows we use the attribute volume:vsn instead since the name is not necessarily unique. - separated by '|' e.g. "AdoptOpenJDK|1.8.0_212-b03|/dev/disk1s1" The same prefix is used as for filesystem timestamp resolution, so both values are stored in the same config section - The config key for minmal racy threshold is "minRacyThreshold" as a time value, supported time units are those supported by DefaultTypedConfigGetter#getTimeUnit - measure for 3 seconds to limit runtime which depends on hardware, OS and Java version being used If the minimal racy threshold is configured for a given FileStore the configured value is used instead of measuring it. When the minimal racy threshold was measured it is persisted in the user global git configuration. Rename FileStoreAttributeCache to FileStoreAttributes since this class is now declared public in order to enable exposing all attributes in one object. Example: [filesystem "AdoptOpenJDK|11.0.3|/dev/disk1s1"] timestampResolution = 7000 nanoseconds minRacyThreshold = 3440 microseconds Change-Id: I22195e488453aae8d011b0a8e3276fe3d99deaea Signed-off-by: Matthias Sohn <matthias.sohn@sap.com> Also-By: Marc Strapetz <marc.strapetz@syntevo.com>
| | * Measure minimum racy interval to auto-configure FileSnapshotMatthias Sohn2019-08-062-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | By running FileSnapshotTest#detectFileModified we found that the sum of measured filesystem timestamp resolution and measured clock resolution may yield a too small interval after a file has been modified which we need to consider racily clean. In our tests we didn't find this behavior on all systems we tested on, e.g. on MacOS using APFS and Java 8 and 11 this effect was not observed. On Linux (SLES 15, kernel 4.12.14-150.22-default) we collected the following test results using Java 8 and 11: In 23-98% of 10000 test runs (depending on filesystem type and Java version) the test failed, which means the effective interval which needs to be considered racily clean after a file was modified is larger than the measured file timestamp resolution. "delta" is the observed interval after a file has been modified but FileSnapshot did not yet detect the modification: "resolution" is the measured sum of file timestamp resolution and clock resolution seen in Java. Java version filesystem failures resolution min delta max delta 1.8.0_212-b04 btrfs 98.6% 1 ms 3.6 ms 6.6 ms 1.8.0_212-b04 ext4 82.6% 3 ms 1.1 ms 4.1 ms 1.8.0_212-b04 xfs 23.8% 4 ms 3.7 ms 3.9 ms 1.8.0_212-b04 zfs 23.1% 3 ms 4.8 ms 5.0 ms 11.0.3+7 btrfs 98.1% 3 us 0.7 ms 4.7 ms 11.0.3+7 ext4 98.1% 6 us 0.7 ms 4.7 ms 11.0.3+7 xfs 98.5% 7 us 0.1 ms 8.0 ms 11.0.3+7 zfs 98.4% 7 us 0.7 ms 5.2 ms Mac OS 1.8.0_212 APFS 0% 1 s 11.0.3+7 APFS 0% 6 us The observed delta is not distributed according to a normal gaussian distribution but rather random in the observed range between "min delta" and "max delta". Run this test after measuring file timestamp resolution in FS.FileAttributeCache to auto-configure JGit since it's unclear what mechanism is causing this effect. In FileSnapshot#isRacyClean use the maximum of the measured timestamp resolution and the measured "delta" as explained above to decide if a given FileSnapshot is to be considered racily clean. Add a 30% safety margin to ensure we are on the safe side. Change-Id: I1c8bb59f6486f174b7bbdc63072777ddbe06694d Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>