* stable-4.2: CheckoutCommandTest: Create Git instances in try-with-resource BranchCommandTest: Create Git instances in try-with-resource CheckoutTest: Create Git instances in try-with-resource BranchTest: Create Git instances in try-with-resource URIishTest: Use @Test annotation's `expected` argument Suppress "The allocated object is never used" warning in tests Add $NON-NLS to suppress "Non-externalized string literal" warnings Don't use deprecated constructors of CmdLineException Prepare 4.2.0-SNAPSHOT builds Remove org.eclipse.jgit.updatesite project from tools/version.sh RevParse: Remove superfluous semicolon RefUpdateTest: Use try-with-resource for auto-closable types RefUpdateTest: Add null check to prevent potential NPE CommitCommand: Remove redundant null check JGit v4.2.0.201512141825-rc1 Change-Id: I2179859289b2f2e3d0b7c6d02ef7e7890c467f7b Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>tags/v4.2.0.201601211800-r
@@ -63,7 +63,9 @@ public class BranchTest extends CLIRepositoryTestCase { | |||
@Before | |||
public void setUp() throws Exception { | |||
super.setUp(); | |||
new Git(db).commit().setMessage("initial commit").call(); | |||
try (Git git = new Git(db)) { | |||
git.commit().setMessage("initial commit").call(); | |||
} | |||
} | |||
@Test | |||
@@ -95,13 +97,15 @@ public class BranchTest extends CLIRepositoryTestCase { | |||
@Test | |||
public void testListContains() throws Exception { | |||
new Git(db).branchCreate().setName("initial").call(); | |||
RevCommit second = new Git(db).commit().setMessage("second commit") | |||
.call(); | |||
assertEquals(toString(" initial", "* master"), | |||
toString(execute("git branch --contains 6fd41be"))); | |||
assertEquals("* master", | |||
toString(execute("git branch --contains " + second.name()))); | |||
try (Git git = new Git(db)) { | |||
git.branchCreate().setName("initial").call(); | |||
RevCommit second = git.commit().setMessage("second commit") | |||
.call(); | |||
assertEquals(toString(" initial", "* master"), | |||
toString(execute("git branch --contains 6fd41be"))); | |||
assertEquals("* master", | |||
toString(execute("git branch --contains " + second.name()))); | |||
} | |||
} | |||
@Test |
@@ -73,27 +73,33 @@ public class CheckoutTest extends CLIRepositoryTestCase { | |||
@Test | |||
public void testCheckoutSelf() throws Exception { | |||
new Git(db).commit().setMessage("initial commit").call(); | |||
try (Git git = new Git(db)) { | |||
git.commit().setMessage("initial commit").call(); | |||
assertStringArrayEquals("Already on 'master'", | |||
execute("git checkout master")); | |||
assertStringArrayEquals("Already on 'master'", | |||
execute("git checkout master")); | |||
} | |||
} | |||
@Test | |||
public void testCheckoutBranch() throws Exception { | |||
new Git(db).commit().setMessage("initial commit").call(); | |||
new Git(db).branchCreate().setName("side").call(); | |||
try (Git git = new Git(db)) { | |||
git.commit().setMessage("initial commit").call(); | |||
git.branchCreate().setName("side").call(); | |||
assertStringArrayEquals("Switched to branch 'side'", | |||
execute("git checkout side")); | |||
assertStringArrayEquals("Switched to branch 'side'", | |||
execute("git checkout side")); | |||
} | |||
} | |||
@Test | |||
public void testCheckoutNewBranch() throws Exception { | |||
new Git(db).commit().setMessage("initial commit").call(); | |||
try (Git git = new Git(db)) { | |||
git.commit().setMessage("initial commit").call(); | |||
assertStringArrayEquals("Switched to a new branch 'side'", | |||
execute("git checkout -b side")); | |||
assertStringArrayEquals("Switched to a new branch 'side'", | |||
execute("git checkout -b side")); | |||
} | |||
} | |||
@Test | |||
@@ -105,11 +111,13 @@ public class CheckoutTest extends CLIRepositoryTestCase { | |||
@Test | |||
public void testCheckoutNewBranchThatAlreadyExists() throws Exception { | |||
new Git(db).commit().setMessage("initial commit").call(); | |||
try (Git git = new Git(db)) { | |||
git.commit().setMessage("initial commit").call(); | |||
assertStringArrayEquals( | |||
"fatal: A branch named 'master' already exists.", | |||
assertStringArrayEquals( | |||
"fatal: A branch named 'master' already exists.", | |||
executeUnchecked("git checkout -b master")); | |||
} | |||
} | |||
@Test | |||
@@ -127,32 +135,35 @@ public class CheckoutTest extends CLIRepositoryTestCase { | |||
@Test | |||
public void testCheckoutHead() throws Exception { | |||
new Git(db).commit().setMessage("initial commit").call(); | |||
try (Git git = new Git(db)) { | |||
git.commit().setMessage("initial commit").call(); | |||
assertStringArrayEquals("", execute("git checkout HEAD")); | |||
assertStringArrayEquals("", execute("git checkout HEAD")); | |||
} | |||
} | |||
@Test | |||
public void testCheckoutExistingBranchWithConflict() throws Exception { | |||
Git git = new Git(db); | |||
writeTrashFile("a", "Hello world a"); | |||
git.add().addFilepattern(".").call(); | |||
git.commit().setMessage("commit file a").call(); | |||
git.branchCreate().setName("branch_1").call(); | |||
git.rm().addFilepattern("a").call(); | |||
FileUtils.mkdirs(new File(db.getWorkTree(), "a")); | |||
writeTrashFile("a/b", "Hello world b"); | |||
git.add().addFilepattern("a/b").call(); | |||
git.commit().setMessage("commit folder a").call(); | |||
git.rm().addFilepattern("a").call(); | |||
writeTrashFile("a", "New Hello world a"); | |||
git.add().addFilepattern(".").call(); | |||
String[] execute = execute("git checkout branch_1"); | |||
assertEquals( | |||
"error: Your local changes to the following files would be overwritten by checkout:", | |||
execute[0]); | |||
assertEquals("\ta", execute[1]); | |||
try (Git git = new Git(db)) { | |||
writeTrashFile("a", "Hello world a"); | |||
git.add().addFilepattern(".").call(); | |||
git.commit().setMessage("commit file a").call(); | |||
git.branchCreate().setName("branch_1").call(); | |||
git.rm().addFilepattern("a").call(); | |||
FileUtils.mkdirs(new File(db.getWorkTree(), "a")); | |||
writeTrashFile("a/b", "Hello world b"); | |||
git.add().addFilepattern("a/b").call(); | |||
git.commit().setMessage("commit folder a").call(); | |||
git.rm().addFilepattern("a").call(); | |||
writeTrashFile("a", "New Hello world a"); | |||
git.add().addFilepattern(".").call(); | |||
String[] execute = execute("git checkout branch_1"); | |||
assertEquals( | |||
"error: Your local changes to the following files would be overwritten by checkout:", | |||
execute[0]); | |||
assertEquals("\ta", execute[1]); | |||
} | |||
} | |||
/** | |||
@@ -174,41 +185,43 @@ public class CheckoutTest extends CLIRepositoryTestCase { | |||
*/ | |||
@Test | |||
public void testCheckoutWithMissingWorkingTreeFile() throws Exception { | |||
Git git = new Git(db); | |||
File fileA = writeTrashFile("a", "Hello world a"); | |||
writeTrashFile("b", "Hello world b"); | |||
git.add().addFilepattern(".").call(); | |||
git.commit().setMessage("add files a & b").call(); | |||
Ref branch_1 = git.branchCreate().setName("branch_1").call(); | |||
writeTrashFile("a", "b"); | |||
git.add().addFilepattern("a").call(); | |||
git.commit().setMessage("modify file a").call(); | |||
FileEntry entry = new FileTreeIterator.FileEntry(new File( | |||
db.getWorkTree(), "a"), db.getFS()); | |||
assertEquals(FileMode.REGULAR_FILE, entry.getMode()); | |||
FileUtils.delete(fileA); | |||
git.checkout().setName(branch_1.getName()).call(); | |||
entry = new FileTreeIterator.FileEntry(new File(db.getWorkTree(), "a"), | |||
db.getFS()); | |||
assertEquals(FileMode.REGULAR_FILE, entry.getMode()); | |||
assertEquals("Hello world a", read(fileA)); | |||
try (Git git = new Git(db)) { | |||
File fileA = writeTrashFile("a", "Hello world a"); | |||
writeTrashFile("b", "Hello world b"); | |||
git.add().addFilepattern(".").call(); | |||
git.commit().setMessage("add files a & b").call(); | |||
Ref branch_1 = git.branchCreate().setName("branch_1").call(); | |||
writeTrashFile("a", "b"); | |||
git.add().addFilepattern("a").call(); | |||
git.commit().setMessage("modify file a").call(); | |||
FileEntry entry = new FileTreeIterator.FileEntry(new File( | |||
db.getWorkTree(), "a"), db.getFS()); | |||
assertEquals(FileMode.REGULAR_FILE, entry.getMode()); | |||
FileUtils.delete(fileA); | |||
git.checkout().setName(branch_1.getName()).call(); | |||
entry = new FileTreeIterator.FileEntry(new File(db.getWorkTree(), "a"), | |||
db.getFS()); | |||
assertEquals(FileMode.REGULAR_FILE, entry.getMode()); | |||
assertEquals("Hello world a", read(fileA)); | |||
} | |||
} | |||
@Test | |||
public void testCheckoutOrphan() throws Exception { | |||
Git git = new Git(db); | |||
git.commit().setMessage("initial commit").call(); | |||
assertStringArrayEquals("Switched to a new branch 'new_branch'", | |||
execute("git checkout --orphan new_branch")); | |||
assertEquals("refs/heads/new_branch", | |||
db.exactRef("HEAD").getTarget().getName()); | |||
RevCommit commit = git.commit().setMessage("orphan commit").call(); | |||
assertEquals(0, commit.getParentCount()); | |||
try (Git git = new Git(db)) { | |||
git.commit().setMessage("initial commit").call(); | |||
assertStringArrayEquals("Switched to a new branch 'new_branch'", | |||
execute("git checkout --orphan new_branch")); | |||
assertEquals("refs/heads/new_branch", | |||
db.exactRef("HEAD").getTarget().getName()); | |||
RevCommit commit = git.commit().setMessage("orphan commit").call(); | |||
assertEquals(0, commit.getParentCount()); | |||
} | |||
} | |||
/** | |||
@@ -231,33 +244,34 @@ public class CheckoutTest extends CLIRepositoryTestCase { | |||
@Test | |||
public void fileModeTestMissingThenFolderWithFileInWorkingTree() | |||
throws Exception { | |||
Git git = new Git(db); | |||
writeTrashFile("b", "Hello world b"); | |||
git.add().addFilepattern(".").call(); | |||
git.commit().setMessage("add file b").call(); | |||
Ref branch_1 = git.branchCreate().setName("branch_1").call(); | |||
File folderA = new File(db.getWorkTree(), "a"); | |||
FileUtils.mkdirs(folderA); | |||
writeTrashFile("a/c", "Hello world c"); | |||
git.add().addFilepattern(".").call(); | |||
git.commit().setMessage("add folder a").call(); | |||
FileEntry entry = new FileTreeIterator.FileEntry(new File( | |||
db.getWorkTree(), "a"), db.getFS()); | |||
assertEquals(FileMode.TREE, entry.getMode()); | |||
FileUtils.delete(folderA, FileUtils.RECURSIVE); | |||
writeTrashFile("a", "b"); | |||
entry = new FileTreeIterator.FileEntry(new File(db.getWorkTree(), "a"), | |||
db.getFS()); | |||
assertEquals(FileMode.REGULAR_FILE, entry.getMode()); | |||
git.checkout().setName(branch_1.getName()).call(); | |||
entry = new FileTreeIterator.FileEntry(new File(db.getWorkTree(), "a"), | |||
db.getFS()); | |||
assertEquals(FileMode.REGULAR_FILE, entry.getMode()); | |||
try (Git git = new Git(db)) { | |||
writeTrashFile("b", "Hello world b"); | |||
git.add().addFilepattern(".").call(); | |||
git.commit().setMessage("add file b").call(); | |||
Ref branch_1 = git.branchCreate().setName("branch_1").call(); | |||
File folderA = new File(db.getWorkTree(), "a"); | |||
FileUtils.mkdirs(folderA); | |||
writeTrashFile("a/c", "Hello world c"); | |||
git.add().addFilepattern(".").call(); | |||
git.commit().setMessage("add folder a").call(); | |||
FileEntry entry = new FileTreeIterator.FileEntry(new File( | |||
db.getWorkTree(), "a"), db.getFS()); | |||
assertEquals(FileMode.TREE, entry.getMode()); | |||
FileUtils.delete(folderA, FileUtils.RECURSIVE); | |||
writeTrashFile("a", "b"); | |||
entry = new FileTreeIterator.FileEntry(new File(db.getWorkTree(), "a"), | |||
db.getFS()); | |||
assertEquals(FileMode.REGULAR_FILE, entry.getMode()); | |||
git.checkout().setName(branch_1.getName()).call(); | |||
entry = new FileTreeIterator.FileEntry(new File(db.getWorkTree(), "a"), | |||
db.getFS()); | |||
assertEquals(FileMode.REGULAR_FILE, entry.getMode()); | |||
} | |||
} | |||
/** | |||
@@ -279,30 +293,31 @@ public class CheckoutTest extends CLIRepositoryTestCase { | |||
*/ | |||
@Test | |||
public void fileModeTestFolderWithMissingInWorkingTree() throws Exception { | |||
Git git = new Git(db); | |||
writeTrashFile("b", "Hello world b"); | |||
writeTrashFile("a", "b"); | |||
git.add().addFilepattern(".").call(); | |||
git.commit().setMessage("add file b & file a").call(); | |||
Ref branch_1 = git.branchCreate().setName("branch_1").call(); | |||
git.rm().addFilepattern("a").call(); | |||
File folderA = new File(db.getWorkTree(), "a"); | |||
FileUtils.mkdirs(folderA); | |||
writeTrashFile("a/c", "Hello world c"); | |||
git.add().addFilepattern(".").call(); | |||
git.commit().setMessage("add folder a").call(); | |||
FileEntry entry = new FileTreeIterator.FileEntry(new File( | |||
db.getWorkTree(), "a"), db.getFS()); | |||
assertEquals(FileMode.TREE, entry.getMode()); | |||
FileUtils.delete(folderA, FileUtils.RECURSIVE); | |||
git.checkout().setName(branch_1.getName()).call(); | |||
entry = new FileTreeIterator.FileEntry(new File(db.getWorkTree(), "a"), | |||
db.getFS()); | |||
assertEquals(FileMode.REGULAR_FILE, entry.getMode()); | |||
try (Git git = new Git(db)) { | |||
writeTrashFile("b", "Hello world b"); | |||
writeTrashFile("a", "b"); | |||
git.add().addFilepattern(".").call(); | |||
git.commit().setMessage("add file b & file a").call(); | |||
Ref branch_1 = git.branchCreate().setName("branch_1").call(); | |||
git.rm().addFilepattern("a").call(); | |||
File folderA = new File(db.getWorkTree(), "a"); | |||
FileUtils.mkdirs(folderA); | |||
writeTrashFile("a/c", "Hello world c"); | |||
git.add().addFilepattern(".").call(); | |||
git.commit().setMessage("add folder a").call(); | |||
FileEntry entry = new FileTreeIterator.FileEntry(new File( | |||
db.getWorkTree(), "a"), db.getFS()); | |||
assertEquals(FileMode.TREE, entry.getMode()); | |||
FileUtils.delete(folderA, FileUtils.RECURSIVE); | |||
git.checkout().setName(branch_1.getName()).call(); | |||
entry = new FileTreeIterator.FileEntry(new File(db.getWorkTree(), "a"), | |||
db.getFS()); | |||
assertEquals(FileMode.REGULAR_FILE, entry.getMode()); | |||
} | |||
} | |||
/** | |||
@@ -324,32 +339,33 @@ public class CheckoutTest extends CLIRepositoryTestCase { | |||
*/ | |||
@Test | |||
public void fileModeTestMissingWithFolderInWorkingTree() throws Exception { | |||
Git git = new Git(db); | |||
writeTrashFile("b", "Hello world b"); | |||
writeTrashFile("a", "b"); | |||
git.add().addFilepattern(".").call(); | |||
git.commit().setMessage("add file b & file a").call(); | |||
Ref branch_1 = git.branchCreate().setName("branch_1").call(); | |||
git.rm().addFilepattern("a").call(); | |||
git.commit().setMessage("delete file a").call(); | |||
FileUtils.mkdirs(new File(db.getWorkTree(), "a")); | |||
writeTrashFile("a/c", "Hello world c"); | |||
FileEntry entry = new FileTreeIterator.FileEntry(new File( | |||
db.getWorkTree(), "a"), db.getFS()); | |||
assertEquals(FileMode.TREE, entry.getMode()); | |||
CheckoutConflictException exception = null; | |||
try { | |||
git.checkout().setName(branch_1.getName()).call(); | |||
} catch (CheckoutConflictException e) { | |||
exception = e; | |||
try (Git git = new Git(db)) { | |||
writeTrashFile("b", "Hello world b"); | |||
writeTrashFile("a", "b"); | |||
git.add().addFilepattern(".").call(); | |||
git.commit().setMessage("add file b & file a").call(); | |||
Ref branch_1 = git.branchCreate().setName("branch_1").call(); | |||
git.rm().addFilepattern("a").call(); | |||
git.commit().setMessage("delete file a").call(); | |||
FileUtils.mkdirs(new File(db.getWorkTree(), "a")); | |||
writeTrashFile("a/c", "Hello world c"); | |||
FileEntry entry = new FileTreeIterator.FileEntry(new File( | |||
db.getWorkTree(), "a"), db.getFS()); | |||
assertEquals(FileMode.TREE, entry.getMode()); | |||
CheckoutConflictException exception = null; | |||
try { | |||
git.checkout().setName(branch_1.getName()).call(); | |||
} catch (CheckoutConflictException e) { | |||
exception = e; | |||
} | |||
assertNotNull(exception); | |||
assertEquals(2, exception.getConflictingPaths().size()); | |||
assertEquals("a", exception.getConflictingPaths().get(0)); | |||
assertEquals("a/c", exception.getConflictingPaths().get(1)); | |||
} | |||
assertNotNull(exception); | |||
assertEquals(2, exception.getConflictingPaths().size()); | |||
assertEquals("a", exception.getConflictingPaths().get(0)); | |||
assertEquals("a/c", exception.getConflictingPaths().get(1)); | |||
} | |||
/** | |||
@@ -371,40 +387,41 @@ public class CheckoutTest extends CLIRepositoryTestCase { | |||
@Test | |||
public void fileModeTestFolderThenMissingWithFileInWorkingTree() | |||
throws Exception { | |||
Git git = new Git(db); | |||
FileUtils.mkdirs(new File(db.getWorkTree(), "a")); | |||
writeTrashFile("a/c", "Hello world c"); | |||
writeTrashFile("b", "Hello world b"); | |||
git.add().addFilepattern(".").call(); | |||
RevCommit commit1 = git.commit().setMessage("add folder a & file b") | |||
.call(); | |||
Ref branch_1 = git.branchCreate().setName("branch_1").call(); | |||
git.rm().addFilepattern("a").call(); | |||
RevCommit commit2 = git.commit().setMessage("delete folder a").call(); | |||
TreeWalk tw = new TreeWalk(db); | |||
tw.addTree(commit1.getTree()); | |||
tw.addTree(commit2.getTree()); | |||
List<DiffEntry> scan = DiffEntry.scan(tw); | |||
assertEquals(1, scan.size()); | |||
assertEquals(FileMode.MISSING, scan.get(0).getNewMode()); | |||
assertEquals(FileMode.TREE, scan.get(0).getOldMode()); | |||
writeTrashFile("a", "b"); | |||
FileEntry entry = new FileTreeIterator.FileEntry(new File( | |||
db.getWorkTree(), "a"), db.getFS()); | |||
assertEquals(FileMode.REGULAR_FILE, entry.getMode()); | |||
CheckoutConflictException exception = null; | |||
try { | |||
git.checkout().setName(branch_1.getName()).call(); | |||
} catch (CheckoutConflictException e) { | |||
exception = e; | |||
try (Git git = new Git(db)) { | |||
FileUtils.mkdirs(new File(db.getWorkTree(), "a")); | |||
writeTrashFile("a/c", "Hello world c"); | |||
writeTrashFile("b", "Hello world b"); | |||
git.add().addFilepattern(".").call(); | |||
RevCommit commit1 = git.commit().setMessage("add folder a & file b") | |||
.call(); | |||
Ref branch_1 = git.branchCreate().setName("branch_1").call(); | |||
git.rm().addFilepattern("a").call(); | |||
RevCommit commit2 = git.commit().setMessage("delete folder a").call(); | |||
TreeWalk tw = new TreeWalk(db); | |||
tw.addTree(commit1.getTree()); | |||
tw.addTree(commit2.getTree()); | |||
List<DiffEntry> scan = DiffEntry.scan(tw); | |||
assertEquals(1, scan.size()); | |||
assertEquals(FileMode.MISSING, scan.get(0).getNewMode()); | |||
assertEquals(FileMode.TREE, scan.get(0).getOldMode()); | |||
writeTrashFile("a", "b"); | |||
FileEntry entry = new FileTreeIterator.FileEntry(new File( | |||
db.getWorkTree(), "a"), db.getFS()); | |||
assertEquals(FileMode.REGULAR_FILE, entry.getMode()); | |||
CheckoutConflictException exception = null; | |||
try { | |||
git.checkout().setName(branch_1.getName()).call(); | |||
} catch (CheckoutConflictException e) { | |||
exception = e; | |||
} | |||
assertNotNull(exception); | |||
assertEquals(1, exception.getConflictingPaths().size()); | |||
assertEquals("a", exception.getConflictingPaths().get(0)); | |||
} | |||
assertNotNull(exception); | |||
assertEquals(1, exception.getConflictingPaths().size()); | |||
assertEquals("a", exception.getConflictingPaths().get(0)); | |||
} | |||
/** | |||
@@ -427,30 +444,31 @@ public class CheckoutTest extends CLIRepositoryTestCase { | |||
@Test | |||
public void fileModeTestFolderThenFileWithMissingInWorkingTree() | |||
throws Exception { | |||
Git git = new Git(db); | |||
FileUtils.mkdirs(new File(db.getWorkTree(), "a")); | |||
writeTrashFile("a/c", "Hello world c"); | |||
writeTrashFile("b", "Hello world b"); | |||
git.add().addFilepattern(".").call(); | |||
git.commit().setMessage("add folder a & file b").call(); | |||
Ref branch_1 = git.branchCreate().setName("branch_1").call(); | |||
git.rm().addFilepattern("a").call(); | |||
File fileA = new File(db.getWorkTree(), "a"); | |||
writeTrashFile("a", "b"); | |||
git.add().addFilepattern("a").call(); | |||
git.commit().setMessage("add file a").call(); | |||
FileEntry entry = new FileTreeIterator.FileEntry(new File( | |||
db.getWorkTree(), "a"), db.getFS()); | |||
assertEquals(FileMode.REGULAR_FILE, entry.getMode()); | |||
FileUtils.delete(fileA); | |||
git.checkout().setName(branch_1.getName()).call(); | |||
entry = new FileTreeIterator.FileEntry(new File(db.getWorkTree(), "a"), | |||
db.getFS()); | |||
assertEquals(FileMode.TREE, entry.getMode()); | |||
try (Git git = new Git(db)) { | |||
FileUtils.mkdirs(new File(db.getWorkTree(), "a")); | |||
writeTrashFile("a/c", "Hello world c"); | |||
writeTrashFile("b", "Hello world b"); | |||
git.add().addFilepattern(".").call(); | |||
git.commit().setMessage("add folder a & file b").call(); | |||
Ref branch_1 = git.branchCreate().setName("branch_1").call(); | |||
git.rm().addFilepattern("a").call(); | |||
File fileA = new File(db.getWorkTree(), "a"); | |||
writeTrashFile("a", "b"); | |||
git.add().addFilepattern("a").call(); | |||
git.commit().setMessage("add file a").call(); | |||
FileEntry entry = new FileTreeIterator.FileEntry(new File( | |||
db.getWorkTree(), "a"), db.getFS()); | |||
assertEquals(FileMode.REGULAR_FILE, entry.getMode()); | |||
FileUtils.delete(fileA); | |||
git.checkout().setName(branch_1.getName()).call(); | |||
entry = new FileTreeIterator.FileEntry(new File(db.getWorkTree(), "a"), | |||
db.getFS()); | |||
assertEquals(FileMode.TREE, entry.getMode()); | |||
} | |||
} | |||
/** | |||
@@ -471,38 +489,39 @@ public class CheckoutTest extends CLIRepositoryTestCase { | |||
*/ | |||
@Test | |||
public void fileModeTestFileThenFileWithFolderInIndex() throws Exception { | |||
Git git = new Git(db); | |||
writeTrashFile("a", "Hello world a"); | |||
writeTrashFile("b", "Hello world b"); | |||
git.add().addFilepattern(".").call(); | |||
git.commit().setMessage("add files a & b").call(); | |||
Ref branch_1 = git.branchCreate().setName("branch_1").call(); | |||
writeTrashFile("a", "b"); | |||
git.add().addFilepattern("a").call(); | |||
git.commit().setMessage("add file a").call(); | |||
FileEntry entry = new FileTreeIterator.FileEntry(new File( | |||
db.getWorkTree(), "a"), db.getFS()); | |||
assertEquals(FileMode.REGULAR_FILE, entry.getMode()); | |||
git.rm().addFilepattern("a").call(); | |||
FileUtils.mkdirs(new File(db.getWorkTree(), "a")); | |||
writeTrashFile("a/c", "Hello world c"); | |||
git.add().addFilepattern(".").call(); | |||
entry = new FileTreeIterator.FileEntry(new File(db.getWorkTree(), "a"), | |||
db.getFS()); | |||
assertEquals(FileMode.TREE, entry.getMode()); | |||
CheckoutConflictException exception = null; | |||
try { | |||
git.checkout().setName(branch_1.getName()).call(); | |||
} catch (CheckoutConflictException e) { | |||
exception = e; | |||
try (Git git = new Git(db)) { | |||
writeTrashFile("a", "Hello world a"); | |||
writeTrashFile("b", "Hello world b"); | |||
git.add().addFilepattern(".").call(); | |||
git.commit().setMessage("add files a & b").call(); | |||
Ref branch_1 = git.branchCreate().setName("branch_1").call(); | |||
writeTrashFile("a", "b"); | |||
git.add().addFilepattern("a").call(); | |||
git.commit().setMessage("add file a").call(); | |||
FileEntry entry = new FileTreeIterator.FileEntry(new File( | |||
db.getWorkTree(), "a"), db.getFS()); | |||
assertEquals(FileMode.REGULAR_FILE, entry.getMode()); | |||
git.rm().addFilepattern("a").call(); | |||
FileUtils.mkdirs(new File(db.getWorkTree(), "a")); | |||
writeTrashFile("a/c", "Hello world c"); | |||
git.add().addFilepattern(".").call(); | |||
entry = new FileTreeIterator.FileEntry(new File(db.getWorkTree(), "a"), | |||
db.getFS()); | |||
assertEquals(FileMode.TREE, entry.getMode()); | |||
CheckoutConflictException exception = null; | |||
try { | |||
git.checkout().setName(branch_1.getName()).call(); | |||
} catch (CheckoutConflictException e) { | |||
exception = e; | |||
} | |||
assertNotNull(exception); | |||
assertEquals(1, exception.getConflictingPaths().size()); | |||
assertEquals("a", exception.getConflictingPaths().get(0)); | |||
} | |||
assertNotNull(exception); | |||
assertEquals(1, exception.getConflictingPaths().size()); | |||
assertEquals("a", exception.getConflictingPaths().get(0)); | |||
} | |||
/** | |||
@@ -524,66 +543,68 @@ public class CheckoutTest extends CLIRepositoryTestCase { | |||
*/ | |||
@Test | |||
public void fileModeTestFileWithFolderInIndex() throws Exception { | |||
Git git = new Git(db); | |||
writeTrashFile("b", "Hello world b"); | |||
writeTrashFile("a", "b"); | |||
git.add().addFilepattern(".").call(); | |||
git.commit().setMessage("add file b & file a").call(); | |||
Ref branch_1 = git.branchCreate().setName("branch_1").call(); | |||
git.rm().addFilepattern("a").call(); | |||
writeTrashFile("a", "Hello world a"); | |||
git.add().addFilepattern("a").call(); | |||
git.commit().setMessage("add file a").call(); | |||
FileEntry entry = new FileTreeIterator.FileEntry(new File( | |||
db.getWorkTree(), "a"), db.getFS()); | |||
assertEquals(FileMode.REGULAR_FILE, entry.getMode()); | |||
git.rm().addFilepattern("a").call(); | |||
FileUtils.mkdirs(new File(db.getWorkTree(), "a")); | |||
writeTrashFile("a/c", "Hello world c"); | |||
git.add().addFilepattern(".").call(); | |||
entry = new FileTreeIterator.FileEntry(new File(db.getWorkTree(), "a"), | |||
db.getFS()); | |||
assertEquals(FileMode.TREE, entry.getMode()); | |||
CheckoutConflictException exception = null; | |||
try { | |||
git.checkout().setName(branch_1.getName()).call(); | |||
} catch (CheckoutConflictException e) { | |||
exception = e; | |||
try (Git git = new Git(db)) { | |||
writeTrashFile("b", "Hello world b"); | |||
writeTrashFile("a", "b"); | |||
git.add().addFilepattern(".").call(); | |||
git.commit().setMessage("add file b & file a").call(); | |||
Ref branch_1 = git.branchCreate().setName("branch_1").call(); | |||
git.rm().addFilepattern("a").call(); | |||
writeTrashFile("a", "Hello world a"); | |||
git.add().addFilepattern("a").call(); | |||
git.commit().setMessage("add file a").call(); | |||
FileEntry entry = new FileTreeIterator.FileEntry(new File( | |||
db.getWorkTree(), "a"), db.getFS()); | |||
assertEquals(FileMode.REGULAR_FILE, entry.getMode()); | |||
git.rm().addFilepattern("a").call(); | |||
FileUtils.mkdirs(new File(db.getWorkTree(), "a")); | |||
writeTrashFile("a/c", "Hello world c"); | |||
git.add().addFilepattern(".").call(); | |||
entry = new FileTreeIterator.FileEntry(new File(db.getWorkTree(), "a"), | |||
db.getFS()); | |||
assertEquals(FileMode.TREE, entry.getMode()); | |||
CheckoutConflictException exception = null; | |||
try { | |||
git.checkout().setName(branch_1.getName()).call(); | |||
} catch (CheckoutConflictException e) { | |||
exception = e; | |||
} | |||
assertNotNull(exception); | |||
assertEquals(1, exception.getConflictingPaths().size()); | |||
assertEquals("a", exception.getConflictingPaths().get(0)); | |||
// TODO: ideally we'd like to get two paths from this exception | |||
// assertEquals(2, exception.getConflictingPaths().size()); | |||
// assertEquals("a", exception.getConflictingPaths().get(0)); | |||
// assertEquals("a/c", exception.getConflictingPaths().get(1)); | |||
} | |||
assertNotNull(exception); | |||
assertEquals(1, exception.getConflictingPaths().size()); | |||
assertEquals("a", exception.getConflictingPaths().get(0)); | |||
// TODO: ideally we'd like to get two paths from this exception | |||
// assertEquals(2, exception.getConflictingPaths().size()); | |||
// assertEquals("a", exception.getConflictingPaths().get(0)); | |||
// assertEquals("a/c", exception.getConflictingPaths().get(1)); | |||
} | |||
@Test | |||
public void testCheckoutPath() throws Exception { | |||
Git git = new Git(db); | |||
writeTrashFile("a", "Hello world a"); | |||
git.add().addFilepattern(".").call(); | |||
git.commit().setMessage("commit file a").call(); | |||
git.branchCreate().setName("branch_1").call(); | |||
git.checkout().setName("branch_1").call(); | |||
File b = writeTrashFile("b", "Hello world b"); | |||
git.add().addFilepattern("b").call(); | |||
git.commit().setMessage("commit file b").call(); | |||
File a = writeTrashFile("a", "New Hello world a"); | |||
git.add().addFilepattern(".").call(); | |||
git.commit().setMessage("modified a").call(); | |||
assertArrayEquals(new String[] { "" }, | |||
execute("git checkout HEAD~2 -- a")); | |||
assertEquals("Hello world a", read(a)); | |||
assertArrayEquals(new String[] { "* branch_1", " master", "" }, | |||
execute("git branch")); | |||
assertEquals("Hello world b", read(b)); | |||
try (Git git = new Git(db)) { | |||
writeTrashFile("a", "Hello world a"); | |||
git.add().addFilepattern(".").call(); | |||
git.commit().setMessage("commit file a").call(); | |||
git.branchCreate().setName("branch_1").call(); | |||
git.checkout().setName("branch_1").call(); | |||
File b = writeTrashFile("b", "Hello world b"); | |||
git.add().addFilepattern("b").call(); | |||
git.commit().setMessage("commit file b").call(); | |||
File a = writeTrashFile("a", "New Hello world a"); | |||
git.add().addFilepattern(".").call(); | |||
git.commit().setMessage("modified a").call(); | |||
assertArrayEquals(new String[] { "" }, | |||
execute("git checkout HEAD~2 -- a")); | |||
assertEquals("Hello world a", read(a)); | |||
assertArrayEquals(new String[] { "* branch_1", " master", "" }, | |||
execute("git branch")); | |||
assertEquals("Hello world b", read(b)); | |||
} | |||
} | |||
@Test |
@@ -129,20 +129,20 @@ abstract class AbstractFetchCommand extends TextBuiltin { | |||
final TrackingRefUpdate u) { | |||
final RefUpdate.Result r = u.getResult(); | |||
if (r == RefUpdate.Result.LOCK_FAILURE) | |||
return "[lock fail]"; | |||
return "[lock fail]"; //$NON-NLS-1$ | |||
if (r == RefUpdate.Result.IO_FAILURE) | |||
return "[i/o error]"; | |||
return "[i/o error]"; //$NON-NLS-1$ | |||
if (r == RefUpdate.Result.REJECTED) | |||
return "[rejected]"; | |||
return "[rejected]"; //$NON-NLS-1$ | |||
if (ObjectId.zeroId().equals(u.getNewObjectId())) | |||
return "[deleted]"; | |||
return "[deleted]"; //$NON-NLS-1$ | |||
if (r == RefUpdate.Result.NEW) { | |||
if (u.getRemoteName().startsWith(Constants.R_HEADS)) | |||
return "[new branch]"; | |||
return "[new branch]"; //$NON-NLS-1$ | |||
else if (u.getLocalName().startsWith(Constants.R_TAGS)) | |||
return "[new tag]"; | |||
return "[new]"; | |||
return "[new tag]"; //$NON-NLS-1$ | |||
return "[new]"; //$NON-NLS-1$ | |||
} | |||
if (r == RefUpdate.Result.FORCED) { | |||
@@ -158,7 +158,7 @@ abstract class AbstractFetchCommand extends TextBuiltin { | |||
} | |||
if (r == RefUpdate.Result.NO_CHANGE) | |||
return "[up to date]"; | |||
return "[up to date]"; //$NON-NLS-1$ | |||
return "[" + r.name() + "]"; //$NON-NLS-1$//$NON-NLS-2$ | |||
} | |||
@@ -74,7 +74,7 @@ class Config extends TextBuiltin { | |||
list(); | |||
else | |||
throw new NotSupportedException( | |||
"only --list option is currently supported"); | |||
"only --list option is currently supported"); //$NON-NLS-1$ | |||
} | |||
private void list() throws IOException, ConfigInvalidException { |
@@ -324,7 +324,7 @@ class Log extends RevWalkTextBuiltin { | |||
return false; | |||
if (emptyLine) | |||
outw.println(); | |||
outw.print("Notes"); | |||
outw.print("Notes"); //$NON-NLS-1$ | |||
if (label != null) { | |||
outw.print(" ("); //$NON-NLS-1$ | |||
outw.print(label); |
@@ -182,15 +182,15 @@ class Push extends TextBuiltin { | |||
switch (rru.getStatus()) { | |||
case OK: | |||
if (rru.isDelete()) | |||
printUpdateLine('-', "[deleted]", null, remoteName, null); | |||
printUpdateLine('-', "[deleted]", null, remoteName, null); //$NON-NLS-1$ | |||
else { | |||
final Ref oldRef = result.getAdvertisedRef(remoteName); | |||
if (oldRef == null) { | |||
final String summary; | |||
if (remoteName.startsWith(Constants.R_TAGS)) | |||
summary = "[new tag]"; | |||
summary = "[new tag]"; //$NON-NLS-1$ | |||
else | |||
summary = "[new branch]"; | |||
summary = "[new branch]"; //$NON-NLS-1$ | |||
printUpdateLine('*', summary, srcRef, remoteName, null); | |||
} else { | |||
boolean fastForward = rru.isFastForward(); | |||
@@ -206,16 +206,16 @@ class Push extends TextBuiltin { | |||
break; | |||
case NON_EXISTING: | |||
printUpdateLine('X', "[no match]", null, remoteName, null); | |||
printUpdateLine('X', "[no match]", null, remoteName, null); //$NON-NLS-1$ | |||
break; | |||
case REJECTED_NODELETE: | |||
printUpdateLine('!', "[rejected]", null, remoteName, | |||
printUpdateLine('!', "[rejected]", null, remoteName, //$NON-NLS-1$ | |||
CLIText.get().remoteSideDoesNotSupportDeletingRefs); | |||
break; | |||
case REJECTED_NONFASTFORWARD: | |||
printUpdateLine('!', "[rejected]", srcRef, remoteName, | |||
printUpdateLine('!', "[rejected]", srcRef, remoteName, //$NON-NLS-1$ | |||
CLIText.get().nonFastForward); | |||
break; | |||
@@ -223,22 +223,22 @@ class Push extends TextBuiltin { | |||
final String message = MessageFormat.format( | |||
CLIText.get().remoteRefObjectChangedIsNotExpectedOne, | |||
safeAbbreviate(reader, rru.getExpectedOldObjectId())); | |||
printUpdateLine('!', "[rejected]", srcRef, remoteName, message); | |||
printUpdateLine('!', "[rejected]", srcRef, remoteName, message); //$NON-NLS-1$ | |||
break; | |||
case REJECTED_OTHER_REASON: | |||
printUpdateLine('!', "[remote rejected]", srcRef, remoteName, rru | |||
printUpdateLine('!', "[remote rejected]", srcRef, remoteName, rru //$NON-NLS-1$ | |||
.getMessage()); | |||
break; | |||
case UP_TO_DATE: | |||
if (verbose) | |||
printUpdateLine('=', "[up to date]", srcRef, remoteName, null); | |||
printUpdateLine('=', "[up to date]", srcRef, remoteName, null); //$NON-NLS-1$ | |||
break; | |||
case NOT_ATTEMPTED: | |||
case AWAITING_REPORT: | |||
printUpdateLine('?', "[unexpected push-process behavior]", srcRef, | |||
printUpdateLine('?', "[unexpected push-process behavior]", srcRef, //$NON-NLS-1$ | |||
remoteName, rru.getMessage()); | |||
break; | |||
} |
@@ -89,7 +89,7 @@ class Reset extends TextBuiltin { | |||
if (hard) | |||
mode = selectMode(mode, ResetType.HARD); | |||
if (mode == null) | |||
throw die("no reset mode set"); | |||
throw die("no reset mode set"); //$NON-NLS-1$ | |||
command.setMode(mode); | |||
} | |||
command.call(); | |||
@@ -98,7 +98,7 @@ class Reset extends TextBuiltin { | |||
private static ResetType selectMode(ResetType mode, ResetType want) { | |||
if (mode != null) | |||
throw die("reset modes are mutually exclusive, select one"); | |||
throw die("reset modes are mutually exclusive, select one"); //$NON-NLS-1$ | |||
return want; | |||
} | |||
} |
@@ -56,7 +56,8 @@ import org.kohsuke.args4j.CmdLineException; | |||
import org.kohsuke.args4j.Option; | |||
import org.eclipse.jgit.lib.ObjectId; | |||
import org.eclipse.jgit.lib.Ref; | |||
import org.eclipse.jgit.pgm.internal.CLIText;; | |||
import org.eclipse.jgit.pgm.internal.CLIText; | |||
import org.eclipse.jgit.pgm.opt.CmdLineParser; | |||
@Command(usage = "usage_RevParse") | |||
class RevParse extends TextBuiltin { | |||
@@ -84,7 +85,8 @@ class RevParse extends TextBuiltin { | |||
} | |||
} else { | |||
if (verify && commits.size() > 1) { | |||
throw new CmdLineException(CLIText.get().needSingleRevision); | |||
final CmdLineParser clp = new CmdLineParser(this); | |||
throw new CmdLineException(clp, CLIText.get().needSingleRevision); | |||
} | |||
for (final ObjectId o : commits) { |
@@ -136,7 +136,7 @@ class DiffAlgorithms extends TextBuiltin { | |||
protected void run() throws Exception { | |||
mxBean = ManagementFactory.getThreadMXBean(); | |||
if (!mxBean.isCurrentThreadCpuTimeSupported()) | |||
throw die("Current thread CPU time not supported on this JRE"); | |||
throw die("Current thread CPU time not supported on this JRE"); //$NON-NLS-1$ | |||
if (gitDirs.isEmpty()) { | |||
RepositoryBuilder rb = new RepositoryBuilder() // | |||
@@ -248,18 +248,18 @@ class DiffAlgorithms extends TextBuiltin { | |||
File parent = directory.getParentFile(); | |||
if (name.equals(Constants.DOT_GIT) && parent != null) | |||
name = parent.getName(); | |||
outw.println(name + ": start at " + startId.name()); | |||
outw.println(name + ": start at " + startId.name()); //$NON-NLS-1$ | |||
} | |||
outw.format(" %12d files, %8d commits\n", valueOf(files), | |||
outw.format(" %12d files, %8d commits\n", valueOf(files), //$NON-NLS-1$ | |||
valueOf(commits)); | |||
outw.format(" N=%10d min lines, %8d max lines\n", valueOf(minN), | |||
outw.format(" N=%10d min lines, %8d max lines\n", valueOf(minN), //$NON-NLS-1$ | |||
valueOf(maxN)); | |||
outw.format("%-25s %12s ( %12s %12s )\n", // | |||
"Algorithm", "Time(ns)", "Time(ns) on", "Time(ns) on"); | |||
outw.format("%-25s %12s ( %12s %12s )\n", // | |||
"", "", "N=" + minN, "N=" + maxN); | |||
outw.format("%-25s %12s ( %12s %12s )\n", //$NON-NLS-1$ | |||
"Algorithm", "Time(ns)", "Time(ns) on", "Time(ns) on"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ | |||
outw.format("%-25s %12s ( %12s %12s )\n", //$NON-NLS-1$ | |||
"", "", "N=" + minN, "N=" + maxN); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ | |||
outw.println("-----------------------------------------------------" //$NON-NLS-1$ | |||
+ "----------------"); //$NON-NLS-1$ | |||
@@ -335,9 +335,9 @@ class DiffAlgorithms extends TextBuiltin { | |||
} | |||
} | |||
} catch (IllegalArgumentException e) { | |||
throw die("Cannot determine names", e); | |||
throw die("Cannot determine names", e); //$NON-NLS-1$ | |||
} catch (IllegalAccessException e) { | |||
throw die("Cannot determine names", e); | |||
throw die("Cannot determine names", e); //$NON-NLS-1$ | |||
} | |||
return all; |
@@ -167,7 +167,7 @@ class RebuildCommitGraph extends TextBuiltin { | |||
} | |||
} | |||
pm.beginTask("Rewriting commits", queue.size()); | |||
pm.beginTask("Rewriting commits", queue.size()); //$NON-NLS-1$ | |||
try (ObjectInserter oi = db.newObjectInserter()) { | |||
final ObjectId emptyTree = oi.insert(Constants.OBJ_TREE, | |||
new byte[] {}); | |||
@@ -203,7 +203,7 @@ class RebuildCommitGraph extends TextBuiltin { | |||
newc.setAuthor(new PersonIdent(me, new Date(t.commitTime))); | |||
newc.setCommitter(newc.getAuthor()); | |||
newc.setParentIds(newParents); | |||
newc.setMessage("ORIGINAL " + t.oldId.name() + "\n"); //$NON-NLS-2$ | |||
newc.setMessage("ORIGINAL " + t.oldId.name() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$ | |||
t.newId = oi.insert(newc); | |||
rewrites.put(t.oldId, t.newId); | |||
pm.update(1); |
@@ -87,9 +87,9 @@ class ShowPackDelta extends TextBuiltin { | |||
long size = reader.getObjectSize(obj, obj.getType()); | |||
try { | |||
if (BinaryDelta.getResultSize(delta) != size) | |||
throw die("Object " + obj.name() + " is not a delta"); | |||
throw die("Object " + obj.name() + " is not a delta"); //$NON-NLS-1$ //$NON-NLS-2$ | |||
} catch (ArrayIndexOutOfBoundsException bad) { | |||
throw die("Object " + obj.name() + " is not a delta"); | |||
throw die("Object " + obj.name() + " is not a delta"); //$NON-NLS-1$ //$NON-NLS-2$ | |||
} | |||
outw.println(BinaryDelta.format(delta)); |
@@ -349,10 +349,10 @@ class TextHashFunctions extends TextBuiltin { | |||
name = parent.getName(); | |||
outw.println(name + ":"); //$NON-NLS-1$ | |||
} | |||
outw.format(" %6d files; %5d avg. unique lines/file\n", // | |||
outw.format(" %6d files; %5d avg. unique lines/file\n", //$NON-NLS-1$ | |||
valueOf(fileCnt), // | |||
valueOf(lineCnt / fileCnt)); | |||
outw.format("%-20s %-15s %9s\n", "Hash", "Fold", "Max Len"); | |||
outw.format("%-20s %-15s %9s\n", "Hash", "Fold", "Max Len"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ | |||
outw.println("-----------------------------------------------"); //$NON-NLS-1$ | |||
String lastHashName = null; | |||
for (Function fun : all) { | |||
@@ -405,9 +405,9 @@ class TextHashFunctions extends TextBuiltin { | |||
} | |||
} | |||
} catch (IllegalArgumentException e) { | |||
throw new RuntimeException("Cannot determine names", e); | |||
throw new RuntimeException("Cannot determine names", e); //$NON-NLS-1$ | |||
} catch (IllegalAccessException e) { | |||
throw new RuntimeException("Cannot determine names", e); | |||
throw new RuntimeException("Cannot determine names", e); //$NON-NLS-1$ | |||
} | |||
List<Function> all = new ArrayList<Function>(); |
@@ -109,7 +109,7 @@ public class AbstractTreeIteratorHandler extends | |||
try { | |||
dirc = DirCache.read(new File(name), FS.DETECTED); | |||
} catch (IOException e) { | |||
throw new CmdLineException(MessageFormat.format(CLIText.get().notAnIndexFile, name), e); | |||
throw new CmdLineException(clp, MessageFormat.format(CLIText.get().notAnIndexFile, name), e); | |||
} | |||
setter.addValue(new DirCacheIterator(dirc)); | |||
return 1; | |||
@@ -119,20 +119,20 @@ public class AbstractTreeIteratorHandler extends | |||
try { | |||
id = clp.getRepository().resolve(name); | |||
} catch (IOException e) { | |||
throw new CmdLineException(e.getMessage()); | |||
throw new CmdLineException(clp, e.getMessage()); | |||
} | |||
if (id == null) | |||
throw new CmdLineException(MessageFormat.format(CLIText.get().notATree, name)); | |||
throw new CmdLineException(clp, MessageFormat.format(CLIText.get().notATree, name)); | |||
final CanonicalTreeParser p = new CanonicalTreeParser(); | |||
try (ObjectReader curs = clp.getRepository().newObjectReader()) { | |||
p.reset(curs, clp.getRevWalk().parseTree(id)); | |||
} catch (MissingObjectException e) { | |||
throw new CmdLineException(MessageFormat.format(CLIText.get().notATree, name)); | |||
throw new CmdLineException(clp, MessageFormat.format(CLIText.get().notATree, name)); | |||
} catch (IncorrectObjectTypeException e) { | |||
throw new CmdLineException(MessageFormat.format(CLIText.get().notATree, name)); | |||
throw new CmdLineException(clp, MessageFormat.format(CLIText.get().notATree, name)); | |||
} catch (IOException e) { | |||
throw new CmdLineException(MessageFormat.format(CLIText.get().cannotReadBecause, name, e.getMessage())); | |||
throw new CmdLineException(clp, MessageFormat.format(CLIText.get().cannotReadBecause, name, e.getMessage())); | |||
} | |||
setter.addValue(p); |
@@ -86,14 +86,14 @@ public class ObjectIdHandler extends OptionHandler<ObjectId> { | |||
try { | |||
id = clp.getRepository().resolve(name); | |||
} catch (IOException e) { | |||
throw new CmdLineException(e.getMessage()); | |||
throw new CmdLineException(clp, e.getMessage()); | |||
} | |||
if (id != null) { | |||
setter.addValue(id); | |||
return 1; | |||
} | |||
throw new CmdLineException(MessageFormat.format(CLIText.get().notAnObject, name)); | |||
throw new CmdLineException(clp, MessageFormat.format(CLIText.get().notAnObject, name)); | |||
} | |||
@Override |
@@ -96,8 +96,10 @@ public class RevCommitHandler extends OptionHandler<RevCommit> { | |||
final int dot2 = name.indexOf(".."); //$NON-NLS-1$ | |||
if (dot2 != -1) { | |||
if (!option.isMultiValued()) | |||
throw new CmdLineException(MessageFormat.format(CLIText.get().onlyOneMetaVarExpectedIn | |||
, option.metaVar(), name)); | |||
throw new CmdLineException(clp, | |||
MessageFormat.format( | |||
CLIText.get().onlyOneMetaVarExpectedIn, | |||
option.metaVar(), name)); | |||
final String left = name.substring(0, dot2); | |||
final String right = name.substring(dot2 + 2); | |||
@@ -116,20 +118,20 @@ public class RevCommitHandler extends OptionHandler<RevCommit> { | |||
try { | |||
id = clp.getRepository().resolve(name); | |||
} catch (IOException e) { | |||
throw new CmdLineException(e.getMessage()); | |||
throw new CmdLineException(clp, e.getMessage()); | |||
} | |||
if (id == null) | |||
throw new CmdLineException(MessageFormat.format(CLIText.get().notACommit, name)); | |||
throw new CmdLineException(clp, MessageFormat.format(CLIText.get().notACommit, name)); | |||
final RevCommit c; | |||
try { | |||
c = clp.getRevWalk().parseCommit(id); | |||
} catch (MissingObjectException e) { | |||
throw new CmdLineException(MessageFormat.format(CLIText.get().notACommit, name)); | |||
throw new CmdLineException(clp, MessageFormat.format(CLIText.get().notACommit, name)); | |||
} catch (IncorrectObjectTypeException e) { | |||
throw new CmdLineException(MessageFormat.format(CLIText.get().notACommit, name)); | |||
throw new CmdLineException(clp, MessageFormat.format(CLIText.get().notACommit, name)); | |||
} catch (IOException e) { | |||
throw new CmdLineException(MessageFormat.format(CLIText.get().cannotReadBecause, name, e.getMessage())); | |||
throw new CmdLineException(clp, MessageFormat.format(CLIText.get().cannotReadBecause, name, e.getMessage())); | |||
} | |||
if (interesting) |
@@ -89,20 +89,20 @@ public class RevTreeHandler extends OptionHandler<RevTree> { | |||
try { | |||
id = clp.getRepository().resolve(name); | |||
} catch (IOException e) { | |||
throw new CmdLineException(e.getMessage()); | |||
throw new CmdLineException(clp, e.getMessage()); | |||
} | |||
if (id == null) | |||
throw new CmdLineException(MessageFormat.format(CLIText.get().notATree, name)); | |||
throw new CmdLineException(clp, MessageFormat.format(CLIText.get().notATree, name)); | |||
final RevTree c; | |||
try { | |||
c = clp.getRevWalk().parseTree(id); | |||
} catch (MissingObjectException e) { | |||
throw new CmdLineException(MessageFormat.format(CLIText.get().notATree, name)); | |||
throw new CmdLineException(clp, MessageFormat.format(CLIText.get().notATree, name)); | |||
} catch (IncorrectObjectTypeException e) { | |||
throw new CmdLineException(MessageFormat.format(CLIText.get().notATree, name)); | |||
throw new CmdLineException(clp, MessageFormat.format(CLIText.get().notATree, name)); | |||
} catch (IOException e) { | |||
throw new CmdLineException(MessageFormat.format(CLIText.get().cannotReadBecause, name, e.getMessage())); | |||
throw new CmdLineException(clp, MessageFormat.format(CLIText.get().cannotReadBecause, name, e.getMessage())); | |||
} | |||
setter.addValue(c); | |||
return 1; |
@@ -63,6 +63,8 @@ import org.eclipse.jgit.pgm.internal.CLIText; | |||
* we can execute at runtime with the remaining arguments of the parser. | |||
*/ | |||
public class SubcommandHandler extends OptionHandler<TextBuiltin> { | |||
private final org.eclipse.jgit.pgm.opt.CmdLineParser clp; | |||
/** | |||
* Create a new handler for the command name. | |||
* <p> | |||
@@ -75,6 +77,7 @@ public class SubcommandHandler extends OptionHandler<TextBuiltin> { | |||
public SubcommandHandler(final CmdLineParser parser, | |||
final OptionDef option, final Setter<? super TextBuiltin> setter) { | |||
super(parser, option, setter); | |||
clp = (org.eclipse.jgit.pgm.opt.CmdLineParser) parser; | |||
} | |||
@Override | |||
@@ -82,7 +85,7 @@ public class SubcommandHandler extends OptionHandler<TextBuiltin> { | |||
final String name = params.getParameter(0); | |||
final CommandRef cr = CommandCatalog.get(name); | |||
if (cr == null) | |||
throw new CmdLineException(MessageFormat.format( | |||
throw new CmdLineException(clp, MessageFormat.format( | |||
CLIText.get().notAJgitCommand, name)); | |||
// Force option parsing to stop. Everything after us should |
@@ -104,37 +104,38 @@ public class BranchCommandTest extends RepositoryTestCase { | |||
private Git setUpRepoWithRemote() throws Exception { | |||
Repository remoteRepository = createWorkRepository(); | |||
Git remoteGit = new Git(remoteRepository); | |||
// commit something | |||
writeTrashFile("Test.txt", "Hello world"); | |||
remoteGit.add().addFilepattern("Test.txt").call(); | |||
initialCommit = remoteGit.commit().setMessage("Initial commit").call(); | |||
writeTrashFile("Test.txt", "Some change"); | |||
remoteGit.add().addFilepattern("Test.txt").call(); | |||
secondCommit = remoteGit.commit().setMessage("Second commit").call(); | |||
// create a master branch | |||
RefUpdate rup = remoteRepository.updateRef("refs/heads/master"); | |||
rup.setNewObjectId(initialCommit.getId()); | |||
rup.forceUpdate(); | |||
Repository localRepository = createWorkRepository(); | |||
Git localGit = new Git(localRepository); | |||
StoredConfig config = localRepository.getConfig(); | |||
RemoteConfig rc = new RemoteConfig(config, "origin"); | |||
rc.addURI(new URIish(remoteRepository.getDirectory().getAbsolutePath())); | |||
rc.addFetchRefSpec(new RefSpec("+refs/heads/*:refs/remotes/origin/*")); | |||
rc.update(config); | |||
config.save(); | |||
FetchResult res = localGit.fetch().setRemote("origin").call(); | |||
assertFalse(res.getTrackingRefUpdates().isEmpty()); | |||
rup = localRepository.updateRef("refs/heads/master"); | |||
rup.setNewObjectId(initialCommit.getId()); | |||
rup.forceUpdate(); | |||
rup = localRepository.updateRef(Constants.HEAD); | |||
rup.link("refs/heads/master"); | |||
rup.setNewObjectId(initialCommit.getId()); | |||
rup.update(); | |||
return localGit; | |||
try (Git remoteGit = new Git(remoteRepository)) { | |||
// commit something | |||
writeTrashFile("Test.txt", "Hello world"); | |||
remoteGit.add().addFilepattern("Test.txt").call(); | |||
initialCommit = remoteGit.commit().setMessage("Initial commit").call(); | |||
writeTrashFile("Test.txt", "Some change"); | |||
remoteGit.add().addFilepattern("Test.txt").call(); | |||
secondCommit = remoteGit.commit().setMessage("Second commit").call(); | |||
// create a master branch | |||
RefUpdate rup = remoteRepository.updateRef("refs/heads/master"); | |||
rup.setNewObjectId(initialCommit.getId()); | |||
rup.forceUpdate(); | |||
Repository localRepository = createWorkRepository(); | |||
Git localGit = new Git(localRepository); | |||
StoredConfig config = localRepository.getConfig(); | |||
RemoteConfig rc = new RemoteConfig(config, "origin"); | |||
rc.addURI(new URIish(remoteRepository.getDirectory().getAbsolutePath())); | |||
rc.addFetchRefSpec(new RefSpec("+refs/heads/*:refs/remotes/origin/*")); | |||
rc.update(config); | |||
config.save(); | |||
FetchResult res = localGit.fetch().setRemote("origin").call(); | |||
assertFalse(res.getTrackingRefUpdates().isEmpty()); | |||
rup = localRepository.updateRef("refs/heads/master"); | |||
rup.setNewObjectId(initialCommit.getId()); | |||
rup.forceUpdate(); | |||
rup = localRepository.updateRef(Constants.HEAD); | |||
rup.link("refs/heads/master"); | |||
rup.setNewObjectId(initialCommit.getId()); | |||
rup.update(); | |||
return localGit; | |||
} | |||
} | |||
@Test | |||
@@ -192,8 +193,7 @@ public class BranchCommandTest extends RepositoryTestCase { | |||
@Test | |||
public void testListAllBranchesShouldNotDie() throws Exception { | |||
Git git = setUpRepoWithRemote(); | |||
git.branchList().setListMode(ListMode.ALL).call(); | |||
setUpRepoWithRemote().branchList().setListMode(ListMode.ALL).call(); | |||
} | |||
@Test |
@@ -417,20 +417,20 @@ public class CheckoutCommandTest extends RepositoryTestCase { | |||
InvalidRemoteException, TransportException { | |||
// create second repository | |||
Repository db2 = createWorkRepository(); | |||
Git git2 = new Git(db2); | |||
// setup the second repository to fetch from the first repository | |||
final StoredConfig config = db2.getConfig(); | |||
RemoteConfig remoteConfig = new RemoteConfig(config, "origin"); | |||
URIish uri = new URIish(db.getDirectory().toURI().toURL()); | |||
remoteConfig.addURI(uri); | |||
remoteConfig.update(config); | |||
config.save(); | |||
// fetch from first repository | |||
RefSpec spec = new RefSpec("+refs/heads/*:refs/remotes/origin/*"); | |||
git2.fetch().setRemote("origin").setRefSpecs(spec).call(); | |||
return db2; | |||
try (Git git2 = new Git(db2)) { | |||
// setup the second repository to fetch from the first repository | |||
final StoredConfig config = db2.getConfig(); | |||
RemoteConfig remoteConfig = new RemoteConfig(config, "origin"); | |||
URIish uri = new URIish(db.getDirectory().toURI().toURL()); | |||
remoteConfig.addURI(uri); | |||
remoteConfig.update(config); | |||
config.save(); | |||
// fetch from first repository | |||
RefSpec spec = new RefSpec("+refs/heads/*:refs/remotes/origin/*"); | |||
git2.fetch().setRemote("origin").setRefSpecs(spec).call(); | |||
return db2; | |||
} | |||
} | |||
private CheckoutCommand newOrphanBranchCommand() { | |||
@@ -639,40 +639,41 @@ public class CheckoutCommandTest extends RepositoryTestCase { | |||
File clean_filter = writeTempFile("sed s/V1/@version/g -"); | |||
File smudge_filter = writeTempFile("sed s/@version/V1/g -"); | |||
Git git = new Git(db); | |||
StoredConfig config = git.getRepository().getConfig(); | |||
config.setString("filter", "tstFilter", "smudge", | |||
"sh " + slashify(smudge_filter.getPath())); | |||
config.setString("filter", "tstFilter", "clean", | |||
"sh " + slashify(clean_filter.getPath())); | |||
config.save(); | |||
writeTrashFile(".gitattributes", "*.txt filter=tstFilter"); | |||
git.add().addFilepattern(".gitattributes").call(); | |||
git.commit().setMessage("add attributes").call(); | |||
writeTrashFile("filterTest.txt", "hello world, V1"); | |||
git.add().addFilepattern("filterTest.txt").call(); | |||
git.commit().setMessage("add filterText.txt").call(); | |||
assertEquals( | |||
"[.gitattributes, mode:100644, content:*.txt filter=tstFilter][Test.txt, mode:100644, content:Some other change][filterTest.txt, mode:100644, content:hello world, @version]", | |||
indexState(CONTENT)); | |||
git.checkout().setCreateBranch(true).setName("test2").call(); | |||
writeTrashFile("filterTest.txt", "bon giorno world, V1"); | |||
git.add().addFilepattern("filterTest.txt").call(); | |||
git.commit().setMessage("modified filterText.txt").call(); | |||
assertTrue(git.status().call().isClean()); | |||
assertEquals( | |||
"[.gitattributes, mode:100644, content:*.txt filter=tstFilter][Test.txt, mode:100644, content:Some other change][filterTest.txt, mode:100644, content:bon giorno world, @version]", | |||
indexState(CONTENT)); | |||
git.checkout().setName("refs/heads/test").call(); | |||
assertTrue(git.status().call().isClean()); | |||
assertEquals( | |||
"[.gitattributes, mode:100644, content:*.txt filter=tstFilter][Test.txt, mode:100644, content:Some other change][filterTest.txt, mode:100644, content:hello world, @version]", | |||
indexState(CONTENT)); | |||
assertEquals("hello world, V1", read("filterTest.txt")); | |||
try (Git git2 = new Git(db)) { | |||
StoredConfig config = git.getRepository().getConfig(); | |||
config.setString("filter", "tstFilter", "smudge", | |||
"sh " + slashify(smudge_filter.getPath())); | |||
config.setString("filter", "tstFilter", "clean", | |||
"sh " + slashify(clean_filter.getPath())); | |||
config.save(); | |||
writeTrashFile(".gitattributes", "*.txt filter=tstFilter"); | |||
git2.add().addFilepattern(".gitattributes").call(); | |||
git2.commit().setMessage("add attributes").call(); | |||
writeTrashFile("filterTest.txt", "hello world, V1"); | |||
git2.add().addFilepattern("filterTest.txt").call(); | |||
git2.commit().setMessage("add filterText.txt").call(); | |||
assertEquals( | |||
"[.gitattributes, mode:100644, content:*.txt filter=tstFilter][Test.txt, mode:100644, content:Some other change][filterTest.txt, mode:100644, content:hello world, @version]", | |||
indexState(CONTENT)); | |||
git2.checkout().setCreateBranch(true).setName("test2").call(); | |||
writeTrashFile("filterTest.txt", "bon giorno world, V1"); | |||
git2.add().addFilepattern("filterTest.txt").call(); | |||
git2.commit().setMessage("modified filterText.txt").call(); | |||
assertTrue(git2.status().call().isClean()); | |||
assertEquals( | |||
"[.gitattributes, mode:100644, content:*.txt filter=tstFilter][Test.txt, mode:100644, content:Some other change][filterTest.txt, mode:100644, content:bon giorno world, @version]", | |||
indexState(CONTENT)); | |||
git2.checkout().setName("refs/heads/test").call(); | |||
assertTrue(git2.status().call().isClean()); | |||
assertEquals( | |||
"[.gitattributes, mode:100644, content:*.txt filter=tstFilter][Test.txt, mode:100644, content:Some other change][filterTest.txt, mode:100644, content:hello world, @version]", | |||
indexState(CONTENT)); | |||
assertEquals("hello world, V1", read("filterTest.txt")); | |||
} | |||
} | |||
private File writeTempFile(String body) throws IOException { |
@@ -69,6 +69,7 @@ public class DirCacheEntryTest { | |||
assertFalse(isValidPath("a\u0000b")); | |||
} | |||
@SuppressWarnings("unused") | |||
private static boolean isValidPath(String path) { | |||
try { | |||
new DirCacheEntry(path); | |||
@@ -78,6 +79,7 @@ public class DirCacheEntryTest { | |||
} | |||
} | |||
@SuppressWarnings("unused") | |||
@Test | |||
public void testCreate_ByStringPath() { | |||
assertEquals("a", new DirCacheEntry("a").getPathString()); | |||
@@ -91,6 +93,7 @@ public class DirCacheEntryTest { | |||
} | |||
} | |||
@SuppressWarnings("unused") | |||
@Test | |||
public void testCreate_ByStringPathAndStage() { | |||
DirCacheEntry e; |
@@ -72,6 +72,7 @@ public class FileRepositoryBuilderTest extends LocalDiskRepositoryTestCase { | |||
.findGitDir(d).getGitDir()); | |||
} | |||
@SuppressWarnings("unused") | |||
@Test | |||
public void emptyRepositoryFormatVersion() throws Exception { | |||
Repository r = createWorkRepository(); | |||
@@ -83,6 +84,7 @@ public class FileRepositoryBuilderTest extends LocalDiskRepositoryTestCase { | |||
new FileRepository(r.getDirectory()); | |||
} | |||
@SuppressWarnings("unused") | |||
@Test | |||
public void invalidRepositoryFormatVersion() throws Exception { | |||
Repository r = createWorkRepository(); | |||
@@ -99,6 +101,7 @@ public class FileRepositoryBuilderTest extends LocalDiskRepositoryTestCase { | |||
} | |||
} | |||
@SuppressWarnings("unused") | |||
@Test | |||
public void unknownRepositoryFormatVersion() throws Exception { | |||
Repository r = createWorkRepository(); |
@@ -558,13 +558,15 @@ public class RefUpdateTest extends SampleDataRepositoryTestCase { | |||
assertEquals(ppid, db.resolve("refs/heads/master")); | |||
// real test | |||
RevCommit old = new RevWalk(db).parseCommit(ppid); | |||
RefUpdate updateRef2 = db.updateRef("refs/heads/master"); | |||
updateRef2.setExpectedOldObjectId(old); | |||
updateRef2.setNewObjectId(pid); | |||
Result update2 = updateRef2.update(); | |||
assertEquals(Result.FAST_FORWARD, update2); | |||
assertEquals(pid, db.resolve("refs/heads/master")); | |||
try (RevWalk rw = new RevWalk(db)) { | |||
RevCommit old = rw.parseCommit(ppid); | |||
RefUpdate updateRef2 = db.updateRef("refs/heads/master"); | |||
updateRef2.setExpectedOldObjectId(old); | |||
updateRef2.setNewObjectId(pid); | |||
Result update2 = updateRef2.update(); | |||
assertEquals(Result.FAST_FORWARD, update2); | |||
assertEquals(pid, db.resolve("refs/heads/master")); | |||
} | |||
} | |||
/** | |||
@@ -707,9 +709,10 @@ public class RefUpdateTest extends SampleDataRepositoryTestCase { | |||
// Create new Repository instance, to reread caches and make sure our | |||
// assumptions are persistent. | |||
Repository ndb = new FileRepository(db.getDirectory()); | |||
assertEquals(rb2, ndb.resolve("refs/heads/new/name")); | |||
assertNull(ndb.resolve("refs/heads/b")); | |||
try (Repository ndb = new FileRepository(db.getDirectory())) { | |||
assertEquals(rb2, ndb.resolve("refs/heads/new/name")); | |||
assertNull(ndb.resolve("refs/heads/b")); | |||
} | |||
} | |||
public void tryRenameWhenLocked(String toLock, String fromName, | |||
@@ -751,7 +754,7 @@ public class RefUpdateTest extends SampleDataRepositoryTestCase { | |||
assertNull(db.resolve(toName)); | |||
assertEquals(oldFromLog.toString(), db.getReflogReader(fromName) | |||
.getReverseEntries().toString()); | |||
if (oldHeadId != null) | |||
if (oldHeadId != null && oldHeadLog != null) | |||
assertEquals(oldHeadLog.toString(), db.getReflogReader( | |||
Constants.HEAD).getReverseEntries().toString()); | |||
} finally { |
@@ -362,6 +362,7 @@ public class T0003_BasicTest extends SampleDataRepositoryTestCase { | |||
assertNotSame(db.getConfig(), db2.getConfig()); | |||
} | |||
@SuppressWarnings("unused") | |||
@Test | |||
public void test008_FailOnWrongVersion() throws IOException { | |||
final File cfg = new File(db.getDirectory(), Constants.CONFIG); |
@@ -75,11 +75,13 @@ public class T0001_PersonIdentTest { | |||
p.toExternalString()); | |||
} | |||
@SuppressWarnings("unused") | |||
@Test(expected = IllegalArgumentException.class) | |||
public void nullForNameShouldThrowIllegalArgumentException() { | |||
new PersonIdent(null, "author@example.com"); | |||
} | |||
@SuppressWarnings("unused") | |||
@Test(expected = IllegalArgumentException.class) | |||
public void nullForEmailShouldThrowIllegalArgumentException() { | |||
new PersonIdent("A U Thor", null); |
@@ -195,6 +195,7 @@ public class SideBandOutputStreamTest { | |||
assertEquals(1, flushCnt[0]); | |||
} | |||
@SuppressWarnings("unused") | |||
@Test | |||
public void testConstructor_RejectsBadChannel() { | |||
try { | |||
@@ -220,6 +221,7 @@ public class SideBandOutputStreamTest { | |||
} | |||
} | |||
@SuppressWarnings("unused") | |||
@Test | |||
public void testConstructor_RejectsBadBufferSize() { | |||
try { |
@@ -51,7 +51,6 @@ import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertNull; | |||
import static org.junit.Assert.assertTrue; | |||
import static org.junit.Assert.fail; | |||
import java.io.File; | |||
import java.io.IOException; | |||
@@ -64,24 +63,16 @@ public class URIishTest { | |||
private static final String GIT_SCHEME = "git://"; | |||
@Test | |||
@SuppressWarnings("unused") | |||
@Test(expected = URISyntaxException.class) | |||
public void shouldRaiseErrorOnEmptyURI() throws Exception { | |||
try { | |||
new URIish(""); | |||
fail("expecting an exception"); | |||
} catch (URISyntaxException e) { | |||
// expected | |||
} | |||
new URIish(""); | |||
} | |||
@Test | |||
@SuppressWarnings("unused") | |||
@Test(expected = URISyntaxException.class) | |||
public void shouldRaiseErrorOnNullURI() throws Exception { | |||
try { | |||
new URIish((String) null); | |||
fail("expecting an exception"); | |||
} catch (URISyntaxException e) { | |||
// expected | |||
} | |||
new URIish((String) null); | |||
} | |||
@Test | |||
@@ -634,34 +625,19 @@ public class URIishTest { | |||
assertEquals(u, new URIish(str)); | |||
} | |||
@Test | |||
@Test(expected = IllegalArgumentException.class) | |||
public void testGetNullHumanishName() { | |||
try { | |||
new URIish().getHumanishName(); | |||
fail("path must be not null"); | |||
} catch (IllegalArgumentException e) { | |||
// expected | |||
} | |||
new URIish().getHumanishName(); | |||
} | |||
@Test | |||
@Test(expected = IllegalArgumentException.class) | |||
public void testGetEmptyHumanishName() throws URISyntaxException { | |||
try { | |||
new URIish(GIT_SCHEME).getHumanishName(); | |||
fail("empty path is useless"); | |||
} catch (IllegalArgumentException e) { | |||
// expected | |||
} | |||
new URIish(GIT_SCHEME).getHumanishName(); | |||
} | |||
@Test | |||
@Test(expected = IllegalArgumentException.class) | |||
public void testGetAbsEmptyHumanishName() { | |||
try { | |||
new URIish().getHumanishName(); | |||
fail("empty path is useless"); | |||
} catch (IllegalArgumentException e) { | |||
// expected | |||
} | |||
new URIish().getHumanishName(); | |||
} | |||
@Test |
@@ -179,7 +179,7 @@ public class CommitCommand extends GitCommand<RevCommit> { | |||
processOptions(state, rw); | |||
if (all && !repo.isBare() && repo.getWorkTree() != null) { | |||
if (all && !repo.isBare()) { | |||
try (Git git = new Git(repo)) { | |||
git.add() | |||
.addFilepattern(".") //$NON-NLS-1$ |
@@ -715,7 +715,7 @@ public class URIish implements Serializable { | |||
*/ | |||
public String getHumanishName() throws IllegalArgumentException { | |||
String s = getPath(); | |||
if ("/".equals(s) || "".equals(s)) //$NON-NLS-1$ | |||
if ("/".equals(s) || "".equals(s)) //$NON-NLS-1$ //$NON-NLS-2$ | |||
s = getHost(); | |||
if (s == null) // $NON-NLS-1$ | |||
throw new IllegalArgumentException(); |
@@ -144,17 +144,6 @@ perl -pi~ -e ' | |||
} | |||
' org.eclipse.jgit.packaging/org.*.feature/pom.xml | |||
perl -pi~ -e ' | |||
if ($ARGV ne $old_argv) { | |||
$seen_version = 0; | |||
$old_argv = $ARGV; | |||
} | |||
if ($seen_version < 5) { | |||
$seen_version++ if | |||
s{<(version)>.*</\1>}{<${1}>'"$POM_V"'</${1}>}; | |||
} | |||
' org.eclipse.jgit.packaging/org.eclipse.jgit.updatesite/pom.xml | |||
perl -pi~ -e ' | |||
if ($ARGV ne $old_argv) { | |||
$seen_version = 0; |