diff options
Diffstat (limited to 'org.eclipse.jgit')
8 files changed, 192 insertions, 285 deletions
diff --git a/org.eclipse.jgit/META-INF/MANIFEST.MF b/org.eclipse.jgit/META-INF/MANIFEST.MF index d1e612593c..307a8016e3 100644 --- a/org.eclipse.jgit/META-INF/MANIFEST.MF +++ b/org.eclipse.jgit/META-INF/MANIFEST.MF @@ -3,12 +3,12 @@ Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name Automatic-Module-Name: org.eclipse.jgit Bundle-SymbolicName: org.eclipse.jgit -Bundle-Version: 6.3.0.qualifier +Bundle-Version: 6.3.1.qualifier Bundle-Localization: plugin Bundle-Vendor: %Bundle-Vendor Eclipse-ExtensibleAPI: true -Export-Package: org.eclipse.jgit.annotations;version="6.3.0", - org.eclipse.jgit.api;version="6.3.0"; +Export-Package: org.eclipse.jgit.annotations;version="6.3.1", + org.eclipse.jgit.api;version="6.3.1"; uses:="org.eclipse.jgit.transport, org.eclipse.jgit.notes, org.eclipse.jgit.dircache, @@ -23,18 +23,18 @@ Export-Package: org.eclipse.jgit.annotations;version="6.3.0", org.eclipse.jgit.revwalk.filter, org.eclipse.jgit.blame, org.eclipse.jgit.merge", - org.eclipse.jgit.api.errors;version="6.3.0"; + org.eclipse.jgit.api.errors;version="6.3.1"; uses:="org.eclipse.jgit.lib, org.eclipse.jgit.errors", - org.eclipse.jgit.attributes;version="6.3.0"; + org.eclipse.jgit.attributes;version="6.3.1"; uses:="org.eclipse.jgit.lib, org.eclipse.jgit.treewalk", - org.eclipse.jgit.blame;version="6.3.0"; + org.eclipse.jgit.blame;version="6.3.1"; uses:="org.eclipse.jgit.lib, org.eclipse.jgit.revwalk, org.eclipse.jgit.treewalk.filter, org.eclipse.jgit.diff", - org.eclipse.jgit.diff;version="6.3.0"; + org.eclipse.jgit.diff;version="6.3.1"; uses:="org.eclipse.jgit.lib, org.eclipse.jgit.attributes, org.eclipse.jgit.revwalk, @@ -42,51 +42,51 @@ Export-Package: org.eclipse.jgit.annotations;version="6.3.0", org.eclipse.jgit.treewalk.filter, org.eclipse.jgit.treewalk, org.eclipse.jgit.util", - org.eclipse.jgit.dircache;version="6.3.0"; + org.eclipse.jgit.dircache;version="6.3.1"; uses:="org.eclipse.jgit.events, org.eclipse.jgit.lib, org.eclipse.jgit.attributes, org.eclipse.jgit.treewalk, org.eclipse.jgit.util", - org.eclipse.jgit.errors;version="6.3.0"; + org.eclipse.jgit.errors;version="6.3.1"; uses:="org.eclipse.jgit.transport, org.eclipse.jgit.dircache, org.eclipse.jgit.lib, org.eclipse.jgit.internal.storage.pack", - org.eclipse.jgit.events;version="6.3.0"; + org.eclipse.jgit.events;version="6.3.1"; uses:="org.eclipse.jgit.lib", - org.eclipse.jgit.fnmatch;version="6.3.0", - org.eclipse.jgit.gitrepo;version="6.3.0"; + org.eclipse.jgit.fnmatch;version="6.3.1", + org.eclipse.jgit.gitrepo;version="6.3.1"; uses:="org.xml.sax.helpers, org.eclipse.jgit.api, org.eclipse.jgit.lib, org.eclipse.jgit.revwalk, org.xml.sax", - org.eclipse.jgit.gitrepo.internal;version="6.3.0";x-internal:=true, - org.eclipse.jgit.hooks;version="6.3.0";uses:="org.eclipse.jgit.lib", - org.eclipse.jgit.ignore;version="6.3.0", - org.eclipse.jgit.ignore.internal;version="6.3.0"; + org.eclipse.jgit.gitrepo.internal;version="6.3.1";x-internal:=true, + org.eclipse.jgit.hooks;version="6.3.1";uses:="org.eclipse.jgit.lib", + org.eclipse.jgit.ignore;version="6.3.1", + org.eclipse.jgit.ignore.internal;version="6.3.1"; x-friends:="org.eclipse.jgit.test", - org.eclipse.jgit.internal;version="6.3.0"; + org.eclipse.jgit.internal;version="6.3.1"; x-friends:="org.eclipse.jgit.test, org.eclipse.jgit.http.test", - org.eclipse.jgit.internal.diff;version="6.3.0"; + org.eclipse.jgit.internal.diff;version="6.3.1"; x-friends:="org.eclipse.jgit.test", - org.eclipse.jgit.internal.diffmergetool;version="6.3.0"; + org.eclipse.jgit.internal.diffmergetool;version="6.3.1"; x-friends:="org.eclipse.jgit.test, org.eclipse.jgit.pgm.test, org.eclipse.jgit.pgm, org.eclipse.egit.ui", - org.eclipse.jgit.internal.fsck;version="6.3.0"; + org.eclipse.jgit.internal.fsck;version="6.3.1"; x-friends:="org.eclipse.jgit.test", - org.eclipse.jgit.internal.revwalk;version="6.3.0"; + org.eclipse.jgit.internal.revwalk;version="6.3.1"; x-friends:="org.eclipse.jgit.test", - org.eclipse.jgit.internal.storage.dfs;version="6.3.0"; + org.eclipse.jgit.internal.storage.dfs;version="6.3.1"; x-friends:="org.eclipse.jgit.test, org.eclipse.jgit.http.server, org.eclipse.jgit.http.test, org.eclipse.jgit.lfs.test", - org.eclipse.jgit.internal.storage.file;version="6.3.0"; + org.eclipse.jgit.internal.storage.file;version="6.3.1"; x-friends:="org.eclipse.jgit.test, org.eclipse.jgit.junit, org.eclipse.jgit.junit.http, @@ -95,32 +95,32 @@ Export-Package: org.eclipse.jgit.annotations;version="6.3.0", org.eclipse.jgit.pgm, org.eclipse.jgit.pgm.test, org.eclipse.jgit.ssh.apache", - org.eclipse.jgit.internal.storage.io;version="6.3.0"; + org.eclipse.jgit.internal.storage.io;version="6.3.1"; x-friends:="org.eclipse.jgit.junit, org.eclipse.jgit.test, org.eclipse.jgit.pgm", - org.eclipse.jgit.internal.storage.pack;version="6.3.0"; + org.eclipse.jgit.internal.storage.pack;version="6.3.1"; x-friends:="org.eclipse.jgit.junit, org.eclipse.jgit.test, org.eclipse.jgit.pgm", - org.eclipse.jgit.internal.storage.reftable;version="6.3.0"; + org.eclipse.jgit.internal.storage.reftable;version="6.3.1"; x-friends:="org.eclipse.jgit.http.test, org.eclipse.jgit.junit, org.eclipse.jgit.test, org.eclipse.jgit.pgm", - org.eclipse.jgit.internal.submodule;version="6.3.0";x-internal:=true, - org.eclipse.jgit.internal.transport.connectivity;version="6.3.0"; + org.eclipse.jgit.internal.submodule;version="6.3.1";x-internal:=true, + org.eclipse.jgit.internal.transport.connectivity;version="6.3.1"; x-friends:="org.eclipse.jgit.test", - org.eclipse.jgit.internal.transport.http;version="6.3.0"; + org.eclipse.jgit.internal.transport.http;version="6.3.1"; x-friends:="org.eclipse.jgit.test", - org.eclipse.jgit.internal.transport.parser;version="6.3.0"; + org.eclipse.jgit.internal.transport.parser;version="6.3.1"; x-friends:="org.eclipse.jgit.http.server, org.eclipse.jgit.test", - org.eclipse.jgit.internal.transport.ssh;version="6.3.0"; + org.eclipse.jgit.internal.transport.ssh;version="6.3.1"; x-friends:="org.eclipse.jgit.ssh.apache, org.eclipse.jgit.ssh.jsch, org.eclipse.jgit.test", - org.eclipse.jgit.lib;version="6.3.0"; + org.eclipse.jgit.lib;version="6.3.1"; uses:="org.eclipse.jgit.transport, org.eclipse.jgit.util.sha1, org.eclipse.jgit.dircache, @@ -134,12 +134,12 @@ Export-Package: org.eclipse.jgit.annotations;version="6.3.0", org.eclipse.jgit.util, org.eclipse.jgit.submodule, org.eclipse.jgit.util.time", - org.eclipse.jgit.lib.internal;version="6.3.0"; + org.eclipse.jgit.lib.internal;version="6.3.1"; x-friends:="org.eclipse.jgit.test, org.eclipse.jgit.pgm, org.eclipse.egit.ui", - org.eclipse.jgit.logging;version="6.3.0", - org.eclipse.jgit.merge;version="6.3.0"; + org.eclipse.jgit.logging;version="6.3.1", + org.eclipse.jgit.merge;version="6.3.1"; uses:="org.eclipse.jgit.dircache, org.eclipse.jgit.lib, org.eclipse.jgit.revwalk, @@ -148,40 +148,40 @@ Export-Package: org.eclipse.jgit.annotations;version="6.3.0", org.eclipse.jgit.util, org.eclipse.jgit.api, org.eclipse.jgit.attributes", - org.eclipse.jgit.nls;version="6.3.0", - org.eclipse.jgit.notes;version="6.3.0"; + org.eclipse.jgit.nls;version="6.3.1", + org.eclipse.jgit.notes;version="6.3.1"; uses:="org.eclipse.jgit.lib, org.eclipse.jgit.revwalk, org.eclipse.jgit.treewalk, org.eclipse.jgit.merge", - org.eclipse.jgit.patch;version="6.3.0"; + org.eclipse.jgit.patch;version="6.3.1"; uses:="org.eclipse.jgit.lib, org.eclipse.jgit.diff", - org.eclipse.jgit.revplot;version="6.3.0"; + org.eclipse.jgit.revplot;version="6.3.1"; uses:="org.eclipse.jgit.lib, org.eclipse.jgit.revwalk", - org.eclipse.jgit.revwalk;version="6.3.0"; + org.eclipse.jgit.revwalk;version="6.3.1"; uses:="org.eclipse.jgit.lib, org.eclipse.jgit.diff, org.eclipse.jgit.treewalk.filter, org.eclipse.jgit.revwalk.filter, org.eclipse.jgit.treewalk", - org.eclipse.jgit.revwalk.filter;version="6.3.0"; + org.eclipse.jgit.revwalk.filter;version="6.3.1"; uses:="org.eclipse.jgit.revwalk, org.eclipse.jgit.lib, org.eclipse.jgit.util", - org.eclipse.jgit.storage.file;version="6.3.0"; + org.eclipse.jgit.storage.file;version="6.3.1"; uses:="org.eclipse.jgit.lib, org.eclipse.jgit.util", - org.eclipse.jgit.storage.pack;version="6.3.0"; + org.eclipse.jgit.storage.pack;version="6.3.1"; uses:="org.eclipse.jgit.lib", - org.eclipse.jgit.submodule;version="6.3.0"; + org.eclipse.jgit.submodule;version="6.3.1"; uses:="org.eclipse.jgit.lib, org.eclipse.jgit.diff, org.eclipse.jgit.treewalk.filter, org.eclipse.jgit.treewalk, org.eclipse.jgit.util", - org.eclipse.jgit.transport;version="6.3.0"; + org.eclipse.jgit.transport;version="6.3.1"; uses:="javax.crypto, org.eclipse.jgit.util.io, org.eclipse.jgit.lib, @@ -194,21 +194,21 @@ Export-Package: org.eclipse.jgit.annotations;version="6.3.0", org.eclipse.jgit.transport.resolver, org.eclipse.jgit.storage.pack, org.eclipse.jgit.errors", - org.eclipse.jgit.transport.http;version="6.3.0"; + org.eclipse.jgit.transport.http;version="6.3.1"; uses:="javax.net.ssl", - org.eclipse.jgit.transport.resolver;version="6.3.0"; + org.eclipse.jgit.transport.resolver;version="6.3.1"; uses:="org.eclipse.jgit.transport, org.eclipse.jgit.lib", - org.eclipse.jgit.treewalk;version="6.3.0"; + org.eclipse.jgit.treewalk;version="6.3.1"; uses:="org.eclipse.jgit.dircache, org.eclipse.jgit.lib, org.eclipse.jgit.attributes, org.eclipse.jgit.revwalk, org.eclipse.jgit.treewalk.filter, org.eclipse.jgit.util", - org.eclipse.jgit.treewalk.filter;version="6.3.0"; + org.eclipse.jgit.treewalk.filter;version="6.3.1"; uses:="org.eclipse.jgit.treewalk", - org.eclipse.jgit.util;version="6.3.0"; + org.eclipse.jgit.util;version="6.3.1"; uses:="org.eclipse.jgit.transport, org.eclipse.jgit.hooks, org.eclipse.jgit.revwalk, @@ -221,12 +221,12 @@ Export-Package: org.eclipse.jgit.annotations;version="6.3.0", org.eclipse.jgit.treewalk, javax.net.ssl, org.eclipse.jgit.util.time", - org.eclipse.jgit.util.io;version="6.3.0"; + org.eclipse.jgit.util.io;version="6.3.1"; uses:="org.eclipse.jgit.attributes, org.eclipse.jgit.lib, org.eclipse.jgit.treewalk", - org.eclipse.jgit.util.sha1;version="6.3.0", - org.eclipse.jgit.util.time;version="6.3.0" + org.eclipse.jgit.util.sha1;version="6.3.1", + org.eclipse.jgit.util.time;version="6.3.1" Bundle-RequiredExecutionEnvironment: JavaSE-11 Import-Package: com.googlecode.javaewah;version="[1.1.6,2.0.0)", javax.crypto, diff --git a/org.eclipse.jgit/META-INF/SOURCE-MANIFEST.MF b/org.eclipse.jgit/META-INF/SOURCE-MANIFEST.MF index 97f57d8738..43e88e531c 100644 --- a/org.eclipse.jgit/META-INF/SOURCE-MANIFEST.MF +++ b/org.eclipse.jgit/META-INF/SOURCE-MANIFEST.MF @@ -3,5 +3,5 @@ Bundle-ManifestVersion: 2 Bundle-Name: org.eclipse.jgit - Sources Bundle-SymbolicName: org.eclipse.jgit.source Bundle-Vendor: Eclipse.org - JGit -Bundle-Version: 6.3.0.qualifier -Eclipse-SourceBundle: org.eclipse.jgit;version="6.3.0.qualifier";roots="." +Bundle-Version: 6.3.1.qualifier +Eclipse-SourceBundle: org.eclipse.jgit;version="6.3.1.qualifier";roots="." diff --git a/org.eclipse.jgit/pom.xml b/org.eclipse.jgit/pom.xml index b57ea15560..7e6bc0a4f4 100644 --- a/org.eclipse.jgit/pom.xml +++ b/org.eclipse.jgit/pom.xml @@ -20,7 +20,7 @@ <parent> <groupId>org.eclipse.jgit</groupId> <artifactId>org.eclipse.jgit-parent</artifactId> - <version>6.3.0-SNAPSHOT</version> + <version>6.3.1-SNAPSHOT</version> </parent> <artifactId>org.eclipse.jgit</artifactId> diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/blame/BlameGenerator.java b/org.eclipse.jgit/src/org/eclipse/jgit/blame/BlameGenerator.java index 93ddfc6607..77967df2e5 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/blame/BlameGenerator.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/blame/BlameGenerator.java @@ -129,7 +129,6 @@ public class BlameGenerator implements AutoCloseable { /** Blame is currently assigned to this source. */ private Candidate outCandidate; - private Region outRegion; /** @@ -404,35 +403,6 @@ public class BlameGenerator implements AutoCloseable { * revision (if the index is interesting), and finally the working tree copy * (if the working tree is interesting). * - * @param blameCommit - * ordered commits to use instead of RevWalk. - * @return {@code this} - * @throws java.io.IOException - * the repository cannot be read. - * @since 6.3 - */ - public BlameGenerator push(RevCommit blameCommit) throws IOException { - if (!find(blameCommit, resultPath)) { - return this; - } - - Candidate c = new Candidate(getRepository(), blameCommit, resultPath); - c.sourceBlob = idBuf.toObjectId(); - c.loadText(reader); - c.regionList = new Region(0, 0, c.sourceText.size()); - remaining = c.sourceText.size(); - push(c); - return this; - } - - /** - * Push a candidate object onto the generator's traversal stack. - * <p> - * Candidates should be pushed in history order from oldest-to-newest. - * Applications should push the starting commit first, then the index - * revision (if the index is interesting), and finally the working tree copy - * (if the working tree is interesting). - * * @param description * description of the blob revision, such as "Working Tree". * @param id @@ -458,7 +428,16 @@ public class BlameGenerator implements AutoCloseable { } RevCommit commit = revPool.parseCommit(id); - return push(commit); + if (!find(commit, resultPath)) + return this; + + Candidate c = new Candidate(getRepository(), commit, resultPath); + c.sourceBlob = idBuf.toObjectId(); + c.loadText(reader); + c.regionList = new Region(0, 0, c.sourceText.size()); + remaining = c.sourceText.size(); + push(c); + return this; } /** @@ -626,7 +605,7 @@ public class BlameGenerator implements AutoCloseable { // Do not generate a tip of a reverse. The region // survives and should not appear to be deleted. - } else /* if (pCnt == 0) */ { + } else /* if (pCnt == 0) */{ // Root commit, with at least one surviving region. // Assign the remaining blame here. return result(n); @@ -867,8 +846,8 @@ public class BlameGenerator implements AutoCloseable { editList = new EditList(0); } else { p.loadText(reader); - editList = diffAlgorithm.diff(textComparator, p.sourceText, - n.sourceText); + editList = diffAlgorithm.diff(textComparator, + p.sourceText, n.sourceText); } if (editList.isEmpty()) { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java b/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java index 23f8e4a5d5..8b9b569c38 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java @@ -3,7 +3,7 @@ * Copyright (C) 2010-2012, Matthias Sohn <matthias.sohn@sap.com> * Copyright (C) 2012, Research In Motion Limited * Copyright (C) 2017, Obeo (mathieu.cartaud@obeo.fr) - * Copyright (C) 2018, 2022 Thomas Wolf <thomas.wolf@paranor.ch> and others + * Copyright (C) 2018, 2022 Thomas Wolf <twolf@apache.org> and others * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0 which is available at @@ -321,6 +321,25 @@ public class ResolveMerger extends ThreeWayMerger { } /** + * Adds the conflict stages for the current path of {@link #tw} to the index + * builder and returns the "theirs" stage; if present. + * + * @param base + * of the conflict + * @param ours + * of the conflict + * @param theirs + * of the conflict + * @return the {@link DirCacheEntry} for the "theirs" stage, or {@code null} + */ + private DirCacheEntry addConflict(CanonicalTreeParser base, + CanonicalTreeParser ours, CanonicalTreeParser theirs) { + add(tw.getRawPath(), base, DirCacheEntry.STAGE_1, EPOCH, 0); + add(tw.getRawPath(), ours, DirCacheEntry.STAGE_2, EPOCH, 0); + return add(tw.getRawPath(), theirs, DirCacheEntry.STAGE_3, EPOCH, 0); + } + + /** * adds a entry to the index builder which is a copy of the specified * DirCacheEntry * @@ -501,9 +520,7 @@ public class ResolveMerger extends ThreeWayMerger { // length. // This path can be skipped on ignoreConflicts, so the caller // could use virtual commit. - add(tw.getRawPath(), base, DirCacheEntry.STAGE_1, EPOCH, 0); - add(tw.getRawPath(), ours, DirCacheEntry.STAGE_2, EPOCH, 0); - add(tw.getRawPath(), theirs, DirCacheEntry.STAGE_3, EPOCH, 0); + addConflict(base, ours, theirs); unmergedPaths.add(tw.getPathString()); mergeResults.put(tw.getPathString(), new MergeResult<>(Collections.emptyList())); @@ -608,9 +625,7 @@ public class ResolveMerger extends ThreeWayMerger { add(tw.getRawPath(), ours, DirCacheEntry.STAGE_0, EPOCH, 0); return true; } else if (gitLinkMerging) { - add(tw.getRawPath(), base, DirCacheEntry.STAGE_1, EPOCH, 0); - add(tw.getRawPath(), ours, DirCacheEntry.STAGE_2, EPOCH, 0); - add(tw.getRawPath(), theirs, DirCacheEntry.STAGE_3, EPOCH, 0); + addConflict(base, ours, theirs); MergeResult<SubmoduleConflict> result = createGitLinksMergeResult( base, ours, theirs); result.setContainsConflicts(true); @@ -631,9 +646,7 @@ public class ResolveMerger extends ThreeWayMerger { default: break; } - add(tw.getRawPath(), base, DirCacheEntry.STAGE_1, EPOCH, 0); - add(tw.getRawPath(), ours, DirCacheEntry.STAGE_2, EPOCH, 0); - add(tw.getRawPath(), theirs, DirCacheEntry.STAGE_3, EPOCH, 0); + addConflict(base, ours, theirs); // attribute merge issues are conflicts but not failures unmergedPaths.add(tw.getPathString()); @@ -646,30 +659,61 @@ public class ResolveMerger extends ThreeWayMerger { } MergeResult<RawText> result = null; - try { - result = contentMerge(base, ours, theirs, attributes, - getContentMergeStrategy()); - } catch (BinaryBlobException e) { + boolean hasSymlink = FileMode.SYMLINK.equals(modeO) + || FileMode.SYMLINK.equals(modeT); + if (!hasSymlink) { + try { + result = contentMerge(base, ours, theirs, attributes, + getContentMergeStrategy()); + } catch (BinaryBlobException e) { + // result == null + } + } + if (result == null) { switch (getContentMergeStrategy()) { - case OURS: - keep(ourDce); - return true; - case THEIRS: - DirCacheEntry theirEntry = add(tw.getRawPath(), theirs, - DirCacheEntry.STAGE_0, EPOCH, 0); - addToCheckout(tw.getPathString(), theirEntry, attributes); - return true; - default: - result = new MergeResult<>(Collections.emptyList()); - result.setContainsConflicts(true); - break; + case OURS: + keep(ourDce); + return true; + case THEIRS: + DirCacheEntry e = add(tw.getRawPath(), theirs, + DirCacheEntry.STAGE_0, EPOCH, 0); + if (e != null) { + addToCheckout(tw.getPathString(), e, attributes); + } + return true; + default: + result = new MergeResult<>(Collections.emptyList()); + result.setContainsConflicts(true); + break; } } if (ignoreConflicts) { result.setContainsConflicts(false); } - updateIndex(base, ours, theirs, result, attributes[T_OURS]); String currentPath = tw.getPathString(); + if (hasSymlink) { + if (ignoreConflicts) { + if (((modeT & FileMode.TYPE_MASK) == FileMode.TYPE_FILE)) { + DirCacheEntry e = add(tw.getRawPath(), theirs, + DirCacheEntry.STAGE_0, EPOCH, 0); + addToCheckout(currentPath, e, attributes); + } else { + keep(ourDce); + } + } else { + // Record the conflict + DirCacheEntry e = addConflict(base, ours, theirs); + mergeResults.put(currentPath, result); + // If theirs is a file, check it out. In link/file + // conflicts, C git prefers the file. + if (((modeT & FileMode.TYPE_MASK) == FileMode.TYPE_FILE) + && e != null) { + addToCheckout(currentPath, e, attributes); + } + } + } else { + updateIndex(base, ours, theirs, result, attributes[T_OURS]); + } if (result.containsConflicts() && !ignoreConflicts) { unmergedPaths.add(currentPath); } @@ -683,40 +727,58 @@ public class ResolveMerger extends ThreeWayMerger { if (gitLinkMerging && ignoreConflicts) { add(tw.getRawPath(), ours, DirCacheEntry.STAGE_0, EPOCH, 0); } else if (gitLinkMerging) { - add(tw.getRawPath(), base, DirCacheEntry.STAGE_1, EPOCH, 0); - add(tw.getRawPath(), ours, DirCacheEntry.STAGE_2, EPOCH, 0); - add(tw.getRawPath(), theirs, DirCacheEntry.STAGE_3, EPOCH, 0); + addConflict(base, ours, theirs); MergeResult<SubmoduleConflict> result = createGitLinksMergeResult( base, ours, theirs); result.setContainsConflicts(true); mergeResults.put(tw.getPathString(), result); unmergedPaths.add(tw.getPathString()); } else { + boolean isSymLink = ((modeO | modeT) + & FileMode.TYPE_MASK) == FileMode.TYPE_SYMLINK; // Content merge strategy does not apply to delete-modify // conflicts! MergeResult<RawText> result; - try { - result = contentMerge(base, ours, theirs, attributes, - ContentMergeStrategy.CONFLICT); - } catch (BinaryBlobException e) { + if (isSymLink) { + // No need to do a content merge result = new MergeResult<>(Collections.emptyList()); result.setContainsConflicts(true); + } else { + try { + result = contentMerge(base, ours, theirs, + attributes, ContentMergeStrategy.CONFLICT); + } catch (BinaryBlobException e) { + result = new MergeResult<>(Collections.emptyList()); + result.setContainsConflicts(true); + } } if (ignoreConflicts) { - // In case a conflict is detected the working tree file - // is again filled with new content (containing conflict - // markers). But also stage 0 of the index is filled - // with that content. result.setContainsConflicts(false); - updateIndex(base, ours, theirs, result, - attributes[T_OURS]); + if (isSymLink) { + if (modeO != 0) { + keep(ourDce); + } else { + // Check out theirs + if (isWorktreeDirty(work, ourDce)) { + return false; + } + DirCacheEntry e = add(tw.getRawPath(), theirs, + DirCacheEntry.STAGE_0, EPOCH, 0); + if (e != null) { + addToCheckout(tw.getPathString(), e, + attributes); + } + } + } else { + // In case a conflict is detected the working tree + // file is again filled with new content (containing + // conflict markers). But also stage 0 of the index + // is filled with that content. + updateIndex(base, ours, theirs, result, + attributes[T_OURS]); + } } else { - add(tw.getRawPath(), base, DirCacheEntry.STAGE_1, EPOCH, - 0); - add(tw.getRawPath(), ours, DirCacheEntry.STAGE_2, EPOCH, - 0); - DirCacheEntry e = add(tw.getRawPath(), theirs, - DirCacheEntry.STAGE_3, EPOCH, 0); + DirCacheEntry e = addConflict(base, ours, theirs); // OURS was deleted checkout THEIRS if (modeO == 0) { @@ -862,25 +924,25 @@ public class ResolveMerger extends ThreeWayMerger { // A conflict occurred, the file will contain conflict markers // the index will be populated with the three stages and the // workdir (if used) contains the halfway merged content. - add(tw.getRawPath(), base, DirCacheEntry.STAGE_1, EPOCH, 0); - add(tw.getRawPath(), ours, DirCacheEntry.STAGE_2, EPOCH, 0); - add(tw.getRawPath(), theirs, DirCacheEntry.STAGE_3, EPOCH, 0); + addConflict(base, ours, theirs); mergeResults.put(tw.getPathString(), result); return; } // No conflict occurred, the file will contain fully merged content. // The index will be populated with the new merged version. - Instant lastModified = - mergedFile == null ? null : nonNullRepo().getFS().lastModifiedInstant(mergedFile); + Instant lastModified = mergedFile == null ? null + : nonNullRepo().getFS().lastModifiedInstant(mergedFile); // Set the mode for the new content. Fall back to REGULAR_FILE if // we can't merge modes of OURS and THEIRS. int newMode = mergeFileModes(tw.getRawMode(0), tw.getRawMode(1), tw.getRawMode(2)); FileMode mode = newMode == FileMode.MISSING.getBits() ? FileMode.REGULAR_FILE : FileMode.fromBits(newMode); - workTreeUpdater.insertToIndex(rawMerged.openInputStream(), tw.getPathString().getBytes(UTF_8), mode, - DirCacheEntry.STAGE_0, lastModified, (int) rawMerged.length(), + workTreeUpdater.insertToIndex(rawMerged.openInputStream(), + tw.getPathString().getBytes(UTF_8), mode, + DirCacheEntry.STAGE_0, lastModified, + (int) rawMerged.length(), attributes.get(Constants.ATTR_MERGE)); } finally { if (rawMerged != null) { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/FilteredRevCommit.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/FilteredRevCommit.java deleted file mode 100644 index 16beac3903..0000000000 --- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/FilteredRevCommit.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (C) 2022, Google LLC. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Distribution License v. 1.0 which is available at - * https://www.eclipse.org/org/documents/edl-v10.php. - * - * SPDX-License-Identifier: BSD-3-Clause - */ -package org.eclipse.jgit.revwalk; - -/** - * A filtered commit reference that overrides its parent in the DAG. - * - * @since 6.3 - */ -public class FilteredRevCommit extends RevCommit { - private RevCommit[] overriddenParents; - - /** - * Create a new commit reference wrapping an underlying commit reference. - * - * @param commit - * commit that is being wrapped - */ - public FilteredRevCommit(RevCommit commit) { - this(commit, NO_PARENTS); - } - - /** - * Create a new commit reference wrapping an underlying commit reference. - * - * @param commit - * commit that is being wrapped - * @param parents - * overridden parents for the commit - */ - public FilteredRevCommit(RevCommit commit, RevCommit... parents) { - super(commit); - this.overriddenParents = parents; - this.parents = NO_PARENTS; - } - - /** - * Update parents on the commit - * - * @param overriddenParents - * parents to be overwritten - */ - public void setParents(RevCommit... overriddenParents) { - this.overriddenParents = overriddenParents; - } - - /** - * Get the number of parent commits listed in this commit. - * - * @return number of parents; always a positive value but can be 0 if it has - * no parents. - */ - @Override - public int getParentCount() { - return overriddenParents.length; - } - - /** - * Get the nth parent from this commit's parent list. - * - * @param nth - * parent index to obtain. Must be in the range 0 through - * {@link #getParentCount()}-1. - * @return the specified parent. - * @throws java.lang.ArrayIndexOutOfBoundsException - * an invalid parent index was specified. - */ - @Override - public RevCommit getParent(int nth) { - return overriddenParents[nth]; - } - - /** - * Obtain an array of all parents (<b>NOTE - THIS IS NOT A COPY</b>). - * - * <p> - * This method is exposed only to provide very fast, efficient access to - * this commit's parent list. Applications relying on this list should be - * very careful to ensure they do not modify its contents during their use - * of it. - * - * @return the array of parents. - */ - @Override - public RevCommit[] getParents() { - return overriddenParents; - } -} diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevCommit.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevCommit.java index a7c21e3f13..6b644cef90 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevCommit.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevCommit.java @@ -114,7 +114,7 @@ public class RevCommit extends RevObject { * * @since 6.3 */ - RevCommit[] parents; + protected RevCommit[] parents; int commitTime; // An int here for performance, overflows in 2038 @@ -132,22 +132,6 @@ public class RevCommit extends RevObject { super(id); } - /** - * Create a new commit reference. - * - * @param orig - * commit to be copied from. - */ - RevCommit(RevCommit orig) { - super(orig.getId()); - this.buffer = orig.buffer; - this.commitTime = orig.commitTime; - this.flags = orig.flags; - this.parents = orig.parents; - this.tree = orig.tree; - this.inDegree = orig.inDegree; - } - @Override void parseHeaders(RevWalk walk) throws MissingObjectException, IncorrectObjectTypeException, IOException { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RewriteGenerator.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RewriteGenerator.java index 9ec331b697..2c88bb872e 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RewriteGenerator.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RewriteGenerator.java @@ -11,8 +11,6 @@ package org.eclipse.jgit.revwalk; import java.io.IOException; -import java.util.HashMap; -import java.util.Map; import org.eclipse.jgit.errors.IncorrectObjectTypeException; import org.eclipse.jgit.errors.MissingObjectException; @@ -40,13 +38,10 @@ class RewriteGenerator extends Generator { private final FIFORevQueue pending; - private final Map<RevCommit, FilteredRevCommit> transformedCommits; - RewriteGenerator(Generator s) { super(s.firstParent); source = s; pending = new FIFORevQueue(s.firstParent); - transformedCommits = new HashMap<>(); } @Override @@ -63,10 +58,10 @@ class RewriteGenerator extends Generator { @Override RevCommit next() throws MissingObjectException, IncorrectObjectTypeException, IOException { - FilteredRevCommit c = (FilteredRevCommit) pending.next(); + RevCommit c = pending.next(); if (c == null) { - c = transform(source.next()); + c = source.next(); if (c == null) { // We are done: Both the source generator and our internal list // are completely exhausted. @@ -84,9 +79,9 @@ class RewriteGenerator extends Generator { final RevCommit newp = rewrite(oldp); if (firstParent) { if (newp == null) { - c.setParents(RevCommit.NO_PARENTS); + c.parents = RevCommit.NO_PARENTS; } else { - c.setParents(newp); + c.parents = new RevCommit[] { newp }; } return c; } @@ -96,7 +91,7 @@ class RewriteGenerator extends Generator { } } if (rewrote) { - c.setParents(cleanup(pList)); + c.parents = cleanup(pList); } return c; } @@ -116,7 +111,7 @@ class RewriteGenerator extends Generator { for (RevCommit parent : c.getParents()) { while ((parent.flags & RevWalk.TREE_REV_FILTER_APPLIED) == 0) { - FilteredRevCommit n = transform(source.next()); + RevCommit n = source.next(); if (n != null) { pending.add(n); @@ -135,8 +130,6 @@ class RewriteGenerator extends Generator { IncorrectObjectTypeException, IOException { for (;;) { - p = transform(p); - if (p.getParentCount() > 1) { // This parent is a merge, so keep it. // @@ -165,25 +158,9 @@ class RewriteGenerator extends Generator { } applyFilterToParents(p.getParent(0)); - p = transform(p.getParent(0)); - - } - } + p = p.getParent(0); - private FilteredRevCommit transform(RevCommit c) { - if (c == null) { - return null; } - - if (c instanceof FilteredRevCommit) { - return (FilteredRevCommit) c; - } - - if (!transformedCommits.containsKey(c)) { - transformedCommits.put(c, new FilteredRevCommit(c, c.getParents())); - } - - return transformedCommits.get(c); } private RevCommit[] cleanup(RevCommit[] oldList) { |