* [PATCH JGIT 5/5] Treat gitlink tree entries similar to symlink tree entries
@ 2009-08-12 15:07 Jonas Fonseca
2009-08-12 15:32 ` Shawn O. Pearce
0 siblings, 1 reply; 3+ messages in thread
From: Jonas Fonseca @ 2009-08-12 15:07 UTC (permalink / raw)
To: Robin Rosenberg, Shawn O. Pearce; +Cc: git
Adds minimal support for gitlinks, based on the existing code for
handling symlinks. The goal is to avoid exceptions when reading trees
with gitlinks.
Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
---
.../jgit/errors/GitlinksNotSupportedException.java | 58 +++++++++++++
.../src/org/spearce/jgit/lib/ForceModified.java | 4 +
.../src/org/spearce/jgit/lib/GitlinkTreeEntry.java | 85 ++++++++++++++++++++
.../src/org/spearce/jgit/lib/TreeVisitor.java | 8 ++
.../src/org/spearce/jgit/lib/WriteTree.java | 7 ++
5 files changed, 162 insertions(+), 0 deletions(-)
create mode 100644 org.spearce.jgit/src/org/spearce/jgit/errors/GitlinksNotSupportedException.java
create mode 100644 org.spearce.jgit/src/org/spearce/jgit/lib/GitlinkTreeEntry.java
diff --git a/org.spearce.jgit/src/org/spearce/jgit/errors/GitlinksNotSupportedException.java b/org.spearce.jgit/src/org/spearce/jgit/errors/GitlinksNotSupportedException.java
new file mode 100644
index 0000000..8f8883f
--- /dev/null
+++ b/org.spearce.jgit/src/org/spearce/jgit/errors/GitlinksNotSupportedException.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2007, Robin Rosenberg <robin.rosenberg@dewire.com>
+ * Copyright (C) 2007, Shawn O. Pearce <spearce@spearce.org>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * - Neither the name of the Git Development Community nor the
+ * names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.spearce.jgit.errors;
+
+import java.io.IOException;
+
+/**
+ * An exception thrown when a gitlink entry is found and cannot be
+ * handled.
+ */
+public class GitlinksNotSupportedException extends IOException {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Construct a GitlinksNotSupportedException for the specified link
+ *
+ * @param s name of link in tree or workdir
+ */
+ public GitlinksNotSupportedException(final String s) {
+ super(s);
+ }
+}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/ForceModified.java b/org.spearce.jgit/src/org/spearce/jgit/lib/ForceModified.java
index 6d38068..9c94e13 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/ForceModified.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/ForceModified.java
@@ -61,4 +61,8 @@ public void visitSymlink(final SymlinkTreeEntry s) throws IOException {
// Eclipse
// and Pure Java does not know what to do about symbolic links.
}
+
+ public void visitGitlink(GitlinkTreeEntry s) throws IOException {
+ // TODO: handle gitlinks.
+ }
}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/GitlinkTreeEntry.java b/org.spearce.jgit/src/org/spearce/jgit/lib/GitlinkTreeEntry.java
new file mode 100644
index 0000000..babbc26
--- /dev/null
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/GitlinkTreeEntry.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2007, Robin Rosenberg <robin.rosenberg@dewire.com>
+ * Copyright (C) 2007, Shawn O. Pearce <spearce@spearce.org>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * - Neither the name of the Git Development Community nor the
+ * names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.spearce.jgit.lib;
+
+import java.io.IOException;
+
+/**
+ * A tree entry representing a symbolic link.
+ *
+ * Note. Java cannot really handle these as file system objects.
+ */
+public class GitlinkTreeEntry extends TreeEntry {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Construct a {@link SymlinkTreeEntry} with the specified name and SHA-1 in
+ * the specified parent
+ *
+ * @param parent
+ * @param id
+ * @param nameUTF8
+ */
+ public GitlinkTreeEntry(final Tree parent, final ObjectId id,
+ final byte[] nameUTF8) {
+ super(parent, id, nameUTF8);
+ }
+
+ public FileMode getMode() {
+ return FileMode.GITLINK;
+ }
+
+ public void accept(final TreeVisitor tv, final int flags)
+ throws IOException {
+ if ((MODIFIED_ONLY & flags) == MODIFIED_ONLY && !isModified()) {
+ return;
+ }
+
+ tv.visitGitlink(this);
+ }
+
+ @Override
+ public String toString() {
+ final StringBuffer r = new StringBuffer();
+ r.append(ObjectId.toString(getId()));
+ r.append(" G ");
+ r.append(getFullName());
+ return r.toString();
+ }
+}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/TreeVisitor.java b/org.spearce.jgit/src/org/spearce/jgit/lib/TreeVisitor.java
index 78a6c22..8293c24 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/TreeVisitor.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/TreeVisitor.java
@@ -77,4 +77,12 @@
* @throws IOException
*/
public void visitSymlink(final SymlinkTreeEntry s) throws IOException;
+
+ /**
+ * Visit to a gitlink.
+ *
+ * @param s Gitlink entry
+ * @throws IOException
+ */
+ public void visitGitlink(final GitlinkTreeEntry s) throws IOException;
}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/WriteTree.java b/org.spearce.jgit/src/org/spearce/jgit/lib/WriteTree.java
index 9841678..d6725a9 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/WriteTree.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/WriteTree.java
@@ -41,6 +41,7 @@
import java.io.File;
import java.io.IOException;
+import org.spearce.jgit.errors.GitlinksNotSupportedException;
import org.spearce.jgit.errors.SymlinksNotSupportedException;
/**
@@ -78,4 +79,10 @@ public void endVisitTree(final Tree t) throws IOException {
super.endVisitTree(t);
t.setId(ow.writeTree(t));
}
+
+ public void visitGitlink(GitlinkTreeEntry s) throws IOException {
+ if (s.isModified()) {
+ throw new GitlinksNotSupportedException(s.getFullName());
+ }
+ }
}
--
1.6.4.rc3.195.g2b05f
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH JGIT 5/5] Treat gitlink tree entries similar to symlink tree entries
2009-08-12 15:07 [PATCH JGIT 5/5] Treat gitlink tree entries similar to symlink tree entries Jonas Fonseca
@ 2009-08-12 15:32 ` Shawn O. Pearce
2009-08-12 17:30 ` [PATCH JGIT] Recognize gitlink tree entries when mapping a tree Jonas Fonseca
0 siblings, 1 reply; 3+ messages in thread
From: Shawn O. Pearce @ 2009-08-12 15:32 UTC (permalink / raw)
To: Jonas Fonseca; +Cc: Robin Rosenberg, git
Jonas Fonseca <fonseca@diku.dk> wrote:
> Adds minimal support for gitlinks, based on the existing code for
> handling symlinks. The goal is to avoid exceptions when reading trees
> with gitlinks.
Applied, but who calls GitlinkTreeEntry ?
> .../jgit/errors/GitlinksNotSupportedException.java | 58 +++++++++++++
> .../src/org/spearce/jgit/lib/ForceModified.java | 4 +
> .../src/org/spearce/jgit/lib/GitlinkTreeEntry.java | 85 ++++++++++++++++++++
> .../src/org/spearce/jgit/lib/TreeVisitor.java | 8 ++
> .../src/org/spearce/jgit/lib/WriteTree.java | 7 ++
> 5 files changed, 162 insertions(+), 0 deletions(-)
> create mode 100644 org.spearce.jgit/src/org/spearce/jgit/errors/GitlinksNotSupportedException.java
> create mode 100644 org.spearce.jgit/src/org/spearce/jgit/lib/GitlinkTreeEntry.java
--
Shawn.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH JGIT] Recognize gitlink tree entries when mapping a tree
2009-08-12 15:32 ` Shawn O. Pearce
@ 2009-08-12 17:30 ` Jonas Fonseca
0 siblings, 0 replies; 3+ messages in thread
From: Jonas Fonseca @ 2009-08-12 17:30 UTC (permalink / raw)
To: Robin Rosenberg, Shawn O. Pearce; +Cc: git
Also adds minimal testing of symlink and gitlink tree entries and amends
gitlink related javadoc.
Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
---
On Wed, Aug 12, 2009 at 11:32, Shawn O. Pearce<spearce@spearce.org> wrote:
> Jonas Fonseca <fonseca@diku.dk> wrote:
>> Adds minimal support for gitlinks, based on the existing code for
>> handling symlinks. The goal is to avoid exceptions when reading trees
>> with gitlinks.
>
> Applied, but who calls GitlinkTreeEntry ?
True, here is a follow up, which should fix this. With this the Netbeans
module no longer dumps stack traces when dealing with a repository containing
submodules.
.../spearce/jgit/test/resources/create-second-pack | 13 ++++++++++++-
...ck-cbdeda40019ae0e6e789088ea0f51f164f489d14.idx | Bin 0 -> 1240 bytes
...k-cbdeda40019ae0e6e789088ea0f51f164f489d14.pack | Bin 0 -> 651 bytes
.../org/spearce/jgit/test/resources/packed-refs | 2 ++
.../org/spearce/jgit/lib/RepositoryTestCase.java | 1 +
.../tst/org/spearce/jgit/lib/T0002_Tree.java | 7 +++++++
.../org/spearce/jgit/transport/TransportTest.java | 2 +-
.../src/org/spearce/jgit/lib/GitlinkTreeEntry.java | 2 +-
.../src/org/spearce/jgit/lib/Tree.java | 14 ++++++++------
.../src/org/spearce/jgit/lib/TreeEntry.java | 2 +-
10 files changed, 33 insertions(+), 10 deletions(-)
create mode 100644 org.spearce.jgit.test/tst-rsrc/org/spearce/jgit/test/resources/pack-cbdeda40019ae0e6e789088ea0f51f164f489d14.idx
create mode 100644 org.spearce.jgit.test/tst-rsrc/org/spearce/jgit/test/resources/pack-cbdeda40019ae0e6e789088ea0f51f164f489d14.pack
diff --git a/org.spearce.jgit.test/tst-rsrc/org/spearce/jgit/test/resources/create-second-pack b/org.spearce.jgit.test/tst-rsrc/org/spearce/jgit/test/resources/create-second-pack
index 5501a67..7241fa6 100755
--- a/org.spearce.jgit.test/tst-rsrc/org/spearce/jgit/test/resources/create-second-pack
+++ b/org.spearce.jgit.test/tst-rsrc/org/spearce/jgit/test/resources/create-second-pack
@@ -148,8 +148,19 @@ mkdir f
echo "an F" >f/f
git add f/f
git commit -m "An F"
+
git repack -d
-git pack-refs --all
+git checkout -b symlink master
+ln -s c/c1.txt symlink.txt
+git add symlink.txt
+git_commit -m "A symlink"
+
+git checkout -b gitlink master
+git submodule add "$(pwd)/.git" submodule
+git_commit -m "A gitlink"
+
+git repack -d
+git pack-refs --all
gitk --all master
diff --git a/org.spearce.jgit.test/tst-rsrc/org/spearce/jgit/test/resources/pack-cbdeda40019ae0e6e789088ea0f51f164f489d14.idx b/org.spearce.jgit.test/tst-rsrc/org/spearce/jgit/test/resources/pack-cbdeda40019ae0e6e789088ea0f51f164f489d14.idx
new file mode 100644
index 0000000000000000000000000000000000000000..a5aed7def26f945bc329429195702b6c5f82444e
GIT binary patch
literal 1240
zcmexg;-AdGz`z8=LlH0n9X(VqD2$OYGmwuBvjD}hVOF5{D5h^1umQt-L||Q(cO|zM
zGgKV9bGy*?cK4G#9KK}{MLm<dW_8ajIK!!&vwq6jB^fi7V;(SYoVVZcamrV9CnoMI
zycM56ZcfsiRrP4XwN}ZzDP8)fYkSy##?)q<mRHtH`Fu9B>yPaEr_Ga#n2)v}U9D~~
zW#ai1xsB3Wwl8mU{M4|e>CBhT@0-kPc{h9$XyamDB^6LtD7$dd;$mP{Ndso>L%{G~
z3Zy}KoCheTvs+fx_VNdg(i1Ef@{3<GG~MPrAv_`8pq2B=iun8P36r;N{?oH6s!a+2
Df+%BI
literal 0
HcmV?d00001
diff --git a/org.spearce.jgit.test/tst-rsrc/org/spearce/jgit/test/resources/pack-cbdeda40019ae0e6e789088ea0f51f164f489d14.pack b/org.spearce.jgit.test/tst-rsrc/org/spearce/jgit/test/resources/pack-cbdeda40019ae0e6e789088ea0f51f164f489d14.pack
new file mode 100644
index 0000000000000000000000000000000000000000..24f69429a0fa4f206a7e6481e17fd0e11725c219
GIT binary patch
literal 651
zcmV;60(AXQK|@Ob00062000J@4S1ZL%UcS<Fc5{|_pBltu;kKaG9Y62pbMBxrdsTc
zl7h=O-GXn2|L~PvL<i>(2}m589AalN2)2>jzzK3>0|RypS#7k-Qgn;nxs)tqPt0iB
zFkobaY@p)$#gqomM$u8;>#lqK)Q@vqsX3Z6-Q`R3Hc7+leACuiht+jnUkn(dYMsYY
z<PWNP{Tj<OE+6#+d)Pm+;RS#hc$~Y#c!yE9q$o92A=xxB$;jN;z|zFhFgeZ4#4t6<
z&@d^<B*{F{+ycl=GqNy9GO;k4s2k5@XgRUZQq<7WSV7mo+`xc~%Tb}YGB+nPFPjSh
z!RHoirVMzTGc+(TGci%nOV2FH%}*)KNiAlGDC(KqHLH7O!5L2Fob^-IF3FgwY+?We
z3W*F{w&g`0-Pr>9+cboaT)U<|v3Fu4L@tRzfaSvVHEO@V83ZgcIk}_DjXhlQGDI$!
z!Sm>kK!>~rmK|a{#QF0j9`n5@-)RW3IybSnB(+Gdq@skOY2$^Kw3h+#ZE4#pO8jS;
z6fWm!G&BPnQCyk?aUX-Hk@m(~t1}bbe)deiP!VXPvHSA@0OH(DH@paVoIT1x4uBvG
zMA5aJg1DESz>^pkh!r(xO<V3SsBt%We+J3ZL32)M+kdvBX)dp;?d@--$(#znN(aJ1
zr(p0P9AJ-|0&#S5q33|Ef>RU)745iwN`^1L|0gpF<w63kn7IMT$}+U>0)Z=doIA$2
zka41VwVIIu5GWK^=H_JPW$TqxlrZSByeqlAn4#j(o!f=Bx4WP0;qWa30EL1Q>o|Cv
lOV&>|)GMhd0RRgq0=2sxB|X#d2zAH=&~J0;0D{{I$P-a{H+%p9
literal 0
HcmV?d00001
diff --git a/org.spearce.jgit.test/tst-rsrc/org/spearce/jgit/test/resources/packed-refs b/org.spearce.jgit.test/tst-rsrc/org/spearce/jgit/test/resources/packed-refs
index a6a14f2..82fb0d7 100644
--- a/org.spearce.jgit.test/tst-rsrc/org/spearce/jgit/test/resources/packed-refs
+++ b/org.spearce.jgit.test/tst-rsrc/org/spearce/jgit/test/resources/packed-refs
@@ -7,8 +7,10 @@ d0114ab8ac326bab30e3a657a0397578c5a1af88 refs/heads/e
47d3697c3747e8184e0dc479ccbd01e359023577 refs/heads/f
175d5b80bd9768884d8fced02e9bd33488174396 refs/heads/g
175d5b80bd9768884d8fced02e9bd33488174396 refs/heads/prefix/a
+68cb1f232964f3cd698afc1dafe583937203c587 refs/heads/gitlink
49322bb17d3acc9146f98c97d078513228bbf3c0 refs/heads/master
d86a2aada2f5e7ccf6f11880bfb9ab404e8a8864 refs/heads/pa
+5ce00008cf3fb8f194f52742020bd40d78f3f1b3 refs/heads/symlink
6db9c2ebf75590eef973081736730a9ea169a0c4 refs/tags/A
17768080a2318cd89bba4c8b87834401e2095703 refs/tags/B
^d86a2aada2f5e7ccf6f11880bfb9ab404e8a8864
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/RepositoryTestCase.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/RepositoryTestCase.java
index 6de9afe..b1adde9 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/RepositoryTestCase.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/RepositoryTestCase.java
@@ -249,6 +249,7 @@ public void run() {
"pack-df2982f284bbabb6bdb59ee3fcc6eb0983e20371",
"pack-9fb5b411fe6dfa89cc2e6b89d2bd8e5de02b5745",
"pack-546ff360fe3488adb20860ce3436a2d6373d2796",
+ "pack-cbdeda40019ae0e6e789088ea0f51f164f489d14",
"pack-e6d07037cbcf13376308a0a995d1fa48f8f76aaa",
"pack-3280af9c07ee18a87705ef50b0cc4cd20266cf12"
};
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/T0002_Tree.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/T0002_Tree.java
index 97f299c..febcbc6 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/T0002_Tree.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/T0002_Tree.java
@@ -271,4 +271,11 @@ public void test008_SubtreeInternalSorting() throws IOException {
assertSame(e4, ents[3]);
assertSame(e2, ents[4]);
}
+
+ public void test009_SymlinkAndGitlink() throws IOException {
+ final Tree symlinkTree = db.mapTree("symlink");
+ assertTrue("Symlink entry exists", symlinkTree.existsBlob("symlink.txt"));
+ final Tree gitlinkTree = db.mapTree("gitlink");
+ assertTrue("Gitlink entry exists", gitlinkTree.existsBlob("submodule"));
+ }
}
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/transport/TransportTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/transport/TransportTest.java
index fcf3f5c..c6bd13d 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/transport/TransportTest.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/transport/TransportTest.java
@@ -123,7 +123,7 @@ public void testFindRemoteRefUpdatesWildcardNoTracking() throws IOException {
.findRemoteRefUpdatesFor(Collections.nCopies(1, new RefSpec(
"+refs/heads/*:refs/heads/test/*")));
- assertEquals(10, result.size());
+ assertEquals(12, result.size());
boolean foundA = false;
boolean foundB = false;
for (final RemoteRefUpdate rru : result) {
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/GitlinkTreeEntry.java b/org.spearce.jgit/src/org/spearce/jgit/lib/GitlinkTreeEntry.java
index db6a8e2..5cabbd6 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/GitlinkTreeEntry.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/GitlinkTreeEntry.java
@@ -42,7 +42,7 @@
import java.io.IOException;
/**
- * A tree entry representing a symbolic link.
+ * A tree entry representing a gitlink entry used for submodules.
*
* Note. Java cannot really handle these as file system objects.
*/
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/Tree.java b/org.spearce.jgit/src/org/spearce/jgit/lib/Tree.java
index ff9e666..291fce8 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/Tree.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/Tree.java
@@ -428,7 +428,7 @@ private boolean exists(final String s, byte slast) throws IOException {
}
/**
- * @param path
+ * @param path to the tree.
* @return true if a tree with the specified path can be found under this
* tree.
* @throws IOException
@@ -438,9 +438,9 @@ public boolean existsTree(String path) throws IOException {
}
/**
- * @param path
- * @return true if a blob or symlink with the specified name can be found
- * under this tree.
+ * @param path of the non-tree entry.
+ * @return true if a blob, symlink, or gitlink with the specified name
+ * can be found under this tree.
* @throws IOException
*/
public boolean existsBlob(String path) throws IOException {
@@ -576,10 +576,12 @@ else if (c < '0' || c > '7')
ent = new FileTreeEntry(this, id, name, false);
else if (FileMode.EXECUTABLE_FILE.equals(mode))
ent = new FileTreeEntry(this, id, name, true);
- else if (FileMode.TREE.equals(mode)) {
+ else if (FileMode.TREE.equals(mode))
ent = new Tree(this, id, name);
- } else if (FileMode.SYMLINK.equals(mode))
+ else if (FileMode.SYMLINK.equals(mode))
ent = new SymlinkTreeEntry(this, id, name);
+ else if (FileMode.GITLINK.equals(mode))
+ ent = new GitlinkTreeEntry(this, id, name);
else
throw new CorruptObjectException(getId(), "Invalid mode: "
+ Integer.toOctalString(mode));
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/TreeEntry.java b/org.spearce.jgit/src/org/spearce/jgit/lib/TreeEntry.java
index c95863c..4921c7a 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/TreeEntry.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/TreeEntry.java
@@ -232,7 +232,7 @@ public int compareTo(final Object o) {
* @return '/' for Tree entries and NUL for non-treeish objects.
*/
final public static int lastChar(TreeEntry treeEntry) {
- if (treeEntry instanceof FileTreeEntry)
+ if (!(treeEntry instanceof Tree))
return '\0';
else
return '/';
--
1.6.4.rc3.195.g2b05f
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-08-12 17:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-12 15:07 [PATCH JGIT 5/5] Treat gitlink tree entries similar to symlink tree entries Jonas Fonseca
2009-08-12 15:32 ` Shawn O. Pearce
2009-08-12 17:30 ` [PATCH JGIT] Recognize gitlink tree entries when mapping a tree Jonas Fonseca
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.