]> source.dussan.org Git - jgit.git/commitdiff
Repository: Deprecate #peel method 35/123035/2
authorDavid Pursehouse <david.pursehouse@gmail.com>
Tue, 22 May 2018 02:27:30 +0000 (11:27 +0900)
committerDavid Pursehouse <david.pursehouse@gmail.com>
Tue, 22 May 2018 02:49:37 +0000 (11:49 +0900)
Callers should use getRefDatabase().peel(ref) instead since it
doesn't swallow the IOException.

Adapt all trivial callers to user the alternative.

DescribeCommand still uses the deprecated method and is not adapted in
this change since it will require more refactoring to add handling of
the IOException.

Change-Id: I14d4a95a5e0570548753b9fc5c03d024dc3ff832
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildRefTree.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/LogCommandTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/TagCommandTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java
org.eclipse.jgit/src/org/eclipse/jgit/api/LogCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/RefAdvertiser.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java

index 86092b27a547c2e6aa8cee47e875712e092f6264..063600f4ea9923d24a4b14cec5e040e98c394934 100644 (file)
@@ -161,7 +161,7 @@ class RebuildRefTree extends TextBuiltin {
                        }
                        cmds.add(new org.eclipse.jgit.internal.storage.reftree.Command(
                                        null,
-                                       db.peel(r)));
+                                       db.getRefDatabase().peel(r)));
                }
                tree.apply(cmds);
                return tree;
index bd0efad016f986da397b0e55fa1d601646f3ebb0..4ef511e43d1e7fe5dcde31cacfcc166ef0740a99 100644 (file)
@@ -116,7 +116,7 @@ public class LogCommandTest extends RepositoryTestCase {
                Iterator<RevCommit> log = git.log().all().call().iterator();
                assertTrue(log.hasNext());
                RevCommit commit = log.next();
-               tag = db.peel(tag);
+               tag = db.getRefDatabase().peel(tag);
 
                assertEquals(commit.getName(), tag.getPeeledObjectId().getName());
                assertTrue(commits.contains(commit));
index 3b29a5bbfba8f48fb1a801ceb1a43eb8bb2c1819..a220e77e0eb74ef004d5421aa820afa72783f095 100644 (file)
@@ -67,19 +67,22 @@ public class TagCommandTest extends RepositoryTestCase {
                                RevWalk walk = new RevWalk(db)) {
                        RevCommit commit = git.commit().setMessage("initial commit").call();
                        Ref tagRef = git.tag().setName("tag").call();
-                       assertEquals(commit.getId(), db.peel(tagRef).getPeeledObjectId());
+                       assertEquals(commit.getId(),
+                                       db.getRefDatabase().peel(tagRef).getPeeledObjectId());
                        assertEquals("tag", walk.parseTag(tagRef.getObjectId()).getTagName());
                }
        }
 
        @Test
-       public void testTagging() throws GitAPIException, JGitInternalException {
+       public void testTagging()
+                       throws GitAPIException, JGitInternalException, IOException {
                try (Git git = new Git(db)) {
                        git.commit().setMessage("initial commit").call();
                        RevCommit commit = git.commit().setMessage("second commit").call();
                        git.commit().setMessage("third commit").call();
                        Ref tagRef = git.tag().setObjectId(commit).setName("tag").call();
-                       assertEquals(commit.getId(), db.peel(tagRef).getPeeledObjectId());
+                       assertEquals(commit.getId(),
+                                       db.getRefDatabase().peel(tagRef).getPeeledObjectId());
                }
        }
 
index fa45214f0c8270ff462d55f7f3e75b23f2ed49fc..df31ab08690d89ccf3343943bdb984560fd0178d 100644 (file)
@@ -160,7 +160,7 @@ public class RepoCommandTest extends RepositoryTestCase {
                                Ref ref = r.findRef(refname);
                                if (ref == null) return null;
 
-                               ref = r.peel(ref);
+                               ref = r.getRefDatabase().peel(ref);
                                ObjectId id = ref.getObjectId();
                                return id;
                        } catch (IOException e) {
index cdf8cdd8d785f2811668a509dccfa62a094efa69..cf3d35fe8952c4f89201b1d25d9f946ff9f8cc46 100644 (file)
@@ -274,7 +274,7 @@ public class LogCommand extends GitCommand<Iterable<RevCommit>> {
        public LogCommand all() throws IOException {
                for (Ref ref : getRepository().getRefDatabase().getRefs()) {
                        if(!ref.isPeeled())
-                               ref = getRepository().peel(ref);
+                               ref = getRepository().getRefDatabase().peel(ref);
 
                        ObjectId objectId = ref.getPeeledObjectId();
                        if (objectId == null)
index c8a9049e6c36a6fe65923781d0cfb0aabd5a82d5..b8fa74de79b5069a05f3bc6574cf54b5971a832f 100644 (file)
@@ -255,7 +255,7 @@ public class MergeCommand extends GitCommand<MergeResult> {
                        refLogMessage.append(ref.getName());
 
                        // handle annotated tags
-                       ref = repo.peel(ref);
+                       ref = repo.getRefDatabase().peel(ref);
                        ObjectId objectId = ref.getPeeledObjectId();
                        if (objectId == null)
                                objectId = ref.getObjectId();
index 5fb4e40084611fd19a03d03339675c6cf534f7db..fa283d01290d45ecf82a4e4db34e0f915638b766 100644 (file)
@@ -1133,7 +1133,9 @@ public abstract class Repository implements AutoCloseable {
         *         new Ref object representing the same data as Ref, but isPeeled()
         *         will be true and getPeeledObjectId will contain the peeled object
         *         (or null).
+        * @deprecated use {@code getRefDatabase().peel(ref)} instead.
         */
+       @Deprecated
        @NonNull
        public Ref peel(Ref ref) {
                try {
index 1bde49df29429dbd5e61831a162b50bd7a4ee29e..dc1871b729821253be8c16b96d101b4e9e1848f3 100644 (file)
@@ -322,7 +322,7 @@ public abstract class RefAdvertiser {
                                String peelPart = ""; //$NON-NLS-1$
                                if (derefTags) {
                                        if (!ref.isPeeled() && repository != null) {
-                                               ref = repository.peel(ref);
+                                               ref = repository.getRefDatabase().peel(ref);
                                        }
                                        ObjectId peeledObjectId = ref.getPeeledObjectId();
                                        if (peeledObjectId != null) {
@@ -342,7 +342,7 @@ public abstract class RefAdvertiser {
                        if (!ref.isPeeled()) {
                                if (repository == null)
                                        continue;
-                               ref = repository.peel(ref);
+                               ref = repository.getRefDatabase().peel(ref);
                        }
 
                        if (ref.getPeeledObjectId() != null)
index 3d4d279a51441ee6e3faf17421ab4406ccc6e4f5..82e6e62f0f2634d059fba1aa53a75785dbe93b02 100644 (file)
@@ -1932,7 +1932,7 @@ public class UploadPack {
                                        }
 
                                        if (!ref.isPeeled())
-                                               ref = db.peel(ref);
+                                               ref = db.getRefDatabase().peel(ref);
 
                                        ObjectId peeledId = ref.getPeeledObjectId();
                                        objectId = ref.getObjectId();