summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst
Commit message (Collapse)AuthorAgeFilesLines
* Merge "Fix off-by-one error in Strings.count()"Christian Halstrick2017-08-161-0/+73
|\
| * Fix off-by-one error in Strings.count()Thomas Wolf2017-08-141-0/+73
| | | | | | | | Change-Id: I0667b1624827d1cf0cc1b81f86c7bb44eafd68a7 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* | Merge "Use relative paths for attribute rule matching"Christian Halstrick2017-08-161-0/+27
|\|
| * Use relative paths for attribute rule matchingThomas Wolf2017-08-111-0/+27
| | | | | | | | | | | | | | | | | | | | Attribute rules must match against the entry path relative to the attribute node containing the rule. The global entry path is to be used only for the init and the global node (and of course the root node). Bug: 520677 Change-Id: I80389a2dc272a72312729ccd5358d7c75e1ea20a Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* | Send a detailed event on working tree modificationsThomas Wolf2017-08-152-466/+771
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently there is no way to determine the precise changes done to the working tree by a JGit command. Only the CheckoutCommand actually provides access to the lists of modified, deleted, and to-be-deleted files, but those lists may be inaccurate (since they are determined up-front before the working tree is modified) if the actual checkout then fails halfway through. Moreover, other JGit commands that modify the working tree do not offer any way to figure out which files were changed. This poses problems for EGit, which may need to refresh parts of the Eclipse workspace when JGit has done java.io file operations. Provide the foundations for better file change tracking: the working tree is modified exclusively in DirCacheCheckout. Make it emit a new type of RepositoryEvent that lists all files that were modified or deleted, even if the checkout failed halfway through. We update the 'updated' and 'removed' lists determined up-front in case of file system problems to reflect the actual state of changes made. EGit thus can register a listener for these events and then knows exactly which parts of the Eclipse workspace may need to be refreshed. Two commands manage checking out individual DirCacheEntries themselves: checkout specific paths, and applying a stash with untracked files. Make those two also emit such a new WorkingTreeModifiedEvent. Furthermore, merges may modify files, and clean, rm, and stash create may delete files. CQ: 13969 Bug: 500106 Change-Id: I7a100aee315791fa1201f43bbad61fbae60b35cb Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* | Merge branch 'stable-4.8'Matthias Sohn2017-08-151-0/+103
|\ \ | | | | | | | | | | | | | | | | | | | | | * stable-4.8: Update Oxygen Orbit p2 repository to R20170516192513 Fix exception handling for opening bitmap index files Change-Id: Ica20f5aa0d8a365fe3317765b93520b3abd5d342 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| * \ Merge branch 'stable-4.7' into stable-4.8Matthias Sohn2017-08-151-0/+103
| |\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-4.7: Update Oxygen Orbit p2 repository to R20170516192513 Fix exception handling for opening bitmap index files Change-Id: I1e4fcf84506ff4316567bbb1713e84d8d196c2a1 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| | * \ Merge branch 'stable-4.6' into stable-4.7Matthias Sohn2017-08-141-0/+103
| | |\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-4.6: Update Oxygen Orbit p2 repository to R20170516192513 Fix exception handling for opening bitmap index files Change-Id: I669fe48ce0034f9ea1977d38ee39099497422c1c Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| | | * \ Merge branch 'stable-4.5' into stable-4.6Matthias Sohn2017-08-141-0/+103
| | | |\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-4.5: Fix exception handling for opening bitmap index files Change-Id: Ifb511238e3e98b1bc9f79a990807b940a17ebaa6 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| | | | * | Fix exception handling for opening bitmap index filesChristian Halstrick2017-08-141-0/+103
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When creating a new PackFile instance it is specified whether this pack has an associated bitmap index file or not. This information is cached and the public method getBitmapIndex() will always assume a bitmap index file must exist if the cached data tells so. But it may happen that the packfiles are repacked during a gc in a different process causing the packfile, bitmap-index and index file to be deleted. Since JGit still has an open FileHandle on the packfile this file is not really deleted and can still be accessed. But index and bitmap index file are deleted. Fix getBitmapIndex() to invalidate the cached packfile instance if such a situation occurs. This problem showed up when a gerrit server was serving repositories which where garbage collected with native git regularly. Fetch and clone commands for certain repositories failed permanently after a native git gc had deleted old bitmap index files. Change-Id: I8e620bec74dd3f310ba42024f9a657062f868f0e Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | | | | | Do not apply pushInsteadOf to existing pushUrisThomas Wolf2017-08-141-4/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Per the git config documentation[1], pushInsteadOf is ignored when a remote has explicit pushUris. Implement this, and adapt tests. Up to now JGit mistakenly applied pushInsteadOf also to existing pushUris. If some repositories had relied on this mis-feature, pushes may newly suddenly fail (the uncritical case; the config just needs to be fixed) or even still succeed but push to unexpected places, namely to the non-rewritten pushUrls (the critical case). The release notes should point out this change. [1] https://git-scm.com/docs/git-config Bug: 393170 Change-Id: I38c83204d2ac74f88f3d22d0550bf5ff7ee86daf Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* | | | | | Record submodule paths with untracked changes as FileMode.GITLINKThomas Wolf2017-08-141-35/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bug: 520702 Change-Id: I9bb48af9e8f1f2ce7968a82297c7c16f1237f987 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* | | | | | Fix handling of pushInsteadOfThomas Wolf2017-08-141-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | According to [1], pushInsteadOf is 1. applied to the uris, not to the pushUris 2. ignored if a remote has an explicit pushUri JGit applied it only to the pushUris. As a result, pushInsteadOf was ignored for remotes having only a uri, but no pushUri. This commit implements (1) if there are no pushUris. I did not dare implement (2) because: * there are explicit tests for it that expect that pushInsteadOf gets applied to existing pushUrls, and * people may actually use and rely on this JGit behavior. [1] https://git-scm.com/docs/git-config Bug: 393170 Change-Id: I6dacbf1768a105190c2a8c5272e7880c1c9c943a Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* | | | | | Merge "Ensure EOL stream type is DIRECT when -text attribute is present"Christian Halstrick2017-08-141-0/+15
|\ \ \ \ \ \
| * | | | | | Ensure EOL stream type is DIRECT when -text attribute is presentThomas Wolf2017-08-111-0/+15
| | |_|_|_|/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Otherwise fancy combinations of attributes (binary or -text in combination with crlf or eol) may result in the corruption of binary data. Bug: 520910 Change-Id: I3ffc666c13d1b9d2ed987b69a67bfc7f42ccdbfc Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* | | | | | Rename extensions.refsStorage to refStorageShawn Pearce2017-08-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This matches the proposal that has been discussed at length on git-core mailing list and seems to be the accepted convention. Change-Id: I9f6ab15144826893d1e2a4b48a2d657d6dd445ec
* | | | | | Expose LongMap in util packageShawn Pearce2017-08-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a useful primitive collection type like IntList. Change-Id: I04b9b2ba25247df056eb3a1725602f1be6d3b440
* | | | | | NB: encode and decode 24-bit intsShawn Pearce2017-08-091-0/+65
|/ / / / / | | | | | | | | | | | | | | | Change-Id: Ie036dc46e5a88a4e87dc52e880505bbe34601ca7
* | | | | Remove unused import introduced in a551b64Matthias Sohn2017-08-011-1/+0
| | | | | | | | | | | | | | | | | | | | Change-Id: Ia6c3935cf061590e7305d0a80a1051e9aebcbb43 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | | | | Merge changes I424295df,Ib003f7c8David Pursehouse2017-08-011-24/+24
|\ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * changes: Treat RawText of binary data as file with one single line. Trim boilerplate in RawParseUtils_LineMapTest.
| * | | | | Treat RawText of binary data as file with one single line.Han-Wen Nienhuys2017-08-011-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This avoids executing mergeAlgorithm.merge on binary data, which is unlikely to be useful. Arguably, binary data should not make it to ResolveMerger#contentMerge, but this approach has the following advantages: * binary detection is exact, since it doesn't only look at the start of the blob. * it is cheap, as we have to iterate over the bytes anyway to find '\n'. Signed-off-by: Han-Wen Nienhuys <hanwen@google.com> Change-Id: I424295df1dc60a719859d9d7c599067891b15792
| * | | | | Trim boilerplate in RawParseUtils_LineMapTest.Han-Wen Nienhuys2017-07-271-24/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Signed-off-by: Han-Wen Nienhuys <hanwen@google.com> Change-Id: Ib003f7c8f2816dd57e941799a665e70ecd6645a2
* | | | | | Merge "Use w1 for hashCode of AbbreviatedObjectId"Terry Parker2017-07-281-3/+13
|\ \ \ \ \ \
| * | | | | | Use w1 for hashCode of AbbreviatedObjectIdShawn Pearce2017-07-281-3/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Very short abbreviations that are under 8 hex digits do not have values in w2. Use w1 as the Java hashCode() instead, so that the prefix of the abbreviation is always included in the hashing function used by any java.util.Collection type. Change-Id: Idaf69f86b62630ba4a022d31b4c293c6d138f557
* | | | | | | Merge "IntList: support contains(int)"David Pursehouse2017-07-281-0/+11
|\| | | | | |
| * | | | | | IntList: support contains(int)Shawn Pearce2017-07-281-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | LongList supports contains(long). IntList should also support contains(int). Change-Id: Ic7a81c3c25b0f10d92087b56e9f200b676060f63
* | | | | | | RefDirectory: Add in-process fair lock for atomic updatesDave Borowitz2017-07-281-0/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In a server scenario such as Gerrit Code Review, there may be many atomic BatchRefUpdates contending for locks on both the packed-refs file and some subset of loose refs. We already retry lock acquisition to improve this situation slightly, but we can do better by using an in-process lock. This way, instead of retrying and potentially exceeding their timeout, different threads sharing the same Repository instance can wait on a fair lock without having to touch the disk lock. Since a server is probably already using RepositoryCache anyway, there is a high likelihood of reusing the Repository instance. Change-Id: If5dd1dc58f0ce62f26131fd5965a0e21a80e8bd3
* | | | | | | RefDirectory: Retry acquiring ref locks with backoffDave Borowitz2017-07-282-0/+106
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If a repo frequently uses PackedBatchRefUpdates, there is likely to be contention on the packed-refs file, so it's not appropriate to fail immediately the first time we fail to acquire a lock. Add some logic to RefDirectory to support general retrying of lock acquisition. Currently, there is a hard-coded wait starting at 100ms and backing off exponentially to 1600ms, for about 3s of total wait. This is no worse than the hard-coded backoff that JGit does elsewhere, e.g. in FileUtils#delete. One can imagine a scheme that uses per-repository configuration of backoff, and the current interface would support this without changing any callers. Change-Id: I4764e11270d9336882483eb698f67a78a401c251
* | | | | | | Merge "Fix committing empty commits"David Pursehouse2017-07-281-0/+5
|\ \ \ \ \ \ \
| * | | | | | | Fix committing empty commitsChristian Halstrick2017-07-281-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Allow to explicitly create an empty commit even if committing only certain files. Bug: 510685 Change-Id: If9bf664d7cd824f8e5bd6765fa6cc739af3d7721
* | | | | | | | Merge "Support overriding a batch's reflog on a per-ReceiveCommand basis"David Pursehouse2017-07-281-0/+45
|\ \ \ \ \ \ \ \ | |/ / / / / / / |/| | | | | | |
| * | | | | | | Support overriding a batch's reflog on a per-ReceiveCommand basisDave Borowitz2017-07-261-0/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change-Id: I86a4b8f6b4f85b2bae64c1b121e4ee527d46de83
* | | | | | | | Merge changes from topic 'batch-ref-update-reflog'David Pursehouse2017-07-281-0/+316
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * changes: BatchRefUpdate: Expand javadocs and add @Nullable PackedBatchRefUpdate: Write reflogs Extract constants for reflog entry message prefixes
| * | | | | | | PackedBatchRefUpdate: Write reflogsDave Borowitz2017-07-261-0/+316
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On-disk reflogs are not stored in the packed-refs file, so we cannot ensure atomic updates. We choose the lesser evil of dropping failed reflog updates on the floor, rather than throwing an exception even though the underlying ref updates succeeded. Add tests for reflogs to BatchRefUpdateTest. Change-Id: Ia456ba9e36af8e01fde81b19af46a72378e614cd
* | | | | | | | Add commit check for head referencesZhen Chen2017-07-261-0/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make sure all refs/heads/* point to a commit object. Change-Id: I9c7cf347aaf63d5ef604d520c2383c6cf3043890 Signed-off-by: Zhen Chen <czhen@google.com>
* | | | | | | | Add connectivity check from referencesZhen Chen2017-07-261-0/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make sure all objects referenced by references are reachable. Stop at the first missing object. Change-Id: Ifcd7392c4321b17d9290bd87f038bc62bc10dabb Signed-off-by: Zhen Chen <czhen@google.com>
* | | | | | | | Add dfs fsck implementationZhen Chen2017-07-262-13/+202
|/ / / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | JGit already had some fsck-like classes like ObjectChecker which can check for an individual object. The read-only FsckPackParser which will parse all objects within a pack file and check it with ObjectChecker. It will also check the pack index file against the object information from the pack parser. Change-Id: Ifd8e0d28eb68ff0b8edd2b51b2fa3a50a544c855 Signed-off-by: Zhen Chen <czhen@google.com>
* | | | | | | Improve BatchRefUpdateTest readabilityDave Borowitz2017-07-251-205/+216
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Factor out helpers for setting up and executing updates. * Use common assert methods, with a special enum type that papers over the fact that there is no ReceiveCommand.Result for transaction aborted. * Static import ReceiveCommand.Type constants. * Add blank lines to separate repo setup, update execution, and asserts. Change-Id: Ic3717f94331abfc7ae3e92065f3fe32026bf7cea
* | | | | | | Move BatchRefUpdate tests to a new fileDave Borowitz2017-07-252-493/+402
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Run with @Parameterized, so we don't have to duplicate test setup for each atomic/non-atomic test. We still have to have two different sets of asserts for the cases where the behavior is different. In fact, this is a readability win: it emphasizes that performing the exact same setup except for the atomic setting will have different behavior. Change-Id: I78a8214075e204732a423341f14c09de273a7854
* | | | | | | Implement atomic BatchRefUpdates for RefDirectoryDave Borowitz2017-07-251-7/+296
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The existing packed-refs file provides a mechanism for implementing atomic multi-ref updates without any changes to the on-disk format or lockfile protocol. We just need to make sure that there are no loose refs involved in the transaction, which we can achieve by packing the refs while holding locks on all loose refs. Full details of the algorithm are in the PackedBatchRefUpdate javadoc. This change does not implement reflog support, which will come in a later change. Change-Id: I09829544a0d4e8dbb141d28c748c3b96ef66fee1
* | | | | | | Separate RefUpdate.Result.REJECTED_{MISSING_OBJECT,OTHER_REASON}Dave Borowitz2017-07-254-80/+94
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ReceiveCommand.Result has a slightly richer set of possibilities, so it makes sense for RefUpdate.Result to have more values in order to match. In particular, this allows us to return REJECTED_MISSING_OBJECT from RefUpdate when an object is missing. The comment in RefUpdate#safeParse about expecting some old objects to be missing is only applicable to the old ID, not the new ID. A missing new ID is a bug or programmer error, and we should not update a ref to point to one. Fix various tests that started failing because they depended for no good reason on setting refs to point to nonexistent objects; it's always easy to create a real object when necessary. It is possible that some downstream users of RefUpdate.Result might choose to handle one of the new statuses differently, for example by providing a more user-readable error message; that is not done in this change. Change-Id: I734b1c32d5404752447d9e20329471436ffe05fc
* | | | | | | Add missing newlines at ends of Java filesDavid Pursehouse2017-07-256-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change-Id: Iead36f53d57ead0eb3edd3f9efb63b6630c9c20c Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* | | | | | | Temporarily @Ignore flaky CommitCommandTest methodsDave Borowitz2017-07-251-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Change-Id: Ia2c42d014323bd29b85bf76f1a20c83f612406d7
* | | | | | | Fix matching ignores and attributes pattern of form a/b/**.Dmitry Pavlenko2017-07-242-1/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix patch matching for patterns of form a/b/** : this should not match paths like a/b but still match a/b/ and a/b/c. Change-Id: Iacbf496a43f01312e7d9052f29c3f9c33807c85d Signed-off-by: Dmitry Pavlenko <pavlenko@tmatesoft.com> Signed-off-by: Andrey Loskutov <loskutov@gmx.de> Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* | | | | | | Merge changes from topic 'packed-batch-ref-update'David Pursehouse2017-07-243-37/+179
|\ \ \ \ \ \ \ | |/ / / / / / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * changes: Add tests for updating single refs to missing objects Fix deleting symrefs RefDirectory: Throw exception if CAS of packed ref list fails ReceiveCommand: Explicitly check constructor preconditions BatchRefUpdate: Document when getPushOptions is null
| * | | | | | Add tests for updating single refs to missing objectsDave Borowitz2017-07-171-0/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The reader may find it surprising that this succeeds without incident unless there is peeling or a fast-forward check involved. This behavior may be changed in the future, but for now, just document the current behavior. Change-Id: I348b37e93e0264dc0905c4d58ce881852d1dfe5e
| * | | | | | Fix deleting symrefsDave Borowitz2017-07-171-4/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The RefDirectory implementation of doDelete never considered whether to delete a symref or its leaf, because the detachingSymbolicRef bit was never exposed from RefUpdate. The behavior was thus incorrectly to always delete the symref, never the leaf. There was no test for this behavior. The only thing that attempted to be a test was testDeleteHeadInBareRepo, but this test was broken for reasons unrelated to this bug. Specifically, it set the leaf to point to a completely nonexistent object, and then asserted that deleting HEAD resulted in NO_CHANGE. The only reason this test ever passed is because of a quirk of updateImpl, which treats a missing object as the same as null. This quirk aside, the test wasn't really testing the right thing. Turn this into a real test by writing out a real object and pointing the leaf at that. Also, add a test for the detachingSymbolicRef case, i.e. deleting the symref and leaving the leaf alone. Change-Id: Ib96d2a35b4f99eba0734725486085fc6f9d78aa5
| * | | | | | RefDirectory: Throw exception if CAS of packed ref list failsDave Borowitz2017-07-171-15/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The contents of the packedRefList AtomicReference should never differ from what we expect prior to writing, because this segment of the code is protected by the packed-refs lock file on disk. If it does happen, whether due to programmer error or a rogue process not respecting the locking protocol, it's better to let the caller know than to silently drop the whole commit operation on the floor. The existing concurrentOnlyOneWritesPackedRefs test is inherently nondeterministic as written, and was already about 6% flaky as measured by bazel: $ bazel test --runs_per_test=200 //org.eclipse.jgit.test:org_eclipse_jgit_internal_storage_file_GcPackRefsTest ... INFO: Elapsed time: 42.608s, Critical Path: 10.35s //org.eclipse.jgit.test:org_eclipse_jgit_internal_storage_file_GcPackRefsTest FAILED in 12 out of 200 in 1.6s Stats over 200 runs: max = 1.6s, min = 1.1s, avg = 1.3s, dev = 0.1s This flakiness was caused by the assumption that exactly one of the 2 threads would fail, when both might actually succeed in practice due to racing on the compare-and-swap. For whatever reason, this change affected the interleaving behavior in such a way that the flakiness jumped to around 50%. Making the interleaving of the test fully deterministic is beyond the scope of this change, but a simple tweak to the assertion is enough to make it pass consistently 200+ times both before and after this change. Change-Id: I5ff4dc39ee05bda88d47909acb70118f3d0c8f74
| * | | | | | ReceiveCommand: Explicitly check constructor preconditionsDave Borowitz2017-07-171-18/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some downstream code checks whether a ReceiveCommand is a create or a delete based on the type field. Other downstream code (in particular a good chunk of Gerrit code I wrote) checks the same thing by comparing oldId/newId to zeroId. Unfortunately, there were no strict checks in the constructor that ensures that zeroId is only set for oldId/newId if the type argument corresponds, so a caller that passed mismatched IDs and types would observe completely undefined behavior as a result. This is and always has been a misuse of the API; throw IllegalArgumentException so the caller knows that it is a misuse. Similarly, throw from the constructor if oldId/newId are null. The non-nullness requirement was already documented. Fix RefDirectoryTest to not do the wrong thing. Change-Id: Ie2d0bfed8a2d89e807a41925d548f0f0ce243ecf
* | | | | | | dfs: silence resource warnings in DfsBlockCacheTestShawn Pearce2017-07-191-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Change-Id: Ia934d8578592dc20837944d50acfb8920e260893