summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src
Commit message (Collapse)AuthorAgeFilesLines
* TransferConfig: Move reading advertisesid setting into TransferConfigJosh Brown2022-11-022-7/+13
| | | | | | | | | | | | | | The config setting to enable advertising the session-id capability is currently read in the ReceivePack class. This change moves it to a common location in the TransferConfig class so that it can be reused in other places like UploadPack. TransferConfig is also a more logical place for the setting as it resides in the `transfer` config section. Set the transfer.advertisesid setting to true to send the session-id capability to the client. Change-Id: If68ecb5e68b59f5c452a7992d02e3688b0a86747 Signed-off-by: Josh Brown <sjoshbrown@google.com>
* FirstWant: Parse client session-id if received.Josh Brown2022-11-021-3/+20
| | | | | | | | | | | | | | | | | In protocol V0 the client capabilities are appended to the first line. Parsing session-id is currently only supported during a ReceivePack operation. This change will parse the client session-id capability if it has been sent by the client. If the server sends the session-id capability to the client. The client may respond with a session ID of its own. FirstWant.fromLine will now parse the ID and make it available via the getClientSID method. This change does not add support to send the session-id capability from the server. The change is necessary to support session-id in UploadPack. Change-Id: Id3fe44fdf9a72984ee3de9cf40cc4e71d434df4a Signed-off-by: Josh Brown <sjoshbrown@google.com>
* ReceivePack: Receive and parse client session-id.Josh Brown2022-10-274-26/+104
| | | | | | | | | | | | | | | | | | | | | | | | Before this change JGit did not support the session-id capability implemented by native Git. This change implements advertising the capability from the server and parsing the session-id received from the client during a ReceivePack operation. Enable the transfer.advertisesid config setting to advertise the capability from the server. The client may send a session-id capability in response. If received, the value from this is parsed and available via the getClientSID method on the ReceivePack object. All capabilities in the form `capability=value` are now split into key value pairs at the first `=` character. This change replaces specific handling for the agent capability. This change does not add advertisement or parsing to UploadPack. This change also does not add the ability to send a session ID from the JGit client. https://git-scm.com/docs/protocol-v2/2.33.0#_session_idsession_id Change-Id: I56fb115e843b11b27e128c4ac427b05d5ec129d0 Signed-off-by: Josh Brown <sjoshbrown@google.com>
* PushCommand: allow users to disable use of bitmaps for pushkylezhao2022-10-213-1/+73
| | | | | | | | | | | | | | | | Reachability bitmaps are designed to speed up the "counting objects" phase of generating a pack during a clone or fetch. They are not optimized for Git clients sending a small topic branch via "git push". In some cases (see [1]), using reachability bitmaps during "git push" can cause significant performance regressions. Add PushCommand#setUseBitmaps(boolean) to allow users to tell "git push" not to use bitmaps. [1]: https://lore.kernel.org/git/87zhoz8b9o.fsf@evledraar.gmail.com/ Change-Id: I7fb7d26084ec63ddfa7249cf58abb85929b30e56 Signed-off-by: kylezhao <kylezhao@tencent.com>
* I/O redirection for the pre-push hookThomas Wolf2022-10-202-7/+86
| | | | | | | | | | | Fix and complete the implementation of calling the pre-push hook. Add the missing error stream redirect, and add the missing setters in Transport and in PushCommand. In Transport, delay setting up a PrePushHook such that it happens only on a push. Previously, the hook was set up also for fetches. Bug: 549246 Change-Id: I64a576dfc6b139426f05d9ea6654027ab805734e Signed-off-by: Thomas Wolf <twolf@apache.org>
* PackParser: populate full size of the PackedObjectInfosIvan Frade2022-10-181-1/+5
| | | | | | | | | | | We need the full size of the objects to populate the object-size index of a pack. This size is not always the one encoded in the object header in the pack (e.g. for deltas). Populate the full size of PackedObjectInfos in the PackParser, which is invoked when receiving a pack e.g. in a push. Change-Id: I102c20901aefb5e85047e2e526c0d733f82ff74b
* PackedObjectInfo: add the full size to the descriptionIvan Frade2022-10-181-0/+36
| | | | | | So we can create a size index later. Change-Id: I9db47ced929fbf045fc37bead6449bbf5484d308
* ObjectReader: New #isNotLargerThan methodIvan Frade2022-10-182-10/+43
| | | | | | | | | | | | | | | | Partial clones filter the objects to send by size calling ObjectReader#getObjectSize per object. This method reads the object from storage to get the size, which can be expensive. Offer a #isNotLargerThan method. The default implementation reads the object, but subclasses can override it with more efficient lookups (e.g. adding an index). isNotLargerThan gives implementors more options to optimize than getObjectIndex (e.g. can be implemented storing only object over certain size). Change-Id: Iefd4b1370cb9144f15cc0391286aeeb365e6ea87
* ObjectDirectory: avoid using File.getCanonicalPath()Jörg Kubitz2022-09-221-7/+15
| | | | | | | | | | | | | | | On java 17 + Windows OS java.io.File.getCanonicalPath is a very slow system call which uses most time during clone. That is since JDK 12 the result of File.getCanonicalPath is not cached anymore by default: https://bugs.openjdk.java.net/browse/JDK-8207005 * Use toRealPath() to follow symbolic links also on windows. * Cache the result. Bug: 580568 Change-Id: I95f4f5b2babefd7210ee4740646230225ebf3788
* AutoCRLFOutputStream: use BufferedOutputStreamJörg Kubitz2022-09-201-1/+4
| | | | | | | This should improve performance of autocrlf checkout. Bug: 580651 Change-Id: I2e2fe0273ac3c71fad50a575278234804ee28306
* CloneCommand: set HEAD also when not checking outThomas Wolf2022-09-181-11/+9
| | | | | | | CloneCommand, when setNoCheckout(true) was set, did not set HEAD. With C git, "git clone --no-checkout" does. Change-Id: Ief3df7e904ce90829a6345a6c3e9ee6a68486ab0 Signed-off-by: Thomas Wolf <twolf@apache.org>
* Pass on shallowSince only if not nullThomas Wolf2022-09-182-2/+6
| | | | | | | FetchCommand.setShallowSince() and Transport.setDeepenSince() require a non-null argument. Change-Id: I1c3a20be518374e380a4e90787ed834438da40ee Signed-off-by: Thomas Wolf <twolf@apache.org>
* Fix wrong @since tagThomas Wolf2022-09-181-1/+1
| | | | | | PatchApplier was merged only in JGit 6.4. Change-Id: Ica84d8184c1d3a1acce8beba9b076f6c32e749d7 Signed-off-by: Thomas Wolf <twolf@apache.org>
* Merge "Split out ApplyCommand logic to PatchApplier class"Han-Wen NIenhuys2022-09-153-665/+1017
|\
| * Split out ApplyCommand logic to PatchApplier classNitzan Gur-Furman2022-09-153-665/+1017
| | | | | | | | | | | | | | | | | | | | | | | | | | | | PatchApplier now routes updates through the index. This has two results: * we can now execute patches in-memory. * the JGit apply command will now always update the index to match the working tree. Change-Id: Id60a88232f05d0367787d038d2518c670cdb543f Co-authored-by: Han-Wen Nienhuys <hanwen@google.com> Co-authored-by: Nitzan Gur-Furman <nitzan@google.com>
* | Fix typo in FetchV2Request javadockylezhao2022-09-141-1/+1
| | | | | | | | | | Change-Id: I905dda15e1b7f5e431816d3fbb01a1672e5fc786 Signed-off-by: kylezhao <kylezhao@tencent.com>
* | [merge] Fix merge conflicts with symlinksThomas Wolf2022-09-071-53/+115
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Merge branch 'master' into stable-6.3Matthias Sohn2022-09-064-186/+110
|\| | | | | | | | | | | | | | | | | | | * master: Move WorkTreeUpdater to merge package WorkTreeUpdater: use DirCacheCheckout#StreamSupplier DirCacheCheckout#getContent: also take InputStream supplier WorkTreeUpdater: remove safeWrite option Change-Id: I8be570dbc4ad0d0b46046b85cbda24c3adcba170
| * Merge changes I888f313f,I98de155c,I2efa9a6d,Ifa79dac2Matthias Sohn2022-09-064-186/+110
| |\ | | | | | | | | | | | | | | | | | | | | | * changes: Move WorkTreeUpdater to merge package WorkTreeUpdater: use DirCacheCheckout#StreamSupplier DirCacheCheckout#getContent: also take InputStream supplier WorkTreeUpdater: remove safeWrite option
| | * Move WorkTreeUpdater to merge packageHan-Wen Nienhuys2022-09-062-5/+3
| | | | | | | | | | | | | | | | | | | | | This avoids making it public with the associated costs for backward compatibility guarantees. Change-Id: I888f313f3854deace8d4cd92f354a6ef0d3b5460
| | * WorkTreeUpdater: use DirCacheCheckout#StreamSupplierHan-Wen Nienhuys2022-09-063-130/+16
| | | | | | | | | | | | | | | | | | This avoids having to introduce the StreamLoader bridging class. Change-Id: I98de155c458745236df24d6323eabed5061e7f8c
| | * DirCacheCheckout#getContent: also take InputStream supplierHan-Wen Nienhuys2022-09-062-27/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This lets us use DirCacheCheckout for routines that want to write files in the worktree that aren't available as a git object. DirCacheCheckout#getContent takes a InputStream supplier rather than InputStream: if filtering fails with IOException, the data is placed unfiltered in the checkout. This means that the stream has to be read again, from the start. Use it in this way in ApplyCommand. This use is incorrect, though: the same InputStream is returned twice, so if the read to be retried, the stream will return 0 bytes. It doesn't really matter, because in either case, the SHA1 will not match up, and the patch fails. Change-Id: I2efa9a6da06806ff79b155032fe4b34be8fec09e
| | * WorkTreeUpdater: remove safeWrite optionHan-Wen Nienhuys2022-09-062-24/+3
| | | | | | | | | | | | | | | | | | | | | | | | This was added in Ideaefd5178 to anticipate on writing files for ApplyCommand, but we are keeping WorkTreeUpdater private to the merge package for now. Change-Id: Ifa79dac245e60eb7a77eaea4cc1249222e347d38
* | | Revert "Adds FilteredRevCommit that can overwrites its parents in theMatthias Sohn2022-09-063-142/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | DAG." This reverts commit 6297491e8adb85e43d60ffe75fb71f335e733449. This is done as a quick fix for the failure of egit tests caused by the introduction of FilteredRevCommit. Bug: 580690 Change-Id: Ia6b651dd11b0a4b02d5e52247eb4bf13adf94e27
* | | Revert "Option to pass start RevCommit to be blamed on to theMatthias Sohn2022-09-061-34/+13
|/ / | | | | | | | | | | | | | | | | | | | | | | BlameGenerator." This reverts commit 5747bba48b22a11beba8ebe0caf13a53d4ca96f2. This is done as a quick fix for the failure of egit tests caused by the introduction of FilteredRevCommit. Bug: 580690 Change-Id: Ia0178bc2de4fc825a81207bbd7979bf3a386c955
* / BaseSuperprojectWriter: report invalid paths as manifest errorsIvan Frade2022-08-231-1/+2
|/ | | | | | | | | | An invalid path in the manifest (e.g. '.') is reported by DirCache in a runtime exception. In server context this becomes a 500 instead of a user error. Wrap the runtime invalid path exception into a checked ManifestErrorException that caller can handle. Change-Id: I61a2104922765506ae232334891057bb06141d97
* ApplyCommand: fix ApplyResult#updatedFilesHan-Wen Nienhuys2022-08-231-5/+6
| | | | | | | | On executing a copy, mark the destination as updated. On executing a rename, mark both source and destination as updated. Change-Id: Ied5b9b0e5a14eac59a06cdd0961e25e143f50ff0
* WorkTreeUpdater: rename metadata mapsHan-Wen Nienhuys2022-08-231-10/+10
| | | | Change-Id: I8ff3803da8fc13377d11c2dc5523e9e32d0650cb
* WorkTreeUpdater#Result: hide data membersHan-Wen Nienhuys2022-08-232-10/+23
| | | | | | This is the standard across JGit. Change-Id: Ie52ad7000d8725657b33dd4f3adcc05ab9666875
* Merge "WorkTreeUpdater: re-format and clean-up"Han-Wen NIenhuys2022-08-181-221/+265
|\
| * WorkTreeUpdater: re-format and clean-upThomas Wolf2022-08-171-221/+265
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Reformat using the standard JGit formatter settings. Clean-ups: * Try to improve javadoc. * Remove blindly copy-pasted "@since 6.1" annotations. * Get rid of private method nonNullNonBareRepo(); it's not needed. * Simplify method nonNullRepo(), and annotate as @NonNull. * Rename setInCoreFileSizeLimit() to getInCoreFileSizeLimit(). Change-Id: Ib1797e7cf925d87554307468330971e8ab2e05e9 Signed-off-by: Thomas Wolf <twolf@apache.org> Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
* | Add javadoc on RevCommitRonald Bhuleskar2022-08-171-0/+5
| | | | | | | | Change-Id: Ib413154fe52983286cb6307862a7373af4fec6e8
* | Option to pass start RevCommit to be blamed on to the BlameGenerator.Ronald Bhuleskar2022-08-171-13/+34
| | | | | | | | | | | | | | | | | | This can allow passing a FilteredRevCommit which is the filtered list of commit graph making it easier for Blame to work on. This can significantly improve blame performance since blame can skip expensive RevWalk. Change-Id: Ie127cb710d004079e9f53a5802130afdb49a7de1
* | Adds FilteredRevCommit that can overwrites its parents in the DAG.Ronald Bhuleskar2022-08-163-8/+142
| | | | | | | | Change-Id: I1ea63a3b56074099688fc45d6a22943a8ae3c2ae
* | Merge changes Ib6689f54,I3b5c22eeMatthias Sohn2022-08-161-0/+2
|\ \ | |/ |/| | | | | | | * changes: Remove unused API problem filters Add missing @since tag for RevCommit#parents introduced in 61b4d105e4
| * Add missing @since tag for RevCommit#parents introduced in 61b4d105e4Matthias Sohn2022-08-121-0/+2
| | | | | | | | Change-Id: I3b5c22eea7d0af5464c7df7a7cd855ea08029853
* | DirCacheCheckout: load WorkingTreeOptions only onceThomas Wolf2022-08-144-39/+95
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previous code loaded the WorkingTreeOptions afresh for every single file being checked out. This checked the git config (all three files, repo, user and system config) for having been modified every time. These checks can be costly, for instance on Windows, or if one of the three config files is not on a local disk, or on an otherwise slow storage. Improve this by loading the options and thus checking the git config only once before the checkout. Bug: 579715 Change-Id: I21cd5a808f9d90b5ca2d022f91f0eeb8ca26091c Signed-off-by: Thomas Wolf <twolf@apache.org>
* | WorkTreeUpdater: Fix unclosed streamsThomas Wolf2022-08-141-12/+20
| | | | | | | | | | | | | | | | | | | | | | 1. A TemporaryBuffer.LocalFile must be destroyed to ensure the temporary file gets deleted on disk. 2. TemporaryBuffer.openInputStream() may be used only after TemporaryBuffer.close(). 3. The caller of DirCacheCheckout.getContent() is responsible for closing the OutputStream! Change-Id: I46abb0fba27656a1026858e5783fc60d4738a45e Signed-off-by: Thomas Wolf <twolf@apache.org>
* | Merge "Fix API errors caused by 23a71696cd"Matthias Sohn2022-08-142-2/+7
|\|
| * Fix API errors caused by 23a71696cdMatthias Sohn2022-08-122-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | - add missing @since 6.3 for new protected field workTreeUpdater and new class WorkTreeUpdater - suppress API errors caused by removing/adding protected fields and methods We follow OSGi semantic versioning which allows breaking implementers in minor versions which are e.g. subclassing a public class. Change-Id: I28f0d7b4fdd9a1f0fbc6b137d6c68dda9fe3c11e
* | Fix adding symlinks to the index when core.symlinks=falseThomas Wolf2022-08-131-0/+6
|/ | | | | | | | | | With core.symlinks=false, symlinks are checked out as plain files. When such a file is re-added to the index, and the index already contains a symlink there, add the file as a symlink. Previous code changed the index entry to a regular file. Bug: 580412 Change-Id: I5497bedc3da89c8b10120b8077c56bc5b67cb791 Signed-off-by: Thomas Wolf <twolf@apache.org>
* Merge changes Ideaefd51,I6c347393Han-Wen NIenhuys2022-08-094-427/+856
|\ | | | | | | | | | | * changes: Reapply "Create util class for work tree updating in both filesystem and index." ResolveMerger: add coverage for inCore file => directory transition
| * Reapply "Create util class for work tree updating in both filesystem and index."Nitzan Gur-Furman2022-08-084-427/+856
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 5709317f71ccaf26eceaa896150f203879b634b8. Add a bugfix for deletions in ResolveMergers instantiated with just an ObjectInserter as argument. Original change description: Create util class for work tree updating in both filesystem and index. This class intends to make future support in index updating easier. This class currently extracts some logic from ResolveMerger. Logic related to StreamSupplier was copied from ApplyCommand, which will be integrated in a following change. Co-authored-by: Nitzan Gur-Furman <nitzan@google.com> Co-authored-by: Han-Wen Nienhuys <hanwen@google.com> Change-Id: Ideaefd51789a382a8b499d1ca7ae0146d032f48b
* | Provide default shallowCommits getter and setter in ObjectDatabaseRonald Bhuleskar2022-08-082-18/+15
|/ | | | | | | | | | | | | | I649db9ae679ec2606cf7c530b040f8b6b93eb81a added a default implementation for getShallowCommits and setShallowCommits to DfsObjDatabase, for the convenience of any implementers that define subclasses. But we forgot that some implementers inherit from ObjectDatabase directly instead. Move the default getter and setter to the base class so that such callers do not need source changes to unbreak their build. This also lets us update the api_filters to reflect that this is no longer an API-breaking change. Change-Id: I5dcca462eb306e511e57907b7d9264d51b3f3014
* Revert "Create util class for work tree updating in both filesystem and index."Jonathan Nieder2022-08-054-855/+426
| | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 5151b324f4605b1091ac5843dcc1f04b3996f0d1. It is producing NullPointerExceptions during merges, causing Gerrit's acceptance tests to fail: com.google.gerrit.extensions.restapi.RestApiException: Cannot rebase ps [...] at com.google.gerrit.server.api.changes.RevisionApiImpl.rebase(RevisionApiImpl.java:280) at com.google.gerrit.acceptance.api.change.ChangeIT.rebaseChangeBase(ChangeIT.java:1584) Caused by: com.google.gerrit.server.update.UpdateException: java.lang.NullPointerException: repository is required at com.google.gerrit.server.update.BatchUpdate.executeUpdateRepo(BatchUpdate.java:588) [...] Caused by: java.lang.NullPointerException: repository is required at org.eclipse.jgit.merge.Merger.nonNullRepo(Merger.java:128) at org.eclipse.jgit.merge.ResolveMerger.addDeletion(ResolveMerger.java:380) at org.eclipse.jgit.merge.ResolveMerger.processEntry(ResolveMerger.java:553) at org.eclipse.jgit.merge.ResolveMerger.mergeTreeWalk(ResolveMerger.java:1224) at org.eclipse.jgit.merge.ResolveMerger.mergeTrees(ResolveMerger.java:1174) at org.eclipse.jgit.merge.ResolveMerger.mergeImpl(ResolveMerger.java:299) at org.eclipse.jgit.merge.Merger.merge(Merger.java:233) at org.eclipse.jgit.merge.Merger.merge(Merger.java:186) at org.eclipse.jgit.merge.ThreeWayMerger.merge(ThreeWayMerger.java:96) at com.google.gerrit.server.change.RebaseChangeOp.rebaseCommit(RebaseChangeOp.java:360) Change-Id: Idf63de81666d0df118d2d93c4f6e014e00dc05b8
* Provide a default implementation for set/get shallowCommits on DfsObjDatabaseRonald Bhuleskar2022-08-051-0/+16
| | | | | | Jgit change https://git.eclipse.org/r/c/jgit/jgit/+/193329 adds an implementation for get/set shallow commits in ObjectDatabase. This failed gerrit's acceptance tests since there is no default implementation for them in DfsObjDatabase. Change-Id: I649db9ae679ec2606cf7c530b040f8b6b93eb81a
* Merge "Revert "Option to pass start RevCommit to be blamed on to the ↵Terry Parker2022-08-031-34/+13
|\ | | | | | | BlameGenerator.""
| * Revert "Option to pass start RevCommit to be blamed on to the BlameGenerator."Ronald Bhuleskar2022-08-031-34/+13
| | | | | | | | | | | | | | | | | | | | This reverts commit 59e8bec6e7705a89b5d0b9c6ac004b323ffa16b0. Reason for revert: The change in https://git.eclipse.org/r/c/jgit/jgit/+/194354 broke the egit test [1]. Calling c.getShortMessage() causes an NPE. [1] https://ci.eclipse.org/egit/job/egit.gerrit/2711/ Change-Id: Iaf5feb35f4bb4c3487b04be15d1fe11376975523
* | Merge "Revert "Adds FilteredRevCommit that can overwrites its parents in the ↵Terry Parker2022-08-032-118/+3
|\ \ | | | | | | | | | DAG.""
| * | Revert "Adds FilteredRevCommit that can overwrites its parents in the DAG."Ronald Bhuleskar2022-08-032-118/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit ceb51a5e0e9db166e572ea7cd362795b4662b0cd. Reason for revert: The change in https://git.eclipse.org/r/c/jgit/jgit/+/194354 broke the egit test [1]. Calling c.getShortMessage() causes an NPE. [1] https://ci.eclipse.org/egit/job/egit.gerrit/2711/ Change-Id: I411565b6eaa0bbb562cc1c8a355942ff09fd29bc