ResolveMerger: do not content-merge gitlinks on del/mod conflicts
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
This commit is contained in:
parent
2ae84c320a
commit
214c4afc2c
|
@ -27,7 +27,6 @@
|
||||||
import org.eclipse.jgit.lib.PersonIdent;
|
import org.eclipse.jgit.lib.PersonIdent;
|
||||||
import org.eclipse.jgit.test.resources.SampleDataRepositoryTestCase;
|
import org.eclipse.jgit.test.resources.SampleDataRepositoryTestCase;
|
||||||
import org.eclipse.jgit.treewalk.TreeWalk;
|
import org.eclipse.jgit.treewalk.TreeWalk;
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class GitlinkMergeTest extends SampleDataRepositoryTestCase {
|
public class GitlinkMergeTest extends SampleDataRepositoryTestCase {
|
||||||
|
@ -38,7 +37,6 @@ public class GitlinkMergeTest extends SampleDataRepositoryTestCase {
|
||||||
private static final String SUBMODULE_PATH = "submodule.link";
|
private static final String SUBMODULE_PATH = "submodule.link";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore("Broken")
|
|
||||||
public void testGitLinkMerging_AddNew() throws Exception {
|
public void testGitLinkMerging_AddNew() throws Exception {
|
||||||
assertGitLinkValue(
|
assertGitLinkValue(
|
||||||
testGitLink(null, null, LINK_ID3, newResolveMerger(), true),
|
testGitLink(null, null, LINK_ID3, newResolveMerger(), true),
|
||||||
|
@ -46,20 +44,17 @@ public void testGitLinkMerging_AddNew() throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore("Broken")
|
|
||||||
public void testGitLinkMerging_Delete() throws Exception {
|
public void testGitLinkMerging_Delete() throws Exception {
|
||||||
assertGitLinkDoesntExist(testGitLink(LINK_ID1, LINK_ID1, null,
|
assertGitLinkDoesntExist(testGitLink(LINK_ID1, LINK_ID1, null,
|
||||||
newResolveMerger(), true));
|
newResolveMerger(), true));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore("Broken")
|
|
||||||
public void testGitLinkMerging_UpdateDelete() throws Exception {
|
public void testGitLinkMerging_UpdateDelete() throws Exception {
|
||||||
testGitLink(LINK_ID1, LINK_ID2, null, newResolveMerger(), false);
|
testGitLink(LINK_ID1, LINK_ID2, null, newResolveMerger(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore("Broken")
|
|
||||||
public void testGitLinkMerging_DeleteUpdate() throws Exception {
|
public void testGitLinkMerging_DeleteUpdate() throws Exception {
|
||||||
testGitLink(LINK_ID1, null, LINK_ID3, newResolveMerger(), false);
|
testGitLink(LINK_ID1, null, LINK_ID3, newResolveMerger(), false);
|
||||||
}
|
}
|
||||||
|
@ -90,14 +85,12 @@ public void testGitLinkMerging_AddNew_ignoreConflicts() throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore("Broken")
|
|
||||||
public void testGitLinkMerging_Delete_ignoreConflicts() throws Exception {
|
public void testGitLinkMerging_Delete_ignoreConflicts() throws Exception {
|
||||||
assertGitLinkDoesntExist(testGitLink(LINK_ID1, LINK_ID1, null,
|
assertGitLinkDoesntExist(testGitLink(LINK_ID1, LINK_ID1, null,
|
||||||
newIgnoreConflictMerger(), true));
|
newIgnoreConflictMerger(), true));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore("Broken")
|
|
||||||
public void testGitLinkMerging_UpdateDelete_ignoreConflicts()
|
public void testGitLinkMerging_UpdateDelete_ignoreConflicts()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
assertGitLinkValue(testGitLink(LINK_ID1, LINK_ID2, null,
|
assertGitLinkValue(testGitLink(LINK_ID1, LINK_ID2, null,
|
||||||
|
@ -105,7 +98,6 @@ public void testGitLinkMerging_UpdateDelete_ignoreConflicts()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore("Broken")
|
|
||||||
public void testGitLinkMerging_DeleteUpdate_ignoreConflicts()
|
public void testGitLinkMerging_DeleteUpdate_ignoreConflicts()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
assertGitLinkDoesntExist(testGitLink(LINK_ID1, null, LINK_ID3,
|
assertGitLinkDoesntExist(testGitLink(LINK_ID1, null, LINK_ID3,
|
||||||
|
@ -299,7 +291,6 @@ public void testGitLinkMerging_blobWithBlobFromLink() throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore("Broken")
|
|
||||||
public void testGitLinkMerging_linkBlobDeleted() throws Exception {
|
public void testGitLinkMerging_linkBlobDeleted() throws Exception {
|
||||||
// We changed a link to a blob, others has deleted this link.
|
// We changed a link to a blob, others has deleted this link.
|
||||||
DirCache treeB = db.readDirCache();
|
DirCache treeB = db.readDirCache();
|
||||||
|
|
|
@ -757,6 +757,7 @@ protected boolean processEntry(CanonicalTreeParser base,
|
||||||
add(tw.getRawPath(), base, DirCacheEntry.STAGE_1, EPOCH, 0);
|
add(tw.getRawPath(), base, DirCacheEntry.STAGE_1, EPOCH, 0);
|
||||||
add(tw.getRawPath(), ours, DirCacheEntry.STAGE_2, EPOCH, 0);
|
add(tw.getRawPath(), ours, DirCacheEntry.STAGE_2, EPOCH, 0);
|
||||||
add(tw.getRawPath(), theirs, DirCacheEntry.STAGE_3, EPOCH, 0);
|
add(tw.getRawPath(), theirs, DirCacheEntry.STAGE_3, EPOCH, 0);
|
||||||
|
|
||||||
// attribute merge issues are conflicts but not failures
|
// attribute merge issues are conflicts but not failures
|
||||||
unmergedPaths.add(tw.getPathString());
|
unmergedPaths.add(tw.getPathString());
|
||||||
return true;
|
return true;
|
||||||
|
@ -783,40 +784,55 @@ protected boolean processEntry(CanonicalTreeParser base,
|
||||||
// OURS or THEIRS has been deleted
|
// OURS or THEIRS has been deleted
|
||||||
if (((modeO != 0 && !tw.idEqual(T_BASE, T_OURS)) || (modeT != 0 && !tw
|
if (((modeO != 0 && !tw.idEqual(T_BASE, T_OURS)) || (modeT != 0 && !tw
|
||||||
.idEqual(T_BASE, T_THEIRS)))) {
|
.idEqual(T_BASE, T_THEIRS)))) {
|
||||||
MergeResult<RawText> result = contentMerge(base, ours, theirs,
|
if (gitLinkMerging && ignoreConflicts) {
|
||||||
attributes);
|
add(tw.getRawPath(), ours, DirCacheEntry.STAGE_0, EPOCH, 0);
|
||||||
|
} else if (gitLinkMerging) {
|
||||||
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);
|
|
||||||
} else {
|
|
||||||
add(tw.getRawPath(), base, DirCacheEntry.STAGE_1, EPOCH, 0);
|
add(tw.getRawPath(), base, DirCacheEntry.STAGE_1, EPOCH, 0);
|
||||||
add(tw.getRawPath(), ours, DirCacheEntry.STAGE_2, EPOCH, 0);
|
add(tw.getRawPath(), ours, DirCacheEntry.STAGE_2, EPOCH, 0);
|
||||||
DirCacheEntry e = add(tw.getRawPath(), theirs,
|
add(tw.getRawPath(), theirs, DirCacheEntry.STAGE_3, EPOCH, 0);
|
||||||
DirCacheEntry.STAGE_3, EPOCH, 0);
|
MergeResult<SubmoduleConflict> result = createGitLinksMergeResult(
|
||||||
|
base, ours, theirs);
|
||||||
|
result.setContainsConflicts(true);
|
||||||
|
mergeResults.put(tw.getPathString(), result);
|
||||||
|
unmergedPaths.add(tw.getPathString());
|
||||||
|
} else {
|
||||||
|
MergeResult<RawText> result = contentMerge(base, ours,
|
||||||
|
theirs, attributes);
|
||||||
|
|
||||||
// OURS was deleted checkout THEIRS
|
if (ignoreConflicts) {
|
||||||
if (modeO == 0) {
|
// In case a conflict is detected the working tree file
|
||||||
// Check worktree before checking out THEIRS
|
// is again filled with new content (containing conflict
|
||||||
if (isWorktreeDirty(work, ourDce)) {
|
// markers). But also stage 0 of the index is filled
|
||||||
return false;
|
// with that content.
|
||||||
}
|
result.setContainsConflicts(false);
|
||||||
if (nonTree(modeT)) {
|
updateIndex(base, ours, theirs, result, attributes);
|
||||||
if (e != null) {
|
} else {
|
||||||
addToCheckout(tw.getPathString(), e,
|
add(tw.getRawPath(), base, DirCacheEntry.STAGE_1, EPOCH,
|
||||||
attributes);
|
0);
|
||||||
|
add(tw.getRawPath(), ours, DirCacheEntry.STAGE_2, EPOCH,
|
||||||
|
0);
|
||||||
|
DirCacheEntry e = add(tw.getRawPath(), theirs,
|
||||||
|
DirCacheEntry.STAGE_3, EPOCH, 0);
|
||||||
|
|
||||||
|
// OURS was deleted checkout THEIRS
|
||||||
|
if (modeO == 0) {
|
||||||
|
// Check worktree before checking out THEIRS
|
||||||
|
if (isWorktreeDirty(work, ourDce)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (nonTree(modeT)) {
|
||||||
|
if (e != null) {
|
||||||
|
addToCheckout(tw.getPathString(), e,
|
||||||
|
attributes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unmergedPaths.add(tw.getPathString());
|
||||||
|
|
||||||
|
// generate a MergeResult for the deleted file
|
||||||
|
mergeResults.put(tw.getPathString(), result);
|
||||||
}
|
}
|
||||||
|
|
||||||
unmergedPaths.add(tw.getPathString());
|
|
||||||
|
|
||||||
// generate a MergeResult for the deleted file
|
|
||||||
mergeResults.put(tw.getPathString(), result);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue