aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse/jgit/merge
Commit message (Collapse)AuthorAgeFilesLines
* RecursiveMerger: Create PersonIdent with java.time APIIvan Frade2024-12-231-7/+6
| | | | | | | | | | We are moving away from the old java.util.Date api to the java.time.Instant version. This class uses a deprecated constructor in PersonIdent. Use the new constructor for PersonIdent with Instant/ZoneId. Change-Id: I50e2a643ad17a5c0722f87b1bb8abcad286745a5
* Merge branch 'stable-7.0' into stable-7.1Matthias Sohn2024-12-061-3/+6
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-7.0: FileSnapshot: silence "Not a Directory" exceptions FileSnapshot: refactor to share error handling Mark Attribute#getValue as @Nullable Fix potential NPE in ResolveMerger#getAttributesContentMergeStrategy Fix NPE in DiffFormatter#getDiffDriver Pack: ensure packfile is still valid while still recoverable WindowCache: add bulk purge(), call from bulk sites UploadPack#implies: add missing @since tag Disable MergeToolTest#testEmptyToolName Change-Id: Icb25fed5b703c6a39a64231fd8ca93c1f1a581be
| * Merge branch 'stable-6.10' into stable-7.0Matthias Sohn2024-12-061-3/+6
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-6.10: FileSnapshot: silence "Not a Directory" exceptions FileSnapshot: refactor to share error handling Mark Attribute#getValue as @Nullable Fix potential NPE in ResolveMerger#getAttributesContentMergeStrategy Fix NPE in DiffFormatter#getDiffDriver Pack: ensure packfile is still valid while still recoverable WindowCache: add bulk purge(), call from bulk sites UploadPack#implies: add missing @since tag Disable MergeToolTest#testEmptyToolName Change-Id: I854f44e76b73ae434a0d6b6ab782fd0aed72f219
| | * Fix potential NPE in ResolveMerger#getAttributesContentMergeStrategyMatthias Sohn2024-12-051-3/+6
| | | | | | | | | | | | Change-Id: I2a4c57438c16a0c5bc1af4c7772eaf65049911e2
* | | RecursiveMerger: fix boxing warningMatthias Sohn2024-11-191-1/+1
| | | | | | | | | | | | Change-Id: I6f6ae540b128ff6b965931e829da1368a8b88ddb
* | | Suppress non-externalized string warningsMatthias Sohn2024-11-191-3/+3
| | | | | | | | | | | | Change-Id: Ib0737f7ec6b9872f6d4514d140e7d32a4a40809d
* | | Merge branch 'stable-7.0' into stable-7.1Matthias Sohn2024-11-053-4/+57
|\| | | | | | | | | | | | | | | | | | | | | | | * stable-7.0: ResolveMerger: Allow setting the TreeWalk AttributesNodeProvider Add Union merge strategy support Change-Id: I15674134f4c73ac2de514d4fac4a36fca7ed7b07
| * | Merge branch 'stable-6.10' into stable-7.0Matthias Sohn2024-11-053-4/+57
| |\| | | | | | | | | | | | | | | | | | | | | | * stable-6.10: ResolveMerger: Allow setting the TreeWalk AttributesNodeProvider Add Union merge strategy support Change-Id: I0d768d793effd1deabb4807446a4f8c10a82ad74
| | * ResolveMerger: Allow setting the TreeWalk AttributesNodeProviderNasser Grainawi2024-11-051-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a merger is created without a Repository, no AttributesNodeProvider is created in the TreeWalk. Since mergers are often created with a custom ObjectInserter and no repo, they skip any lookups of attributes from any of the gitattributes files (within a tree, in the repo info/ dir, or user/global). Since there are potentially merge-affecting attributes in those files, callers might want to use both a custom ObjectInserter and an AttributesNodeProvider. Change-Id: I7997309003bbb598e1002261b3be7f2cc52066c8
| | * Add Union merge strategy supportNasser Grainawi2024-11-043-4/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | Allow users to specify the `union` strategy in their .gitattributes file in order to keep lines from both versions of a conflict [1]. [1] https://git-scm.com/docs/gitattributes.html#Documentation/gitattributes.txt-union Change-Id: I74cecceb2db819a8551b95fb10dfe7c2b160b709
* | | RevolveMerger: honor ignoreConflicts also for binary filesKamil Musin2024-10-081-2/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently difference in binary files during merge will cause them to be added to unmergedPaths regardless of whether ignoreConflicts is true. This creates an issue during merging with strategy "RECURSIVE", as it makes it impossible to create a virtual commit if there is a difference in a binary file. Resulting in the CONFLICTS_DURING_MERGE_BASE_CALCULATION error being thrown. This is especially problematic, since JGit has a rather simplistic rules for considering file binary, which easily leads to false positives. What we should do instead is keep OURS. This will not lead to silently ignoring difference in the final result. It will allow creation of virtual merge-base commit, and then the difference would be presented again in the final merge results. In essense it only affects what's shown as BASE in 3-way merge. Additionally, this is correct because - It's consistent with treatment of other unmergeable entities, for example Gitlinks - It's consistent with behaviour of CGit: - https://git-scm.com/docs/gitattributes#Documentation/gitattributes.txt-binary states on diffs in binary OURS is picked by default. - In code: https://git.kernel.org/pub/scm/git/git.git/tree/merge-ll.c#n81 - ignoreConflicts in CGit afterwards ignores all issues with content merging https://git.kernel.org/pub/scm/git/git.git/tree/merge-ort.c#n5201 We also adjust the behaviour when .gitattributes tell us to treat the file as binary for the purpose of the merge. We only change the behaviour when ignoreConlicts = true, as otherwise the current behaviour works as intended. Change-Id: I2b69f80a13d250aad3fe12dd438b2763f3022270
* | | Record failing paths in recursive merge.jackdt@google.com2024-09-231-2/+19
|/ / | | | | | | | | | | | | | | This is meant to help diagnose LOCK_FAILURE errors, which otherwise provides very little information in https://eclipse.googlesource.com/jgit/jgit/+/refs/heads/master/org.eclipse.jgit/src/org/eclipse/jgit/lib/BatchRefUpdate.java#731. Change-Id: I3d544c899fe66effbd107ea2f38d73f6f253a7e6
* | Remove deprecated MergeMessageFormatter#formatWithConflictsMatthias Sohn2024-09-031-18/+0
| | | | | | | | Change-Id: I3040f655318c47f268433294720a99325ae78863
* | Remove deprecated MergeFormatter#formatMerge using charset nameMatthias Sohn2024-09-031-31/+0
| | | | | | | | Change-Id: I7d0bdb61a8698e94bb40c22fe1c40c70cec65dfc
* | Remove deprecated MergeFormatter#formatMerge using charset nameMatthias Sohn2024-09-031-34/+0
|/ | | | Change-Id: Id2bdcb865203ed192fea35cfcf82c34667710726
* [errorprone] Fix error pattern JdkObsoleteMatthias Sohn2024-04-291-3/+2
| | | | | | See https://errorprone.info/bugpattern/JdkObsolete Change-Id: Id105e2695eb64523bd217f507bf95f909bc6b348
* ResolveMerger: Fix the issue with binary modify-modify conflictsSruteesh2024-04-251-30/+43
| | | | | | | | | | | 1) If the file was marked as binary by git attributes, we should add the path to conflicts if content differs in OURS and THEIRS 2) If the path is a file in OURS, THEIRS and BASE and if it is a binary in any one of them, no content merge should be attempted and the file content is kept as is in the work tree Bug: jgit-14 Change-Id: I9201bdc53a55f8f40adade4b6a36ee8ae25f4db8
* MergeAlgorithm: Fix diff3 conflict hunk computationAntonin Delpeuch2024-04-091-2/+11
| | | | | | | | | | | | | | | Closes https://github.com/eclipse-jgit/jgit/issues/38. The previous code computed the boundaries of the base part of conflict hunks using line numbers computed for the 'ours' and 'theirs' revisions, leading to incorrect boundaries. This only affects the presentation of merge conflicts in diff3 mode (which is probably not used a lot yet on Gerrit). Successful merges are unaffected. Change-Id: I173c79bf5797896dc854791d6d05cb3f035726f4 Signed-off-by: Antonin Delpeuch <antonin@delpeuch.eu>
* [errorprone] Add missing javadoc summaryMatthias Sohn2023-09-252-1/+11
| | | | | | see https://google.github.io/styleguide/javaguide.html#s7.2-summary-fragment Change-Id: Iaf4a6b55d4e4c59b7a2da3451164abb1bb47d4a1
* Merge branch 'stable-6.6' into stable-6.7Matthias Sohn2023-09-031-22/+25
|\ | | | | | | | | | | | | | | | | * stable-6.6: Prepare 6.6.2-SNAPSHOT builds JGit v6.6.1.202309021850-r Checkout: better directory handling Change-Id: Ice82d68b2d343a5fac214807cdb369e486481aab
| * Checkout: better directory handlingThomas Wolf2023-09-031-22/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When checking out a file into the working tree ensure that all parent directories of the file below the working tree root are actually directories and do exist before we try to create the file. When multiple files are to be checked out (or even a whole tree), this may check the same directories over and over again. Asking the file system every time for file attributes is a potentially expensive operation. As a remedy, introduce an in-memory cache of directory states for a particular check-out operation. Apply the same fix also in the ResolveMerger, which may also check out files, and also in the PatchApplier. In PatchApplier, also validate paths. Change-Id: Ie12864c54c9f901a2ccee7caddec73027f353111 Signed-off-by: Thomas Wolf <twolf@apache.org> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | Merge: Add diff3 style merge conflict formatter.Haamed Gheibi2023-07-314-15/+147
| | | | | | | | | | | | | | Add base section to the merge conflict hunks. Bug: 442284 Change-Id: I977b43e7dd8119d6b72d11f09c4e8ec241750383
* | Fix all Javadoc warnings and fail on themAntoine Musso2023-06-1612-33/+41
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Fix API breakage caused by extracting WorkTreeUpdaterMatthias Sohn2022-11-152-636/+612
| | | | | | | | | | | 448052dc2e made WorkTreeUpdater package visible which breaks API for subclasses of ResolveMerger since they cannot access WorkTreeUpdater. Fix this by moving WorkTreeUpdater into ResolveMerger as a nested class and mark it protected so that subclasses can use it. Bug: 581049 Change-Id: I5a2c4953f8514dc0a1b8041c8e069d28370bb2eb
* [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>
* Move WorkTreeUpdater to merge packageHan-Wen Nienhuys2022-09-062-1/+635
| | | | | | | This avoids making it public with the associated costs for backward compatibility guarantees. Change-Id: I888f313f3854deace8d4cd92f354a6ef0d3b5460
* WorkTreeUpdater: use DirCacheCheckout#StreamSupplierHan-Wen Nienhuys2022-09-061-4/+1
| | | | | | This avoids having to introduce the StreamLoader bridging class. Change-Id: I98de155c458745236df24d6323eabed5061e7f8c
* WorkTreeUpdater: remove safeWrite optionHan-Wen Nienhuys2022-09-061-1/+1
| | | | | | | | 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
* WorkTreeUpdater#Result: hide data membersHan-Wen Nienhuys2022-08-231-4/+4
| | | | | | This is the standard across JGit. Change-Id: Ie52ad7000d8725657b33dd4f3adcc05ab9666875
* Fix API errors caused by 23a71696cdMatthias Sohn2022-08-121-0/+2
| | | | | | | | | | | | - 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
* Reapply "Create util class for work tree updating in both filesystem and index."Nitzan Gur-Furman2022-08-082-362/+156
| | | | | | | | | | | | | | | | | | | | | 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
* Revert "Create util class for work tree updating in both filesystem and index."Jonathan Nieder2022-08-052-154/+361
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Create util class for work tree updating in both filesystem and index.Nitzan Gur-Furman2022-07-252-361/+154
| | | | | | | | | | 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. Change-Id: I8dc5a582433fc9891038c628385d3970b5a8984b
* [checkout] Use .gitattributes from the commit to be checked outThomas Wolf2022-03-071-39/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | JGit used only one set of attributes constructed from the global and info attributes, plus the attributes from working tree, index, and HEAD. These attributes must be used to determine whether the working tree is dirty. But for actually checking out a file, one must use the attributes from global, info, and *the commit to be checked out*. Otherwise one may not pick up definitions that are only in the .gitattributes of the commit to be checked out or that are changed in that commit with respect to the attributes currently in HEAD, the index, or the working tree. Maintain in TreeWalk different Attributes per tree, and add operations to determine EOL handling and smudge filters per tree. Use the new methods in DirCacheCheckout and ResolveMerger. Note that merging in JGit actually used the attributes from the base, not those from ours, which looks dubious at least. It now uses those from ours, and for checking out the ones from theirs. The canBeContentMerged() determination was also done from the base attributes, and is newly done from the ours attributes. Possibly this should take into account all three attributes, and only if all three agree the item can be content merged, a content merge should be attempted? (What if the binary/text setting changes between base, ours, or theirs?) Also note that JGit attempts to perform content merges on non-binary LFS files; there it used the filter attribute from base, too, even for the ours and theirs versions. Newly it takes the filter attribute from the correct tree. I'm not convinced doing content merges on potentially huge files like LFS files is really a good idea. Add tests in FilterCommandsTest and LfsGitTest to verify the behavior. Open question: using index and working tree as fallback for the attributes of ours (assuming it is HEAD) is OK. But does it also make sense for base and theirs in merging? Bug: 578707 Change-Id: I0bf433e9e3eb28479b6272e17c0666e175e67d08 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* Merge conflict messages: prefix conflict lines with a hashThomas Wolf2022-01-311-10/+36
| | | | | | | | C git also does so. Note that currently the comment character is hard-coded as the hash '#' throughout JGit. Bug: 548529 Change-Id: I4a5597694082a9e5b07412b365cfaf41fa034cfa Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* Remove redundant type argumentsThomas Wolf2021-09-301-1/+1
| | | | | | | | In Java 11 type arguments for anonymous subclasses can be inferred and don't need to be specified. This resolves a number of compiler warnings. Change-Id: I55eff3babb7628aa0627085e65a1b45eb12c2cd3 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* Implement ours/theirs content conflict resolutionThomas Wolf2021-04-193-45/+204
| | | | | | | | | | | | | | | | | | | | | | | | | | | Git has different conflict resolution strategies: * There is a tree merge strategy "ours" which just ignores any changes from theirs ("-s ours"). JGit also has the mirror strategy "theirs" ignoring any changes from "ours". (This doesn't exist in C git.) Adapt StashApplyCommand and CherrypickCommand to be able to use those tree merge strategies. * For the resolve/recursive tree merge strategies, there are content conflict resolution strategies "ours" and "theirs", which resolve any conflict hunks by taking the "ours" or "theirs" hunk. In C git those correspond to "-Xours" or -Xtheirs". Implement that in MergeAlgorithm, and add API to set and pass through such a strategy for resolving content conflicts. * The "ours/theirs" content conflict resolution strategies also apply for binary files. Handle these cases in ResolveMerger. Note that the content conflict resolution strategies ("-X ours/theirs") do _not_ apply to modify/delete or delete/modify conflicts. Such conflicts are always reported as conflicts by C git. They do apply, however, if one side completely clears a file's content. Bug: 501111 Change-Id: I2c9c170c61c440a2ab9c387991e7a0c3ab960e07 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Allow file mode conflicts in virtual base commit on recursive merge.Marija Savtchouk2021-04-061-9/+12
| | | | | | | | | Similar to https://git.eclipse.org/r/c/jgit/jgit/+/175166, ignore path that have conflicts on attributes, so that the virtual base could be used by RecursiveMerger. Change-Id: I99c95445a305558d55bbb9c9e97446caaf61c154 Signed-off-by: Marija Savtchouk <mariasavtchouk@google.com>
* Allow dir/file conflicts in virtual base commit on recursive merge.Marija Savtchouk2021-02-091-10/+13
| | | | | | | | | | | | | | | | If RecursiveMerger finds multiple base commits, it tries to compute the virtual ancestor to use as a base for the three way merge. Currently, the content conflicts between ancestors are ignored (file staged with the conflict markers). If the path is a file in one ancestor and a dir in the other, it results in NoMergeBaseException (CONFLICTS_DURING_MERGE_BASE_CALCULATION). Allow these conflicts by ignoring this unmerged path in the virtual base. The merger will compute diff in the children instead and it can be further fixed manually if needed. Change-Id: Id59648ae1d6bdf300b26fff513c3204317b755ab Signed-off-by: Marija Savtchouk <mariasavtchouk@google.com>
* ResolveMerger: do not content-merge gitlinks on del/mod conflictsDemetr Starshov2020-08-261-28/+44
| | | | | | | | | | Previously ResolveMerger tried to make a fulltext merge entry in case one of sides got deleted regardless of file mode. This is not applicable for GITLINK type of entry. After this change it is rendering appropriate merge result. Signed-off-by: Demetr Starshov <dstarshov@google.com> Change-Id: Ibdb4557bf8781bdb48bcee6529e37dc80582ed7e
* ResolveMerger: choose OURS on gitlink when ignoreConflictsDemetr Starshov2020-08-261-9/+11
| | | | | | | | | | | | | | | | | | | | | | | Option ignoreConflicts is used when a caller want to create a virtual commit and use it in a future merge (recursive merge) or show it on UI (e.g. Gerrit). According to contract in case of ignoreConflicts ResolveMerger should populate only stage 0 for entries with merge conflicts as if there is no conflict. Current implementation breaks this contract for cases when gitlink revision is ambiguous. Therefore, always select 'ours' when we merge in ignoreConflicts mode. This will satisfy the contract contract, so recursive merge can succeed, however it is an arbitrary decision, so it is not guaranteed to select best GITLINK in all cases. GITLINK merging is a special case of recursive merge because of limitations of GITLINK type of entry. It can't contain more than 1 sha-1 so jgit can't write merge conflicts in place like it can with a blob. Ideally we could signal the conflict with a special value (like '0000...'), but that must be supported by all tooling (git fsck, c-git)." Signed-off-by: Demetr Starshov <dstarshov@google.com> Change-Id: Id4e9bebc8e828f7a1ef9f83259159137df477d89
* ResolveMerger: improving content merge readabilityDemetr Starshov2020-08-261-12/+14
| | | | | | | | Separate "GITLINK conflict" and "attributes can't be content merged" cases. Signed-off-by: Demetr Starshov <dstarshov@google.com> Change-Id: I29424e13ea1738af750196e7bf4315256a6095b6
* ResolveMerger: extracting createGitLinksMergeResult methodDemetr Starshov2020-08-261-8/+14
| | | | | Signed-off-by: Demetr Starshov <dstarshov@google.com> Change-Id: Ibc8b954266b1b4b9b9f404e3433f0d7cdae107e8
* ResolveMerger: Ignore merge conflicts if asked soIvan Frade2020-03-191-16/+26
| | | | | | | | | | | | | | | | | | | | The recursive merge strategy builds a virtual ancestor merging recursively the common bases (when more than one) between the want-to-merge commits. While building this virtual ancestor, content conflicts are ignored, but current code doesn't do so when a file is removed. This was spotted in [1], for example. Merging two commits to build the virtual ancestor bumped into a conflict (modified in one side, deleted in the other) that stopped the process. Follow the "spec" and in case of conflict leave the unmerged content in the index and working trees. [1] https://android-review.googlesource.com/c/kernel/common/+/1228962 Change-Id: Ife9c32ae3ac3a87d3660fa1242e07854b65169d5 Signed-off-by: Ivan Frade <ifrade@google.com>
* 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>
| * Move array designators from the variable to the typeDavid Pursehouse2020-02-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | As reported by Sonar Lint: Array designators should always be located on the type for better code readability. Otherwise, developers must look both at the type and the variable name to know whether or not a variable is an array. Change-Id: If6b41fed3483d0992d402d8680552ab4bef89ffb Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* | Merge branch 'stable-5.6'Matthias Sohn2020-02-221-1/+1
|\| | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.6: Revert "Prepend hostname to subsection used to store file timestamp resolution" SimilarityRenameDetector: Fix inconsistent indentation Use indexOf(char) and lastIndexOf(char) rather than String versions Reorder modifiers to follow Java Language Specification GitmoduleEntry: Remove redundant import of class from same package Remove redundant "static" qualifier from enum declarations Change-Id: Ibb66bef7e8373f81e3e653c9843d986243446d68 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| * Reorder modifiers to follow Java Language SpecificationDavid Pursehouse2020-02-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Java Language Specification recommends listing modifiers in the following order: 1. Annotations 2. public 3. protected 4. private 5. abstract 6. static 7. final 8. transient 9. volatile 10. synchronized 11. native 12. strictfp Not following this convention has no technical impact, but will reduce the code's readability because most developers are used to the standard order. This was detected using SonarLint. Change-Id: I9cddecb4f4234dae1021b677e915be23d349a380 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* | Update EDL 1.0 license headers to new short SPDX compliant formatMatthias Sohn2020-01-0418-684/+90
|/ | | | | | | | | | 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>
* Enable and fix "Statement unnecessarily nested within else clause" warningsDavid Pursehouse2019-10-174-62/+59
| | | | | | | | | | | | | | | 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>