|
|
|
@ -75,7 +75,7 @@ public class SymlinksTest extends RepositoryTestCase {
|
|
|
|
|
*/ |
|
|
|
|
@Test |
|
|
|
|
public void fileModeTestFileThenSymlink() throws Exception { |
|
|
|
|
Git git = new Git(db); |
|
|
|
|
try (Git git = new Git(db)) { |
|
|
|
|
writeTrashFile("a", "Hello world a"); |
|
|
|
|
writeTrashFile("b", "Hello world b"); |
|
|
|
|
git.add().addFilepattern(".").call(); |
|
|
|
@ -96,6 +96,7 @@ public class SymlinksTest extends RepositoryTestCase {
|
|
|
|
|
db.getFS()); |
|
|
|
|
assertEquals(FileMode.REGULAR_FILE, entry.getMode()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Steps: 1.Add symlink 'a' 2.Commit 3.Create branch '1' 4.Replace symlink |
|
|
|
@ -108,7 +109,7 @@ public class SymlinksTest extends RepositoryTestCase {
|
|
|
|
|
*/ |
|
|
|
|
@Test |
|
|
|
|
public void fileModeTestSymlinkThenFile() throws Exception { |
|
|
|
|
Git git = new Git(db); |
|
|
|
|
try (Git git = new Git(db)) { |
|
|
|
|
writeTrashFile("b", "Hello world b"); |
|
|
|
|
FileUtils.createSymLink(new File(db.getWorkTree(), "a"), "b"); |
|
|
|
|
git.add().addFilepattern(".").call(); |
|
|
|
@ -129,6 +130,7 @@ public class SymlinksTest extends RepositoryTestCase {
|
|
|
|
|
db.getFS()); |
|
|
|
|
assertEquals(FileMode.SYMLINK, entry.getMode()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Steps: 1.Add folder 'a' 2.Commit 3.Create branch '1' 4.Replace folder 'a' |
|
|
|
@ -141,7 +143,7 @@ public class SymlinksTest extends RepositoryTestCase {
|
|
|
|
|
*/ |
|
|
|
|
@Test |
|
|
|
|
public void fileModeTestFolderThenSymlink() throws Exception { |
|
|
|
|
Git git = new Git(db); |
|
|
|
|
try (Git git = new Git(db)) { |
|
|
|
|
FileUtils.mkdirs(new File(db.getWorkTree(), "a")); |
|
|
|
|
writeTrashFile("a/b", "Hello world b"); |
|
|
|
|
writeTrashFile("c", "Hello world c"); |
|
|
|
@ -163,6 +165,7 @@ public class SymlinksTest extends RepositoryTestCase {
|
|
|
|
|
db.getFS()); |
|
|
|
|
assertEquals(FileMode.TREE, entry.getMode()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Steps: 1.Add symlink 'a' 2.Commit 3.Create branch '1' 4.Replace symlink |
|
|
|
@ -175,7 +178,7 @@ public class SymlinksTest extends RepositoryTestCase {
|
|
|
|
|
*/ |
|
|
|
|
@Test |
|
|
|
|
public void fileModeTestSymlinkThenFolder() throws Exception { |
|
|
|
|
Git git = new Git(db); |
|
|
|
|
try (Git git = new Git(db)) { |
|
|
|
|
writeTrashFile("c", "Hello world c"); |
|
|
|
|
FileUtils.createSymLink(new File(db.getWorkTree(), "a"), "c"); |
|
|
|
|
git.add().addFilepattern(".").call(); |
|
|
|
@ -197,6 +200,7 @@ public class SymlinksTest extends RepositoryTestCase {
|
|
|
|
|
db.getFS()); |
|
|
|
|
assertEquals(FileMode.SYMLINK, entry.getMode()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Steps: 1.Add file 'b' 2.Commit 3.Create branch '1' 4.Add symlink 'a' |
|
|
|
@ -209,7 +213,8 @@ public class SymlinksTest extends RepositoryTestCase {
|
|
|
|
|
*/ |
|
|
|
|
@Test |
|
|
|
|
public void fileModeTestMissingThenSymlink() throws Exception { |
|
|
|
|
Git git = new Git(db); |
|
|
|
|
try (Git git = new Git(db); |
|
|
|
|
TreeWalk tw = new TreeWalk(db);) { |
|
|
|
|
writeTrashFile("b", "Hello world b"); |
|
|
|
|
git.add().addFilepattern(".").call(); |
|
|
|
|
RevCommit commit1 = git.commit().setMessage("add file b").call(); |
|
|
|
@ -220,7 +225,6 @@ public class SymlinksTest extends RepositoryTestCase {
|
|
|
|
|
|
|
|
|
|
git.checkout().setName(branch_1.getName()).call(); |
|
|
|
|
|
|
|
|
|
TreeWalk tw = new TreeWalk(db); |
|
|
|
|
tw.addTree(commit1.getTree()); |
|
|
|
|
tw.addTree(commit2.getTree()); |
|
|
|
|
List<DiffEntry> scan = DiffEntry.scan(tw); |
|
|
|
@ -228,6 +232,7 @@ public class SymlinksTest extends RepositoryTestCase {
|
|
|
|
|
assertEquals(FileMode.SYMLINK, scan.get(0).getNewMode()); |
|
|
|
|
assertEquals(FileMode.MISSING, scan.get(0).getOldMode()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Steps: 1.Add symlink 'a' 2.Commit 3.Create branch '1' 4.Delete symlink |
|
|
|
@ -240,7 +245,8 @@ public class SymlinksTest extends RepositoryTestCase {
|
|
|
|
|
*/ |
|
|
|
|
@Test |
|
|
|
|
public void fileModeTestSymlinkThenMissing() throws Exception { |
|
|
|
|
Git git = new Git(db); |
|
|
|
|
try (Git git = new Git(db); |
|
|
|
|
TreeWalk tw = new TreeWalk(db);) { |
|
|
|
|
writeTrashFile("b", "Hello world b"); |
|
|
|
|
FileUtils.createSymLink(new File(db.getWorkTree(), "a"), "b"); |
|
|
|
|
git.add().addFilepattern(".").call(); |
|
|
|
@ -252,7 +258,6 @@ public class SymlinksTest extends RepositoryTestCase {
|
|
|
|
|
|
|
|
|
|
git.checkout().setName(branch_1.getName()).call(); |
|
|
|
|
|
|
|
|
|
TreeWalk tw = new TreeWalk(db); |
|
|
|
|
tw.addTree(commit1.getTree()); |
|
|
|
|
tw.addTree(commit2.getTree()); |
|
|
|
|
List<DiffEntry> scan = DiffEntry.scan(tw); |
|
|
|
@ -260,10 +265,11 @@ public class SymlinksTest extends RepositoryTestCase {
|
|
|
|
|
assertEquals(FileMode.MISSING, scan.get(0).getNewMode()); |
|
|
|
|
assertEquals(FileMode.SYMLINK, scan.get(0).getOldMode()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void createSymlinkAfterTarget() throws Exception { |
|
|
|
|
Git git = new Git(db); |
|
|
|
|
try (Git git = new Git(db)) { |
|
|
|
|
writeTrashFile("a", "start"); |
|
|
|
|
git.add().addFilepattern("a").call(); |
|
|
|
|
RevCommit base = git.commit().setMessage("init").call(); |
|
|
|
@ -284,10 +290,11 @@ public class SymlinksTest extends RepositoryTestCase {
|
|
|
|
|
FileUtils.readSymLink(new File(db.getWorkTree(), "link"))); |
|
|
|
|
assertEquals("someData", data); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void createFileSymlinkBeforeTarget() throws Exception { |
|
|
|
|
Git git = new Git(db); |
|
|
|
|
try (Git git = new Git(db)) { |
|
|
|
|
writeTrashFile("a", "start"); |
|
|
|
|
git.add().addFilepattern("a").call(); |
|
|
|
|
RevCommit base = git.commit().setMessage("init").call(); |
|
|
|
@ -308,10 +315,11 @@ public class SymlinksTest extends RepositoryTestCase {
|
|
|
|
|
FileUtils.readSymLink(new File(db.getWorkTree(), "tlink"))); |
|
|
|
|
assertEquals("someData", data); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void createDirSymlinkBeforeTarget() throws Exception { |
|
|
|
|
Git git = new Git(db); |
|
|
|
|
try (Git git = new Git(db)) { |
|
|
|
|
writeTrashFile("a", "start"); |
|
|
|
|
git.add().addFilepattern("a").call(); |
|
|
|
|
RevCommit base = git.commit().setMessage("init").call(); |
|
|
|
@ -334,3 +342,4 @@ public class SymlinksTest extends RepositoryTestCase {
|
|
|
|
|
assertEquals("someData", data); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|