summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Do not apply pushInsteadOf to existing pushUrisThomas Wolf2017-08-142-12/+25
| | | | | | | | | | | | | | | | | | | | 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-142-48/+59
| | | | | | Bug: 520702 Change-Id: I9bb48af9e8f1f2ce7968a82297c7c16f1237f987 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* Fix handling of pushInsteadOfThomas Wolf2017-08-142-6/+30
| | | | | | | | | | | | | | | | | | | | | | 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-142-6/+25
|\
| * Ensure EOL stream type is DIRECT when -text attribute is presentThomas Wolf2017-08-112-6/+25
| | | | | | | | | | | | | | | | | | 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-114-4/+4
| | | | | | | | | | | | | | 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-093-11/+34
| | | | | | | | | | | | This is a useful primitive collection type like IntList. Change-Id: I04b9b2ba25247df056eb3a1725602f1be6d3b440
* | NB: encode and decode 24-bit intsShawn Pearce2017-08-092-0/+106
|/ | | | Change-Id: Ie036dc46e5a88a4e87dc52e880505bbe34601ca7
* Update thread-safety warning about RepositoryShawn Pearce2017-08-081-1/+7
| | | | Change-Id: I1026a77cc688467d5a89a41121146f1bd3d56fa5
* ReflogWriter: Minor cleanupDave Borowitz2017-08-021-40/+37
| | | | | | | Remove unnecessary finals, use consistent punctuation in Javadoc, reflow some lines, etc. Change-Id: Ic64db41c86917725ac649022290621406156bcc4
* Eliminate SectionParser construction boilerplateDave Borowitz2017-08-0214-102/+16
| | | | | | | | | Happily, most anonymous SectionParser implementations can be replaced with FooConfig::new, as long as the constructor takes a single Config arg. Many of these, the non-public ones, can in turn be inlined. A few remaining SectionParsers can be lambdas. Change-Id: I3f563e752dfd2007dd3a48d6d313d20e2685943a
* Merge changes Ia6c3935c,I46a29eaeDavid Pursehouse2017-08-022-1/+20
|\ | | | | | | | | | | * changes: Remove unused import introduced in a551b64 Silence API errors caused by adding enum constants in dbb137e
| * Remove unused import introduced in a551b64Matthias Sohn2017-08-011-1/+0
| | | | | | | | Change-Id: Ia6c3935cf061590e7305d0a80a1051e9aebcbb43 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| * Silence API errors caused by adding enum constants in dbb137eMatthias Sohn2017-08-011-0/+20
| | | | | | | | Change-Id: I46a29eae7b617f3f43f270c40072a1c103ef77f2 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | Merge "git ignore .DS_Store"Matthias Sohn2017-08-011-0/+1
|\ \
| * | git ignore .DS_StoreDavid Pursehouse2017-07-281-0/+1
| | | | | | | | | | | | | | | Change-Id: I04887b91d07ee93f51d27c9a3597e258b9affc0b Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* | | Merge "git ignore all bazel folders"Matthias Sohn2017-08-011-5/+1
|\| | | |/ |/|
| * git ignore all bazel foldersDavid Pursehouse2017-07-281-5/+1
| | | | | | | | | | Change-Id: I38ae02d07020d8ccb8dc1ac4c0fa08ce93512f94 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* | Merge changes I424295df,Ib003f7c8David Pursehouse2017-08-012-29/+48
|\ \ | | | | | | | | | | | | | | | * 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-012-5/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-282-4/+14
|\ \ \
| * | | Use w1 for hashCode of AbbreviatedObjectIdShawn Pearce2017-07-282-4/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-282-0/+26
|\| | |
| * | | IntList: support contains(int)Shawn Pearce2017-07-282-0/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | LongList supports contains(long). IntList should also support contains(int). Change-Id: Ic7a81c3c25b0f10d92087b56e9f200b676060f63
* | | | Merge "Replace findbugs by spotbugs"David Pursehouse2017-07-282-11/+11
|\ \ \ \
| * | | | Replace findbugs by spotbugsMatthias Sohn2017-07-282-11/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | SpotBugs [1] is the spiritual successor of FindBugs, carrying on from the point where it left off with support of its community. [1] http://spotbugs.readthedocs.io/ Change-Id: I127f2c54b04265b6565e780116617ffa8a4d7eaf Signed-off-by: Matthias Sohn <matthias.sohn@sap.com> Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* | | | | RefDirectory: Add in-process fair lock for atomic updatesDave Borowitz2017-07-283-87/+173
|/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-284-28/+266
| |_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-282-1/+6
|\ \ \
| * | | Fix committing empty commitsChristian Halstrick2017-07-282-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-284-9/+193
|\ \ \ \ | |/ / / |/| | |
| * | | Support overriding a batch's reflog on a per-ReceiveCommand basisDave Borowitz2017-07-264-9/+193
| | | | | | | | | | | | | | | | Change-Id: I86a4b8f6b4f85b2bae64c1b121e4ee527d46de83
* | | | Merge changes from topic 'batch-ref-update-reflog'David Pursehouse2017-07-285-10/+449
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | * changes: BatchRefUpdate: Expand javadocs and add @Nullable PackedBatchRefUpdate: Write reflogs Extract constants for reflog entry message prefixes
| * | | BatchRefUpdate: Expand javadocs and add @NullableDave Borowitz2017-07-261-6/+17
| | | | | | | | | | | | | | | | Change-Id: I22d739a9677e24f36323dceadf7d375ac2f446e8
| * | | PackedBatchRefUpdate: Write reflogsDave Borowitz2017-07-262-0/+394
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * | | Extract constants for reflog entry message prefixesDave Borowitz2017-07-252-4/+38
| | | | | | | | | | | | | | | | | | | | | | | | Document explicitly that these are untranslated to (mostly) match C git. Change-Id: I3abcffb4fd611d053bf4373e5d6a14a66f7b9b6b
* | | | Add commit check for head referencesZhen Chen2017-07-263-0/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-262-0/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-2614-45/+1010
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-253-493/+480
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-256-41/+815
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-257-98/+187
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-2545-45/+45
| | | | | | | | | | | | | | | 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-243-12/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-249-44/+269
|\ \ \ | |/ / |/| | | | | | | | | | | | | | | | | | | | * 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-173-4/+78
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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