]> source.dussan.org Git - jgit.git/commitdiff
Merge branch 'stable-4.2' 11/64711/1
authorDavid Pursehouse <david.pursehouse@sonymobile.com>
Wed, 20 Jan 2016 00:32:19 +0000 (09:32 +0900)
committerDavid Pursehouse <david.pursehouse@sonymobile.com>
Wed, 20 Jan 2016 00:45:48 +0000 (09:45 +0900)
* 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>
1  2 
org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/BranchTest.java
org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/CheckoutTest.java
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Reset.java
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevParse.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileRepositoryBuilderTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/T0003_BasicTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/URIishTest.java
org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java

index f1a53d7dcc452e49c30449600406364f83c750b2,d1bd5bacebe49a238454947a5ca768658aad4cae..55f4d8b1b8c939bb084f21ea1124a27c0b1e59a5
@@@ -63,23 -57,15 +63,25 @@@ public class BranchTest extends CLIRepo
        @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
 +      public void testHelpAfterDelete() throws Exception {
 +              String err = toString(executeUnchecked("git branch -d"));
 +              String help = toString(executeUnchecked("git branch -h"));
 +              String errAndHelp = toString(executeUnchecked("git branch -d -h"));
 +              assertEquals(CLIText.fatalError(CLIText.get().branchNameRequired), err);
 +              assertEquals(toString(err, help), errAndHelp);
 +      }
 +
        @Test
        public void testList() throws Exception {
 +              assertEquals("* master", toString(execute("git branch")));
                assertEquals("* master 6fd41be initial commit",
 -                              execute("git branch -v")[0]);
 +                              toString(execute("git branch -v")));
        }
  
        @Test
  
        @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();
++                      git.branchCreate().setName("initial").call();
+                       RevCommit second = git.commit().setMessage("second commit")
+                                       .call();
 -                      assertArrayOfLinesEquals(new String[] { "  initial", "* master", "" },
 -                                      execute("git branch --contains 6fd41be"));
 -                      assertArrayOfLinesEquals(new String[] { "* master", "" },
 -                                      execute("git branch --contains " + second.name()));
++                      assertEquals(toString("  initial", "* master"),
++                                      toString(execute("git branch --contains 6fd41be")));
++                      assertEquals("* master",
++                                      toString(execute("git branch --contains " + second.name())));
+               }
        }
  
        @Test
index 6175b6c06ac6c71628e768065849f19b29d143f1,cb36d057e4bef1336e031f395bac8e9117cc8c3b..e690ad696427ee610b717938f1a4e107b809b6a9
@@@ -105,11 -104,13 +111,13 @@@ public class CheckoutTest extends CLIRe
  
        @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.",
 -                                      execute("git checkout -b master"));
 +                              executeUnchecked("git checkout -b master"));
+               }
        }
  
        @Test
  
        @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
 +      public void testCheckouSingleFile() throws Exception {
 +              try (Git git = new Git(db)) {
 +                      File a = writeTrashFile("a", "file a");
 +                      git.add().addFilepattern(".").call();
 +                      git.commit().setMessage("commit file a").call();
 +                      writeTrashFile("a", "b");
 +                      assertEquals("b", read(a));
 +                      assertEquals("[]", Arrays.toString(execute("git checkout -- a")));
 +                      assertEquals("file a", read(a));
 +              }
 +      }
 +
 +      @Test
 +      public void testCheckoutLink() throws Exception {
 +              Assume.assumeTrue(FS.DETECTED.supportsSymlinks());
 +              try (Git git = new Git(db)) {
 +                      Path path = writeLink("a", "link_a");
 +                      assertTrue(Files.isSymbolicLink(path));
 +                      git.add().addFilepattern(".").call();
 +                      git.commit().setMessage("commit link a").call();
 +                      deleteTrashFile("a");
 +                      writeTrashFile("a", "Hello world a");
 +                      assertFalse(Files.isSymbolicLink(path));
 +                      assertEquals("[]", Arrays.toString(execute("git checkout -- a")));
 +                      assertEquals("link_a", FileUtils.readSymLink(path.toFile()));
 +                      assertTrue(Files.isSymbolicLink(path));
 +              }
 +      }
  }