Browse Source

Merge branch 'stable-4.2'

* 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>
stable-4.3
David Pursehouse 9 years ago
parent
commit
aca07fac46
  1. 10
      org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/BranchTest.java
  2. 55
      org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/CheckoutTest.java
  3. 16
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AbstractFetchCommand.java
  4. 2
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Config.java
  5. 2
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java
  6. 20
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Push.java
  7. 4
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Reset.java
  8. 6
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevParse.java
  9. 20
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/DiffAlgorithms.java
  10. 4
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java
  11. 4
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowPackDelta.java
  12. 8
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/TextHashFunctions.java
  13. 12
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/AbstractTreeIteratorHandler.java
  14. 4
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/ObjectIdHandler.java
  15. 16
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RevCommitHandler.java
  16. 10
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RevTreeHandler.java
  17. 5
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/SubcommandHandler.java
  18. 6
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/BranchCommandTest.java
  19. 27
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CheckoutCommandTest.java
  20. 3
      org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheEntryTest.java
  21. 3
      org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileRepositoryBuilderTest.java
  22. 9
      org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/RefUpdateTest.java
  23. 1
      org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/T0003_BasicTest.java
  24. 2
      org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/T0001_PersonIdentTest.java
  25. 2
      org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/SideBandOutputStreamTest.java
  26. 38
      org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/URIishTest.java
  27. 2
      org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java
  28. 2
      org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java
  29. 11
      tools/version.sh

10
org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/BranchTest.java

@ -63,7 +63,9 @@ public class BranchTest extends CLIRepositoryTestCase {
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
super.setUp(); super.setUp();
new Git(db).commit().setMessage("initial commit").call(); try (Git git = new Git(db)) {
git.commit().setMessage("initial commit").call();
}
} }
@Test @Test
@ -95,14 +97,16 @@ public class BranchTest extends CLIRepositoryTestCase {
@Test @Test
public void testListContains() throws Exception { public void testListContains() throws Exception {
new Git(db).branchCreate().setName("initial").call(); try (Git git = new Git(db)) {
RevCommit second = new Git(db).commit().setMessage("second commit") git.branchCreate().setName("initial").call();
RevCommit second = git.commit().setMessage("second commit")
.call(); .call();
assertEquals(toString(" initial", "* master"), assertEquals(toString(" initial", "* master"),
toString(execute("git branch --contains 6fd41be"))); toString(execute("git branch --contains 6fd41be")));
assertEquals("* master", assertEquals("* master",
toString(execute("git branch --contains " + second.name()))); toString(execute("git branch --contains " + second.name())));
} }
}
@Test @Test
public void testExistingBranch() throws Exception { public void testExistingBranch() throws Exception {

55
org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/CheckoutTest.java

@ -73,28 +73,34 @@ public class CheckoutTest extends CLIRepositoryTestCase {
@Test @Test
public void testCheckoutSelf() throws Exception { 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'", assertStringArrayEquals("Already on 'master'",
execute("git checkout master")); execute("git checkout master"));
} }
}
@Test @Test
public void testCheckoutBranch() throws Exception { public void testCheckoutBranch() throws Exception {
new Git(db).commit().setMessage("initial commit").call(); try (Git git = new Git(db)) {
new Git(db).branchCreate().setName("side").call(); git.commit().setMessage("initial commit").call();
git.branchCreate().setName("side").call();
assertStringArrayEquals("Switched to branch 'side'", assertStringArrayEquals("Switched to branch 'side'",
execute("git checkout side")); execute("git checkout side"));
} }
}
@Test @Test
public void testCheckoutNewBranch() throws Exception { 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'", assertStringArrayEquals("Switched to a new branch 'side'",
execute("git checkout -b side")); execute("git checkout -b side"));
} }
}
@Test @Test
public void testCheckoutNonExistingBranch() throws Exception { public void testCheckoutNonExistingBranch() throws Exception {
@ -105,12 +111,14 @@ public class CheckoutTest extends CLIRepositoryTestCase {
@Test @Test
public void testCheckoutNewBranchThatAlreadyExists() throws Exception { 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( assertStringArrayEquals(
"fatal: A branch named 'master' already exists.", "fatal: A branch named 'master' already exists.",
executeUnchecked("git checkout -b master")); executeUnchecked("git checkout -b master"));
} }
}
@Test @Test
public void testCheckoutNewBranchOnBranchToBeBorn() throws Exception { public void testCheckoutNewBranchOnBranchToBeBorn() throws Exception {
@ -127,14 +135,16 @@ public class CheckoutTest extends CLIRepositoryTestCase {
@Test @Test
public void testCheckoutHead() throws Exception { 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 @Test
public void testCheckoutExistingBranchWithConflict() throws Exception { public void testCheckoutExistingBranchWithConflict() throws Exception {
Git git = new Git(db); try (Git git = new Git(db)) {
writeTrashFile("a", "Hello world a"); writeTrashFile("a", "Hello world a");
git.add().addFilepattern(".").call(); git.add().addFilepattern(".").call();
git.commit().setMessage("commit file a").call(); git.commit().setMessage("commit file a").call();
@ -154,6 +164,7 @@ public class CheckoutTest extends CLIRepositoryTestCase {
execute[0]); execute[0]);
assertEquals("\ta", execute[1]); assertEquals("\ta", execute[1]);
} }
}
/** /**
* Steps: * Steps:
@ -174,7 +185,7 @@ public class CheckoutTest extends CLIRepositoryTestCase {
*/ */
@Test @Test
public void testCheckoutWithMissingWorkingTreeFile() throws Exception { public void testCheckoutWithMissingWorkingTreeFile() throws Exception {
Git git = new Git(db); try (Git git = new Git(db)) {
File fileA = writeTrashFile("a", "Hello world a"); File fileA = writeTrashFile("a", "Hello world a");
writeTrashFile("b", "Hello world b"); writeTrashFile("b", "Hello world b");
git.add().addFilepattern(".").call(); git.add().addFilepattern(".").call();
@ -197,10 +208,11 @@ public class CheckoutTest extends CLIRepositoryTestCase {
assertEquals(FileMode.REGULAR_FILE, entry.getMode()); assertEquals(FileMode.REGULAR_FILE, entry.getMode());
assertEquals("Hello world a", read(fileA)); assertEquals("Hello world a", read(fileA));
} }
}
@Test @Test
public void testCheckoutOrphan() throws Exception { public void testCheckoutOrphan() throws Exception {
Git git = new Git(db); try (Git git = new Git(db)) {
git.commit().setMessage("initial commit").call(); git.commit().setMessage("initial commit").call();
assertStringArrayEquals("Switched to a new branch 'new_branch'", assertStringArrayEquals("Switched to a new branch 'new_branch'",
@ -210,6 +222,7 @@ public class CheckoutTest extends CLIRepositoryTestCase {
RevCommit commit = git.commit().setMessage("orphan commit").call(); RevCommit commit = git.commit().setMessage("orphan commit").call();
assertEquals(0, commit.getParentCount()); assertEquals(0, commit.getParentCount());
} }
}
/** /**
* Steps: * Steps:
@ -231,7 +244,7 @@ public class CheckoutTest extends CLIRepositoryTestCase {
@Test @Test
public void fileModeTestMissingThenFolderWithFileInWorkingTree() public void fileModeTestMissingThenFolderWithFileInWorkingTree()
throws Exception { throws Exception {
Git git = new Git(db); try (Git git = new Git(db)) {
writeTrashFile("b", "Hello world b"); writeTrashFile("b", "Hello world b");
git.add().addFilepattern(".").call(); git.add().addFilepattern(".").call();
git.commit().setMessage("add file b").call(); git.commit().setMessage("add file b").call();
@ -259,6 +272,7 @@ public class CheckoutTest extends CLIRepositoryTestCase {
db.getFS()); db.getFS());
assertEquals(FileMode.REGULAR_FILE, entry.getMode()); assertEquals(FileMode.REGULAR_FILE, entry.getMode());
} }
}
/** /**
* Steps: * Steps:
@ -279,7 +293,7 @@ public class CheckoutTest extends CLIRepositoryTestCase {
*/ */
@Test @Test
public void fileModeTestFolderWithMissingInWorkingTree() throws Exception { public void fileModeTestFolderWithMissingInWorkingTree() throws Exception {
Git git = new Git(db); try (Git git = new Git(db)) {
writeTrashFile("b", "Hello world b"); writeTrashFile("b", "Hello world b");
writeTrashFile("a", "b"); writeTrashFile("a", "b");
git.add().addFilepattern(".").call(); git.add().addFilepattern(".").call();
@ -304,6 +318,7 @@ public class CheckoutTest extends CLIRepositoryTestCase {
db.getFS()); db.getFS());
assertEquals(FileMode.REGULAR_FILE, entry.getMode()); assertEquals(FileMode.REGULAR_FILE, entry.getMode());
} }
}
/** /**
* Steps: * Steps:
@ -324,7 +339,7 @@ public class CheckoutTest extends CLIRepositoryTestCase {
*/ */
@Test @Test
public void fileModeTestMissingWithFolderInWorkingTree() throws Exception { public void fileModeTestMissingWithFolderInWorkingTree() throws Exception {
Git git = new Git(db); try (Git git = new Git(db)) {
writeTrashFile("b", "Hello world b"); writeTrashFile("b", "Hello world b");
writeTrashFile("a", "b"); writeTrashFile("a", "b");
git.add().addFilepattern(".").call(); git.add().addFilepattern(".").call();
@ -351,6 +366,7 @@ public class CheckoutTest extends CLIRepositoryTestCase {
assertEquals("a", exception.getConflictingPaths().get(0)); assertEquals("a", exception.getConflictingPaths().get(0));
assertEquals("a/c", exception.getConflictingPaths().get(1)); assertEquals("a/c", exception.getConflictingPaths().get(1));
} }
}
/** /**
* Steps: * Steps:
@ -371,7 +387,7 @@ public class CheckoutTest extends CLIRepositoryTestCase {
@Test @Test
public void fileModeTestFolderThenMissingWithFileInWorkingTree() public void fileModeTestFolderThenMissingWithFileInWorkingTree()
throws Exception { throws Exception {
Git git = new Git(db); try (Git git = new Git(db)) {
FileUtils.mkdirs(new File(db.getWorkTree(), "a")); FileUtils.mkdirs(new File(db.getWorkTree(), "a"));
writeTrashFile("a/c", "Hello world c"); writeTrashFile("a/c", "Hello world c");
writeTrashFile("b", "Hello world b"); writeTrashFile("b", "Hello world b");
@ -406,6 +422,7 @@ public class CheckoutTest extends CLIRepositoryTestCase {
assertEquals(1, exception.getConflictingPaths().size()); assertEquals(1, exception.getConflictingPaths().size());
assertEquals("a", exception.getConflictingPaths().get(0)); assertEquals("a", exception.getConflictingPaths().get(0));
} }
}
/** /**
* Steps: * Steps:
@ -427,7 +444,7 @@ public class CheckoutTest extends CLIRepositoryTestCase {
@Test @Test
public void fileModeTestFolderThenFileWithMissingInWorkingTree() public void fileModeTestFolderThenFileWithMissingInWorkingTree()
throws Exception { throws Exception {
Git git = new Git(db); try (Git git = new Git(db)) {
FileUtils.mkdirs(new File(db.getWorkTree(), "a")); FileUtils.mkdirs(new File(db.getWorkTree(), "a"));
writeTrashFile("a/c", "Hello world c"); writeTrashFile("a/c", "Hello world c");
writeTrashFile("b", "Hello world b"); writeTrashFile("b", "Hello world b");
@ -452,6 +469,7 @@ public class CheckoutTest extends CLIRepositoryTestCase {
db.getFS()); db.getFS());
assertEquals(FileMode.TREE, entry.getMode()); assertEquals(FileMode.TREE, entry.getMode());
} }
}
/** /**
* Steps: * Steps:
@ -471,7 +489,7 @@ public class CheckoutTest extends CLIRepositoryTestCase {
*/ */
@Test @Test
public void fileModeTestFileThenFileWithFolderInIndex() throws Exception { public void fileModeTestFileThenFileWithFolderInIndex() throws Exception {
Git git = new Git(db); try (Git git = new Git(db)) {
writeTrashFile("a", "Hello world a"); writeTrashFile("a", "Hello world a");
writeTrashFile("b", "Hello world b"); writeTrashFile("b", "Hello world b");
git.add().addFilepattern(".").call(); git.add().addFilepattern(".").call();
@ -504,6 +522,7 @@ public class CheckoutTest extends CLIRepositoryTestCase {
assertEquals(1, exception.getConflictingPaths().size()); assertEquals(1, exception.getConflictingPaths().size());
assertEquals("a", exception.getConflictingPaths().get(0)); assertEquals("a", exception.getConflictingPaths().get(0));
} }
}
/** /**
* Steps: * Steps:
@ -524,7 +543,7 @@ public class CheckoutTest extends CLIRepositoryTestCase {
*/ */
@Test @Test
public void fileModeTestFileWithFolderInIndex() throws Exception { public void fileModeTestFileWithFolderInIndex() throws Exception {
Git git = new Git(db); try (Git git = new Git(db)) {
writeTrashFile("b", "Hello world b"); writeTrashFile("b", "Hello world b");
writeTrashFile("a", "b"); writeTrashFile("a", "b");
git.add().addFilepattern(".").call(); git.add().addFilepattern(".").call();
@ -563,10 +582,11 @@ public class CheckoutTest extends CLIRepositoryTestCase {
// assertEquals("a", exception.getConflictingPaths().get(0)); // assertEquals("a", exception.getConflictingPaths().get(0));
// assertEquals("a/c", exception.getConflictingPaths().get(1)); // assertEquals("a/c", exception.getConflictingPaths().get(1));
} }
}
@Test @Test
public void testCheckoutPath() throws Exception { public void testCheckoutPath() throws Exception {
Git git = new Git(db); try (Git git = new Git(db)) {
writeTrashFile("a", "Hello world a"); writeTrashFile("a", "Hello world a");
git.add().addFilepattern(".").call(); git.add().addFilepattern(".").call();
git.commit().setMessage("commit file a").call(); git.commit().setMessage("commit file a").call();
@ -585,6 +605,7 @@ public class CheckoutTest extends CLIRepositoryTestCase {
execute("git branch")); execute("git branch"));
assertEquals("Hello world b", read(b)); assertEquals("Hello world b", read(b));
} }
}
@Test @Test
public void testCheckouSingleFile() throws Exception { public void testCheckouSingleFile() throws Exception {

16
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AbstractFetchCommand.java

@ -129,20 +129,20 @@ abstract class AbstractFetchCommand extends TextBuiltin {
final TrackingRefUpdate u) { final TrackingRefUpdate u) {
final RefUpdate.Result r = u.getResult(); final RefUpdate.Result r = u.getResult();
if (r == RefUpdate.Result.LOCK_FAILURE) if (r == RefUpdate.Result.LOCK_FAILURE)
return "[lock fail]"; return "[lock fail]"; //$NON-NLS-1$
if (r == RefUpdate.Result.IO_FAILURE) if (r == RefUpdate.Result.IO_FAILURE)
return "[i/o error]"; return "[i/o error]"; //$NON-NLS-1$
if (r == RefUpdate.Result.REJECTED) if (r == RefUpdate.Result.REJECTED)
return "[rejected]"; return "[rejected]"; //$NON-NLS-1$
if (ObjectId.zeroId().equals(u.getNewObjectId())) if (ObjectId.zeroId().equals(u.getNewObjectId()))
return "[deleted]"; return "[deleted]"; //$NON-NLS-1$
if (r == RefUpdate.Result.NEW) { if (r == RefUpdate.Result.NEW) {
if (u.getRemoteName().startsWith(Constants.R_HEADS)) if (u.getRemoteName().startsWith(Constants.R_HEADS))
return "[new branch]"; return "[new branch]"; //$NON-NLS-1$
else if (u.getLocalName().startsWith(Constants.R_TAGS)) else if (u.getLocalName().startsWith(Constants.R_TAGS))
return "[new tag]"; return "[new tag]"; //$NON-NLS-1$
return "[new]"; return "[new]"; //$NON-NLS-1$
} }
if (r == RefUpdate.Result.FORCED) { if (r == RefUpdate.Result.FORCED) {
@ -158,7 +158,7 @@ abstract class AbstractFetchCommand extends TextBuiltin {
} }
if (r == RefUpdate.Result.NO_CHANGE) 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$ return "[" + r.name() + "]"; //$NON-NLS-1$//$NON-NLS-2$
} }

2
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Config.java

@ -74,7 +74,7 @@ class Config extends TextBuiltin {
list(); list();
else else
throw new NotSupportedException( throw new NotSupportedException(
"only --list option is currently supported"); "only --list option is currently supported"); //$NON-NLS-1$
} }
private void list() throws IOException, ConfigInvalidException { private void list() throws IOException, ConfigInvalidException {

2
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java

@ -324,7 +324,7 @@ class Log extends RevWalkTextBuiltin {
return false; return false;
if (emptyLine) if (emptyLine)
outw.println(); outw.println();
outw.print("Notes"); outw.print("Notes"); //$NON-NLS-1$
if (label != null) { if (label != null) {
outw.print(" ("); //$NON-NLS-1$ outw.print(" ("); //$NON-NLS-1$
outw.print(label); outw.print(label);

20
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Push.java

@ -182,15 +182,15 @@ class Push extends TextBuiltin {
switch (rru.getStatus()) { switch (rru.getStatus()) {
case OK: case OK:
if (rru.isDelete()) if (rru.isDelete())
printUpdateLine('-', "[deleted]", null, remoteName, null); printUpdateLine('-', "[deleted]", null, remoteName, null); //$NON-NLS-1$
else { else {
final Ref oldRef = result.getAdvertisedRef(remoteName); final Ref oldRef = result.getAdvertisedRef(remoteName);
if (oldRef == null) { if (oldRef == null) {
final String summary; final String summary;
if (remoteName.startsWith(Constants.R_TAGS)) if (remoteName.startsWith(Constants.R_TAGS))
summary = "[new tag]"; summary = "[new tag]"; //$NON-NLS-1$
else else
summary = "[new branch]"; summary = "[new branch]"; //$NON-NLS-1$
printUpdateLine('*', summary, srcRef, remoteName, null); printUpdateLine('*', summary, srcRef, remoteName, null);
} else { } else {
boolean fastForward = rru.isFastForward(); boolean fastForward = rru.isFastForward();
@ -206,16 +206,16 @@ class Push extends TextBuiltin {
break; break;
case NON_EXISTING: case NON_EXISTING:
printUpdateLine('X', "[no match]", null, remoteName, null); printUpdateLine('X', "[no match]", null, remoteName, null); //$NON-NLS-1$
break; break;
case REJECTED_NODELETE: case REJECTED_NODELETE:
printUpdateLine('!', "[rejected]", null, remoteName, printUpdateLine('!', "[rejected]", null, remoteName, //$NON-NLS-1$
CLIText.get().remoteSideDoesNotSupportDeletingRefs); CLIText.get().remoteSideDoesNotSupportDeletingRefs);
break; break;
case REJECTED_NONFASTFORWARD: case REJECTED_NONFASTFORWARD:
printUpdateLine('!', "[rejected]", srcRef, remoteName, printUpdateLine('!', "[rejected]", srcRef, remoteName, //$NON-NLS-1$
CLIText.get().nonFastForward); CLIText.get().nonFastForward);
break; break;
@ -223,22 +223,22 @@ class Push extends TextBuiltin {
final String message = MessageFormat.format( final String message = MessageFormat.format(
CLIText.get().remoteRefObjectChangedIsNotExpectedOne, CLIText.get().remoteRefObjectChangedIsNotExpectedOne,
safeAbbreviate(reader, rru.getExpectedOldObjectId())); safeAbbreviate(reader, rru.getExpectedOldObjectId()));
printUpdateLine('!', "[rejected]", srcRef, remoteName, message); printUpdateLine('!', "[rejected]", srcRef, remoteName, message); //$NON-NLS-1$
break; break;
case REJECTED_OTHER_REASON: case REJECTED_OTHER_REASON:
printUpdateLine('!', "[remote rejected]", srcRef, remoteName, rru printUpdateLine('!', "[remote rejected]", srcRef, remoteName, rru //$NON-NLS-1$
.getMessage()); .getMessage());
break; break;
case UP_TO_DATE: case UP_TO_DATE:
if (verbose) if (verbose)
printUpdateLine('=', "[up to date]", srcRef, remoteName, null); printUpdateLine('=', "[up to date]", srcRef, remoteName, null); //$NON-NLS-1$
break; break;
case NOT_ATTEMPTED: case NOT_ATTEMPTED:
case AWAITING_REPORT: case AWAITING_REPORT:
printUpdateLine('?', "[unexpected push-process behavior]", srcRef, printUpdateLine('?', "[unexpected push-process behavior]", srcRef, //$NON-NLS-1$
remoteName, rru.getMessage()); remoteName, rru.getMessage());
break; break;
} }

4
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Reset.java

@ -89,7 +89,7 @@ class Reset extends TextBuiltin {
if (hard) if (hard)
mode = selectMode(mode, ResetType.HARD); mode = selectMode(mode, ResetType.HARD);
if (mode == null) if (mode == null)
throw die("no reset mode set"); throw die("no reset mode set"); //$NON-NLS-1$
command.setMode(mode); command.setMode(mode);
} }
command.call(); command.call();
@ -98,7 +98,7 @@ class Reset extends TextBuiltin {
private static ResetType selectMode(ResetType mode, ResetType want) { private static ResetType selectMode(ResetType mode, ResetType want) {
if (mode != null) 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; return want;
} }
} }

6
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevParse.java

@ -56,7 +56,8 @@ import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.Option; import org.kohsuke.args4j.Option;
import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Ref; 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") @Command(usage = "usage_RevParse")
class RevParse extends TextBuiltin { class RevParse extends TextBuiltin {
@ -84,7 +85,8 @@ class RevParse extends TextBuiltin {
} }
} else { } else {
if (verify && commits.size() > 1) { 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) { for (final ObjectId o : commits) {

20
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/DiffAlgorithms.java

@ -136,7 +136,7 @@ class DiffAlgorithms extends TextBuiltin {
protected void run() throws Exception { protected void run() throws Exception {
mxBean = ManagementFactory.getThreadMXBean(); mxBean = ManagementFactory.getThreadMXBean();
if (!mxBean.isCurrentThreadCpuTimeSupported()) 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()) { if (gitDirs.isEmpty()) {
RepositoryBuilder rb = new RepositoryBuilder() // RepositoryBuilder rb = new RepositoryBuilder() //
@ -248,18 +248,18 @@ class DiffAlgorithms extends TextBuiltin {
File parent = directory.getParentFile(); File parent = directory.getParentFile();
if (name.equals(Constants.DOT_GIT) && parent != null) if (name.equals(Constants.DOT_GIT) && parent != null)
name = parent.getName(); 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)); 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)); valueOf(maxN));
outw.format("%-25s %12s ( %12s %12s )\n", // outw.format("%-25s %12s ( %12s %12s )\n", //$NON-NLS-1$
"Algorithm", "Time(ns)", "Time(ns) on", "Time(ns) on"); "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", // outw.format("%-25s %12s ( %12s %12s )\n", //$NON-NLS-1$
"", "", "N=" + minN, "N=" + maxN); "", "", "N=" + minN, "N=" + maxN); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
outw.println("-----------------------------------------------------" //$NON-NLS-1$ outw.println("-----------------------------------------------------" //$NON-NLS-1$
+ "----------------"); //$NON-NLS-1$ + "----------------"); //$NON-NLS-1$
@ -335,9 +335,9 @@ class DiffAlgorithms extends TextBuiltin {
} }
} }
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
throw die("Cannot determine names", e); throw die("Cannot determine names", e); //$NON-NLS-1$
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
throw die("Cannot determine names", e); throw die("Cannot determine names", e); //$NON-NLS-1$
} }
return all; return all;

4
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java

@ -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()) { try (ObjectInserter oi = db.newObjectInserter()) {
final ObjectId emptyTree = oi.insert(Constants.OBJ_TREE, final ObjectId emptyTree = oi.insert(Constants.OBJ_TREE,
new byte[] {}); new byte[] {});
@ -203,7 +203,7 @@ class RebuildCommitGraph extends TextBuiltin {
newc.setAuthor(new PersonIdent(me, new Date(t.commitTime))); newc.setAuthor(new PersonIdent(me, new Date(t.commitTime)));
newc.setCommitter(newc.getAuthor()); newc.setCommitter(newc.getAuthor());
newc.setParentIds(newParents); 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); t.newId = oi.insert(newc);
rewrites.put(t.oldId, t.newId); rewrites.put(t.oldId, t.newId);
pm.update(1); pm.update(1);

4
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowPackDelta.java

@ -87,9 +87,9 @@ class ShowPackDelta extends TextBuiltin {
long size = reader.getObjectSize(obj, obj.getType()); long size = reader.getObjectSize(obj, obj.getType());
try { try {
if (BinaryDelta.getResultSize(delta) != size) 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) { } 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)); outw.println(BinaryDelta.format(delta));

8
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/TextHashFunctions.java

@ -349,10 +349,10 @@ class TextHashFunctions extends TextBuiltin {
name = parent.getName(); name = parent.getName();
outw.println(name + ":"); //$NON-NLS-1$ 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(fileCnt), //
valueOf(lineCnt / 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$ outw.println("-----------------------------------------------"); //$NON-NLS-1$
String lastHashName = null; String lastHashName = null;
for (Function fun : all) { for (Function fun : all) {
@ -405,9 +405,9 @@ class TextHashFunctions extends TextBuiltin {
} }
} }
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
throw new RuntimeException("Cannot determine names", e); throw new RuntimeException("Cannot determine names", e); //$NON-NLS-1$
} catch (IllegalAccessException e) { } 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>(); List<Function> all = new ArrayList<Function>();

12
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/AbstractTreeIteratorHandler.java

@ -109,7 +109,7 @@ public class AbstractTreeIteratorHandler extends
try { try {
dirc = DirCache.read(new File(name), FS.DETECTED); dirc = DirCache.read(new File(name), FS.DETECTED);
} catch (IOException e) { } 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)); setter.addValue(new DirCacheIterator(dirc));
return 1; return 1;
@ -119,20 +119,20 @@ public class AbstractTreeIteratorHandler extends
try { try {
id = clp.getRepository().resolve(name); id = clp.getRepository().resolve(name);
} catch (IOException e) { } catch (IOException e) {
throw new CmdLineException(e.getMessage()); throw new CmdLineException(clp, e.getMessage());
} }
if (id == null) 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(); final CanonicalTreeParser p = new CanonicalTreeParser();
try (ObjectReader curs = clp.getRepository().newObjectReader()) { try (ObjectReader curs = clp.getRepository().newObjectReader()) {
p.reset(curs, clp.getRevWalk().parseTree(id)); p.reset(curs, clp.getRevWalk().parseTree(id));
} catch (MissingObjectException e) { } 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) { } 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) { } 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); setter.addValue(p);

4
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/ObjectIdHandler.java

@ -86,14 +86,14 @@ public class ObjectIdHandler extends OptionHandler<ObjectId> {
try { try {
id = clp.getRepository().resolve(name); id = clp.getRepository().resolve(name);
} catch (IOException e) { } catch (IOException e) {
throw new CmdLineException(e.getMessage()); throw new CmdLineException(clp, e.getMessage());
} }
if (id != null) { if (id != null) {
setter.addValue(id); setter.addValue(id);
return 1; return 1;
} }
throw new CmdLineException(MessageFormat.format(CLIText.get().notAnObject, name)); throw new CmdLineException(clp, MessageFormat.format(CLIText.get().notAnObject, name));
} }
@Override @Override

16
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RevCommitHandler.java

@ -96,8 +96,10 @@ public class RevCommitHandler extends OptionHandler<RevCommit> {
final int dot2 = name.indexOf(".."); //$NON-NLS-1$ final int dot2 = name.indexOf(".."); //$NON-NLS-1$
if (dot2 != -1) { if (dot2 != -1) {
if (!option.isMultiValued()) if (!option.isMultiValued())
throw new CmdLineException(MessageFormat.format(CLIText.get().onlyOneMetaVarExpectedIn throw new CmdLineException(clp,
, option.metaVar(), name)); MessageFormat.format(
CLIText.get().onlyOneMetaVarExpectedIn,
option.metaVar(), name));
final String left = name.substring(0, dot2); final String left = name.substring(0, dot2);
final String right = name.substring(dot2 + 2); final String right = name.substring(dot2 + 2);
@ -116,20 +118,20 @@ public class RevCommitHandler extends OptionHandler<RevCommit> {
try { try {
id = clp.getRepository().resolve(name); id = clp.getRepository().resolve(name);
} catch (IOException e) { } catch (IOException e) {
throw new CmdLineException(e.getMessage()); throw new CmdLineException(clp, e.getMessage());
} }
if (id == null) 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; final RevCommit c;
try { try {
c = clp.getRevWalk().parseCommit(id); c = clp.getRevWalk().parseCommit(id);
} catch (MissingObjectException e) { } 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) { } 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) { } 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) if (interesting)

10
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RevTreeHandler.java

@ -89,20 +89,20 @@ public class RevTreeHandler extends OptionHandler<RevTree> {
try { try {
id = clp.getRepository().resolve(name); id = clp.getRepository().resolve(name);
} catch (IOException e) { } catch (IOException e) {
throw new CmdLineException(e.getMessage()); throw new CmdLineException(clp, e.getMessage());
} }
if (id == null) 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; final RevTree c;
try { try {
c = clp.getRevWalk().parseTree(id); c = clp.getRevWalk().parseTree(id);
} catch (MissingObjectException e) { } 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) { } 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) { } 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); setter.addValue(c);
return 1; return 1;

5
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/SubcommandHandler.java

@ -63,6 +63,8 @@ import org.eclipse.jgit.pgm.internal.CLIText;
* we can execute at runtime with the remaining arguments of the parser. * we can execute at runtime with the remaining arguments of the parser.
*/ */
public class SubcommandHandler extends OptionHandler<TextBuiltin> { public class SubcommandHandler extends OptionHandler<TextBuiltin> {
private final org.eclipse.jgit.pgm.opt.CmdLineParser clp;
/** /**
* Create a new handler for the command name. * Create a new handler for the command name.
* <p> * <p>
@ -75,6 +77,7 @@ public class SubcommandHandler extends OptionHandler<TextBuiltin> {
public SubcommandHandler(final CmdLineParser parser, public SubcommandHandler(final CmdLineParser parser,
final OptionDef option, final Setter<? super TextBuiltin> setter) { final OptionDef option, final Setter<? super TextBuiltin> setter) {
super(parser, option, setter); super(parser, option, setter);
clp = (org.eclipse.jgit.pgm.opt.CmdLineParser) parser;
} }
@Override @Override
@ -82,7 +85,7 @@ public class SubcommandHandler extends OptionHandler<TextBuiltin> {
final String name = params.getParameter(0); final String name = params.getParameter(0);
final CommandRef cr = CommandCatalog.get(name); final CommandRef cr = CommandCatalog.get(name);
if (cr == null) if (cr == null)
throw new CmdLineException(MessageFormat.format( throw new CmdLineException(clp, MessageFormat.format(
CLIText.get().notAJgitCommand, name)); CLIText.get().notAJgitCommand, name));
// Force option parsing to stop. Everything after us should // Force option parsing to stop. Everything after us should

6
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/BranchCommandTest.java

@ -104,7 +104,7 @@ public class BranchCommandTest extends RepositoryTestCase {
private Git setUpRepoWithRemote() throws Exception { private Git setUpRepoWithRemote() throws Exception {
Repository remoteRepository = createWorkRepository(); Repository remoteRepository = createWorkRepository();
Git remoteGit = new Git(remoteRepository); try (Git remoteGit = new Git(remoteRepository)) {
// commit something // commit something
writeTrashFile("Test.txt", "Hello world"); writeTrashFile("Test.txt", "Hello world");
remoteGit.add().addFilepattern("Test.txt").call(); remoteGit.add().addFilepattern("Test.txt").call();
@ -136,6 +136,7 @@ public class BranchCommandTest extends RepositoryTestCase {
rup.update(); rup.update();
return localGit; return localGit;
} }
}
@Test @Test
public void testCreateAndList() throws Exception { public void testCreateAndList() throws Exception {
@ -192,8 +193,7 @@ public class BranchCommandTest extends RepositoryTestCase {
@Test @Test
public void testListAllBranchesShouldNotDie() throws Exception { public void testListAllBranchesShouldNotDie() throws Exception {
Git git = setUpRepoWithRemote(); setUpRepoWithRemote().branchList().setListMode(ListMode.ALL).call();
git.branchList().setListMode(ListMode.ALL).call();
} }
@Test @Test

27
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CheckoutCommandTest.java

@ -417,8 +417,7 @@ public class CheckoutCommandTest extends RepositoryTestCase {
InvalidRemoteException, TransportException { InvalidRemoteException, TransportException {
// create second repository // create second repository
Repository db2 = createWorkRepository(); Repository db2 = createWorkRepository();
Git git2 = new Git(db2); try (Git git2 = new Git(db2)) {
// setup the second repository to fetch from the first repository // setup the second repository to fetch from the first repository
final StoredConfig config = db2.getConfig(); final StoredConfig config = db2.getConfig();
RemoteConfig remoteConfig = new RemoteConfig(config, "origin"); RemoteConfig remoteConfig = new RemoteConfig(config, "origin");
@ -432,6 +431,7 @@ public class CheckoutCommandTest extends RepositoryTestCase {
git2.fetch().setRemote("origin").setRefSpecs(spec).call(); git2.fetch().setRemote("origin").setRefSpecs(spec).call();
return db2; return db2;
} }
}
private CheckoutCommand newOrphanBranchCommand() { private CheckoutCommand newOrphanBranchCommand() {
return git.checkout().setOrphan(true) return git.checkout().setOrphan(true)
@ -639,7 +639,7 @@ public class CheckoutCommandTest extends RepositoryTestCase {
File clean_filter = writeTempFile("sed s/V1/@version/g -"); File clean_filter = writeTempFile("sed s/V1/@version/g -");
File smudge_filter = writeTempFile("sed s/@version/V1/g -"); File smudge_filter = writeTempFile("sed s/@version/V1/g -");
Git git = new Git(db); try (Git git2 = new Git(db)) {
StoredConfig config = git.getRepository().getConfig(); StoredConfig config = git.getRepository().getConfig();
config.setString("filter", "tstFilter", "smudge", config.setString("filter", "tstFilter", "smudge",
"sh " + slashify(smudge_filter.getPath())); "sh " + slashify(smudge_filter.getPath()));
@ -647,33 +647,34 @@ public class CheckoutCommandTest extends RepositoryTestCase {
"sh " + slashify(clean_filter.getPath())); "sh " + slashify(clean_filter.getPath()));
config.save(); config.save();
writeTrashFile(".gitattributes", "*.txt filter=tstFilter"); writeTrashFile(".gitattributes", "*.txt filter=tstFilter");
git.add().addFilepattern(".gitattributes").call(); git2.add().addFilepattern(".gitattributes").call();
git.commit().setMessage("add attributes").call(); git2.commit().setMessage("add attributes").call();
writeTrashFile("filterTest.txt", "hello world, V1"); writeTrashFile("filterTest.txt", "hello world, V1");
git.add().addFilepattern("filterTest.txt").call(); git2.add().addFilepattern("filterTest.txt").call();
git.commit().setMessage("add filterText.txt").call(); git2.commit().setMessage("add filterText.txt").call();
assertEquals( assertEquals(
"[.gitattributes, mode:100644, content:*.txt filter=tstFilter][Test.txt, mode:100644, content:Some other change][filterTest.txt, mode:100644, content:hello world, @version]", "[.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)); indexState(CONTENT));
git.checkout().setCreateBranch(true).setName("test2").call(); git2.checkout().setCreateBranch(true).setName("test2").call();
writeTrashFile("filterTest.txt", "bon giorno world, V1"); writeTrashFile("filterTest.txt", "bon giorno world, V1");
git.add().addFilepattern("filterTest.txt").call(); git2.add().addFilepattern("filterTest.txt").call();
git.commit().setMessage("modified filterText.txt").call(); git2.commit().setMessage("modified filterText.txt").call();
assertTrue(git.status().call().isClean()); assertTrue(git2.status().call().isClean());
assertEquals( 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]", "[.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)); indexState(CONTENT));
git.checkout().setName("refs/heads/test").call(); git2.checkout().setName("refs/heads/test").call();
assertTrue(git.status().call().isClean()); assertTrue(git2.status().call().isClean());
assertEquals( assertEquals(
"[.gitattributes, mode:100644, content:*.txt filter=tstFilter][Test.txt, mode:100644, content:Some other change][filterTest.txt, mode:100644, content:hello world, @version]", "[.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)); indexState(CONTENT));
assertEquals("hello world, V1", read("filterTest.txt")); assertEquals("hello world, V1", read("filterTest.txt"));
} }
}
private File writeTempFile(String body) throws IOException { private File writeTempFile(String body) throws IOException {
File f = File.createTempFile("AddCommandTest_", ""); File f = File.createTempFile("AddCommandTest_", "");

3
org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheEntryTest.java vendored

@ -69,6 +69,7 @@ public class DirCacheEntryTest {
assertFalse(isValidPath("a\u0000b")); assertFalse(isValidPath("a\u0000b"));
} }
@SuppressWarnings("unused")
private static boolean isValidPath(String path) { private static boolean isValidPath(String path) {
try { try {
new DirCacheEntry(path); new DirCacheEntry(path);
@ -78,6 +79,7 @@ public class DirCacheEntryTest {
} }
} }
@SuppressWarnings("unused")
@Test @Test
public void testCreate_ByStringPath() { public void testCreate_ByStringPath() {
assertEquals("a", new DirCacheEntry("a").getPathString()); assertEquals("a", new DirCacheEntry("a").getPathString());
@ -91,6 +93,7 @@ public class DirCacheEntryTest {
} }
} }
@SuppressWarnings("unused")
@Test @Test
public void testCreate_ByStringPathAndStage() { public void testCreate_ByStringPathAndStage() {
DirCacheEntry e; DirCacheEntry e;

3
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileRepositoryBuilderTest.java

@ -72,6 +72,7 @@ public class FileRepositoryBuilderTest extends LocalDiskRepositoryTestCase {
.findGitDir(d).getGitDir()); .findGitDir(d).getGitDir());
} }
@SuppressWarnings("unused")
@Test @Test
public void emptyRepositoryFormatVersion() throws Exception { public void emptyRepositoryFormatVersion() throws Exception {
Repository r = createWorkRepository(); Repository r = createWorkRepository();
@ -83,6 +84,7 @@ public class FileRepositoryBuilderTest extends LocalDiskRepositoryTestCase {
new FileRepository(r.getDirectory()); new FileRepository(r.getDirectory());
} }
@SuppressWarnings("unused")
@Test @Test
public void invalidRepositoryFormatVersion() throws Exception { public void invalidRepositoryFormatVersion() throws Exception {
Repository r = createWorkRepository(); Repository r = createWorkRepository();
@ -99,6 +101,7 @@ public class FileRepositoryBuilderTest extends LocalDiskRepositoryTestCase {
} }
} }
@SuppressWarnings("unused")
@Test @Test
public void unknownRepositoryFormatVersion() throws Exception { public void unknownRepositoryFormatVersion() throws Exception {
Repository r = createWorkRepository(); Repository r = createWorkRepository();

9
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/RefUpdateTest.java

@ -558,7 +558,8 @@ public class RefUpdateTest extends SampleDataRepositoryTestCase {
assertEquals(ppid, db.resolve("refs/heads/master")); assertEquals(ppid, db.resolve("refs/heads/master"));
// real test // real test
RevCommit old = new RevWalk(db).parseCommit(ppid); try (RevWalk rw = new RevWalk(db)) {
RevCommit old = rw.parseCommit(ppid);
RefUpdate updateRef2 = db.updateRef("refs/heads/master"); RefUpdate updateRef2 = db.updateRef("refs/heads/master");
updateRef2.setExpectedOldObjectId(old); updateRef2.setExpectedOldObjectId(old);
updateRef2.setNewObjectId(pid); updateRef2.setNewObjectId(pid);
@ -566,6 +567,7 @@ public class RefUpdateTest extends SampleDataRepositoryTestCase {
assertEquals(Result.FAST_FORWARD, update2); assertEquals(Result.FAST_FORWARD, update2);
assertEquals(pid, db.resolve("refs/heads/master")); assertEquals(pid, db.resolve("refs/heads/master"));
} }
}
/** /**
* Try modify a ref that is locked * Try modify a ref that is locked
@ -707,10 +709,11 @@ public class RefUpdateTest extends SampleDataRepositoryTestCase {
// Create new Repository instance, to reread caches and make sure our // Create new Repository instance, to reread caches and make sure our
// assumptions are persistent. // assumptions are persistent.
Repository ndb = new FileRepository(db.getDirectory()); try (Repository ndb = new FileRepository(db.getDirectory())) {
assertEquals(rb2, ndb.resolve("refs/heads/new/name")); assertEquals(rb2, ndb.resolve("refs/heads/new/name"));
assertNull(ndb.resolve("refs/heads/b")); assertNull(ndb.resolve("refs/heads/b"));
} }
}
public void tryRenameWhenLocked(String toLock, String fromName, public void tryRenameWhenLocked(String toLock, String fromName,
String toName, String headPointsTo) throws IOException { String toName, String headPointsTo) throws IOException {
@ -751,7 +754,7 @@ public class RefUpdateTest extends SampleDataRepositoryTestCase {
assertNull(db.resolve(toName)); assertNull(db.resolve(toName));
assertEquals(oldFromLog.toString(), db.getReflogReader(fromName) assertEquals(oldFromLog.toString(), db.getReflogReader(fromName)
.getReverseEntries().toString()); .getReverseEntries().toString());
if (oldHeadId != null) if (oldHeadId != null && oldHeadLog != null)
assertEquals(oldHeadLog.toString(), db.getReflogReader( assertEquals(oldHeadLog.toString(), db.getReflogReader(
Constants.HEAD).getReverseEntries().toString()); Constants.HEAD).getReverseEntries().toString());
} finally { } finally {

1
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/T0003_BasicTest.java

@ -362,6 +362,7 @@ public class T0003_BasicTest extends SampleDataRepositoryTestCase {
assertNotSame(db.getConfig(), db2.getConfig()); assertNotSame(db.getConfig(), db2.getConfig());
} }
@SuppressWarnings("unused")
@Test @Test
public void test008_FailOnWrongVersion() throws IOException { public void test008_FailOnWrongVersion() throws IOException {
final File cfg = new File(db.getDirectory(), Constants.CONFIG); final File cfg = new File(db.getDirectory(), Constants.CONFIG);

2
org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/T0001_PersonIdentTest.java

@ -75,11 +75,13 @@ public class T0001_PersonIdentTest {
p.toExternalString()); p.toExternalString());
} }
@SuppressWarnings("unused")
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void nullForNameShouldThrowIllegalArgumentException() { public void nullForNameShouldThrowIllegalArgumentException() {
new PersonIdent(null, "author@example.com"); new PersonIdent(null, "author@example.com");
} }
@SuppressWarnings("unused")
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void nullForEmailShouldThrowIllegalArgumentException() { public void nullForEmailShouldThrowIllegalArgumentException() {
new PersonIdent("A U Thor", null); new PersonIdent("A U Thor", null);

2
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/SideBandOutputStreamTest.java

@ -195,6 +195,7 @@ public class SideBandOutputStreamTest {
assertEquals(1, flushCnt[0]); assertEquals(1, flushCnt[0]);
} }
@SuppressWarnings("unused")
@Test @Test
public void testConstructor_RejectsBadChannel() { public void testConstructor_RejectsBadChannel() {
try { try {
@ -220,6 +221,7 @@ public class SideBandOutputStreamTest {
} }
} }
@SuppressWarnings("unused")
@Test @Test
public void testConstructor_RejectsBadBufferSize() { public void testConstructor_RejectsBadBufferSize() {
try { try {

38
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/URIishTest.java

@ -51,7 +51,6 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull; import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -64,24 +63,16 @@ public class URIishTest {
private static final String GIT_SCHEME = "git://"; private static final String GIT_SCHEME = "git://";
@Test @SuppressWarnings("unused")
@Test(expected = URISyntaxException.class)
public void shouldRaiseErrorOnEmptyURI() throws Exception { public void shouldRaiseErrorOnEmptyURI() throws Exception {
try {
new URIish(""); new URIish("");
fail("expecting an exception");
} catch (URISyntaxException e) {
// expected
}
} }
@Test @SuppressWarnings("unused")
@Test(expected = URISyntaxException.class)
public void shouldRaiseErrorOnNullURI() throws Exception { public void shouldRaiseErrorOnNullURI() throws Exception {
try {
new URIish((String) null); new URIish((String) null);
fail("expecting an exception");
} catch (URISyntaxException e) {
// expected
}
} }
@Test @Test
@ -634,34 +625,19 @@ public class URIishTest {
assertEquals(u, new URIish(str)); assertEquals(u, new URIish(str));
} }
@Test @Test(expected = IllegalArgumentException.class)
public void testGetNullHumanishName() { public void testGetNullHumanishName() {
try {
new URIish().getHumanishName(); new URIish().getHumanishName();
fail("path must be not null");
} catch (IllegalArgumentException e) {
// expected
}
} }
@Test @Test(expected = IllegalArgumentException.class)
public void testGetEmptyHumanishName() throws URISyntaxException { public void testGetEmptyHumanishName() throws URISyntaxException {
try {
new URIish(GIT_SCHEME).getHumanishName(); new URIish(GIT_SCHEME).getHumanishName();
fail("empty path is useless");
} catch (IllegalArgumentException e) {
// expected
}
} }
@Test @Test(expected = IllegalArgumentException.class)
public void testGetAbsEmptyHumanishName() { public void testGetAbsEmptyHumanishName() {
try {
new URIish().getHumanishName(); new URIish().getHumanishName();
fail("empty path is useless");
} catch (IllegalArgumentException e) {
// expected
}
} }
@Test @Test

2
org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java

@ -179,7 +179,7 @@ public class CommitCommand extends GitCommand<RevCommit> {
processOptions(state, rw); processOptions(state, rw);
if (all && !repo.isBare() && repo.getWorkTree() != null) { if (all && !repo.isBare()) {
try (Git git = new Git(repo)) { try (Git git = new Git(repo)) {
git.add() git.add()
.addFilepattern(".") //$NON-NLS-1$ .addFilepattern(".") //$NON-NLS-1$

2
org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java

@ -715,7 +715,7 @@ public class URIish implements Serializable {
*/ */
public String getHumanishName() throws IllegalArgumentException { public String getHumanishName() throws IllegalArgumentException {
String s = getPath(); String s = getPath();
if ("/".equals(s) || "".equals(s)) //$NON-NLS-1$ if ("/".equals(s) || "".equals(s)) //$NON-NLS-1$ //$NON-NLS-2$
s = getHost(); s = getHost();
if (s == null) // $NON-NLS-1$ if (s == null) // $NON-NLS-1$
throw new IllegalArgumentException(); throw new IllegalArgumentException();

11
tools/version.sh

@ -144,17 +144,6 @@ perl -pi~ -e '
} }
' org.eclipse.jgit.packaging/org.*.feature/pom.xml ' 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 ' perl -pi~ -e '
if ($ARGV ne $old_argv) { if ($ARGV ne $old_argv) {
$seen_version = 0; $seen_version = 0;

Loading…
Cancel
Save