2 * Copyright (C) 2008, Robin Rosenberg <robin.rosenberg@dewire.com>
3 * Copyright (C) 2006, Shawn O. Pearce <spearce@spearce.org>
7 * Redistribution and use in source and binary forms, with or
8 * without modification, are permitted provided that the following
11 * - Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
14 * - Redistributions in binary form must reproduce the above
15 * copyright notice, this list of conditions and the following
16 * disclaimer in the documentation and/or other materials provided
17 * with the distribution.
19 * - Neither the name of the Git Development Community nor the
20 * names of its contributors may be used to endorse or promote
21 * products derived from this software without specific prior
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
25 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
26 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
27 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
29 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
31 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
34 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
36 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 package org
.spearce
.jgit
.lib
;
41 import java
.io
.IOException
;
43 public class T0008_testparserev
extends RepositoryTestCase
{
45 public void testObjectId_existing() throws IOException
{
46 assertEquals("49322bb17d3acc9146f98c97d078513228bbf3c0",db
.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0").toString());
49 public void testObjectId_nonexisting() throws IOException
{
50 assertEquals("49322bb17d3acc9146f98c97d078513228bbf3c1",db
.resolve("49322bb17d3acc9146f98c97d078513228bbf3c1").toString());
53 public void testObjectId_objectid_implicit_firstparent() throws IOException
{
54 assertEquals("6e1475206e57110fcef4b92320436c1e9872a322",db
.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0^").toString());
55 assertEquals("1203b03dc816ccbb67773f28b3c19318654b0bc8",db
.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0^^").toString());
56 assertEquals("bab66b48f836ed950c99134ef666436fb07a09a0",db
.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0^^^").toString());
59 public void testObjectId_objectid_self() throws IOException
{
60 assertEquals("49322bb17d3acc9146f98c97d078513228bbf3c0",db
.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0^0").toString());
61 assertEquals("49322bb17d3acc9146f98c97d078513228bbf3c0",db
.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0^0^0").toString());
62 assertEquals("49322bb17d3acc9146f98c97d078513228bbf3c0",db
.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0^0^0^0").toString());
65 public void testObjectId_objectid_explicit_firstparent() throws IOException
{
66 assertEquals("6e1475206e57110fcef4b92320436c1e9872a322",db
.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0^1").toString());
67 assertEquals("1203b03dc816ccbb67773f28b3c19318654b0bc8",db
.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0^1^1").toString());
68 assertEquals("bab66b48f836ed950c99134ef666436fb07a09a0",db
.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0^1^1^1").toString());
71 public void testObjectId_objectid_explicit_otherparents() throws IOException
{
72 assertEquals("6e1475206e57110fcef4b92320436c1e9872a322",db
.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0^1").toString());
73 assertEquals("f73b95671f326616d66b2afb3bdfcdbbce110b44",db
.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0^2").toString());
74 assertEquals("d0114ab8ac326bab30e3a657a0397578c5a1af88",db
.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0^3").toString());
75 assertEquals("d0114ab8ac326bab30e3a657a0397578c5a1af88",db
.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0^03").toString());
78 public void testRef_refname() throws IOException
{
79 assertEquals("49322bb17d3acc9146f98c97d078513228bbf3c0",db
.resolve("master^0").toString());
80 assertEquals("6e1475206e57110fcef4b92320436c1e9872a322",db
.resolve("master^").toString());
81 assertEquals("6e1475206e57110fcef4b92320436c1e9872a322",db
.resolve("refs/heads/master^1").toString());
84 public void testDistance() throws IOException
{
85 assertEquals("6e1475206e57110fcef4b92320436c1e9872a322",db
.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0~0").toString());
86 assertEquals("1203b03dc816ccbb67773f28b3c19318654b0bc8",db
.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0~1").toString());
87 assertEquals("bab66b48f836ed950c99134ef666436fb07a09a0",db
.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0~2").toString());
88 assertEquals("bab66b48f836ed950c99134ef666436fb07a09a0",db
.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0~02").toString());
91 public void testTree() throws IOException
{
92 assertEquals("6020a3b8d5d636e549ccbd0c53e2764684bb3125",db
.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0^{tree}").toString());
93 assertEquals("02ba32d3649e510002c21651936b7077aa75ffa9",db
.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0^^{tree}").toString());
96 public void testHEAD() throws IOException
{
97 assertEquals("6020a3b8d5d636e549ccbd0c53e2764684bb3125",db
.resolve("HEAD^{tree}").toString());
100 public void testDerefCommit() throws IOException
{
101 assertEquals("49322bb17d3acc9146f98c97d078513228bbf3c0",db
.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0^{}").toString());
102 assertEquals("49322bb17d3acc9146f98c97d078513228bbf3c0",db
.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0^{commit}").toString());
104 assertEquals("6020a3b8d5d636e549ccbd0c53e2764684bb3125",db
.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0^{commit}^{tree}").toString());
107 public void testDerefTag() throws IOException
{
108 assertEquals("fd608fbe625a2b456d9f15c2b1dc41f252057dd7",db
.resolve("spearce-gpg-pub^{}").toString());
109 assertEquals("fd608fbe625a2b456d9f15c2b1dc41f252057dd7",db
.resolve("spearce-gpg-pub^{blob}").toString());
112 public void testDerefBlob() throws IOException
{
113 assertEquals("fd608fbe625a2b456d9f15c2b1dc41f252057dd7",db
.resolve("fd608fbe625a2b456d9f15c2b1dc41f252057dd7^{}").toString());
114 assertEquals("fd608fbe625a2b456d9f15c2b1dc41f252057dd7",db
.resolve("fd608fbe625a2b456d9f15c2b1dc41f252057dd7^{blob}").toString());
117 // TODO: ^{tree} for a tag pointing to a tag