Update JGit to 0.5.1.140-g660fd39

This is very close to what will eventually be the 0.7.0 release
from the Eclipse.org domain.

It resolves both issues 304 and 399 for us.  Issue 304 was about
not reporting "git not found" during replication when git was not
in the remote user's $PATH.  Issue 399 was about JGit rejecting
older format annotated tag objects, where the tagger was missing.
The Linux kernel is one such project with old tags like this,
which made it hard to work with the kernel in Gerrit.

Bug: issue 304
Bug: issue 399
Change-Id: Icb6252fa549a1814c0334332750552d531fdc0bf
Signed-off-by: Shawn O. Pearce <sop@google.com>
Reviewed-by: Nico Sallembien <nsallembien@google.com>
This commit is contained in:
Shawn O. Pearce
2010-01-29 10:56:13 -08:00
parent efd9cfe648
commit d0a46c3a3d
5 changed files with 27 additions and 23 deletions

View File

@@ -70,14 +70,14 @@ class ListBranches extends Handler<List<Branch>> {
final Map<String, Ref> all = db.getAllRefs();
if (!all.containsKey(Constants.HEAD)) {
// The branch pointed to by HEAD doesn't exist yet. Fake
// that it exists by returning a Ref with no ObjectId.
// The branch pointed to by HEAD doesn't exist yet, so getAllRefs
// filtered it out. If we ask for it individually we can find the
// underlying target and put it into the map anyway.
//
try {
final String head = db.getFullBranch();
if (head != null && head.startsWith(Constants.R_REFS)) {
all.put(Constants.HEAD, new Ref(Ref.Storage.LOOSE, Constants.HEAD,
head, null));
Ref head = db.getRef(Constants.HEAD);
if (head != null) {
all.put(Constants.HEAD, head);
}
} catch (IOException e) {
// Ignore the failure reading HEAD.
@@ -85,13 +85,12 @@ class ListBranches extends Handler<List<Branch>> {
}
for (final Ref ref : all.values()) {
if (Constants.HEAD.equals(ref.getOrigName())
&& !ref.getOrigName().equals(ref.getName())) {
if (Constants.HEAD.equals(ref.getName()) && ref.isSymbolic()) {
// HEAD is a symbolic reference to another branch, instead of
// showing the resolved value, show the name it references.
//
headBranch = createBranch(Constants.HEAD);
String target = ref.getName();
String target = ref.getTarget().getName();
if (target.startsWith(Constants.R_HEADS)) {
target = target.substring(Constants.R_HEADS.length());
}

View File

@@ -22,6 +22,7 @@ import static org.easymock.classextension.EasyMock.replay;
import static org.easymock.classextension.EasyMock.verify;
import static org.eclipse.jgit.lib.Constants.HEAD;
import static org.eclipse.jgit.lib.Constants.R_HEADS;
import static org.eclipse.jgit.lib.Ref.Storage.LOOSE;
import com.google.gerrit.reviewdb.Branch;
import com.google.gerrit.reviewdb.Project;
@@ -34,9 +35,11 @@ import com.google.gwtorm.server.StandardKeyEncoder;
import org.easymock.IExpectationSetters;
import org.eclipse.jgit.junit.LocalDiskRepositoryTestCase;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ObjectIdRef;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.RefUpdate;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.SymbolicRef;
import java.io.IOException;
import java.util.LinkedHashMap;
@@ -112,13 +115,13 @@ public class ListBranchesTest extends LocalDiskRepositoryTestCase {
}
private List<Branch> permitted(boolean getFullBranch)
private List<Branch> permitted(boolean getHead)
throws NoSuchProjectException, IOException {
validate().andReturn(pc);
expect(grm.openRepository(eq(name.get()))).andReturn(mockDb);
expect(mockDb.getAllRefs()).andDelegateTo(realDb);
if (getFullBranch) {
expect(mockDb.getFullBranch()).andDelegateTo(realDb);
if (getHead) {
expect(mockDb.getRef(HEAD)).andDelegateTo(realDb);
}
mockDb.close();
expectLastCall();
@@ -216,9 +219,10 @@ public class ListBranchesTest extends LocalDiskRepositoryTestCase {
public void testSortByName() throws Exception {
Map<String, Ref> u = new LinkedHashMap<String, Ref>();
u.put("foo", new Ref(Ref.Storage.LOOSE, R_HEADS + "foo", idA));
u.put("bar", new Ref(Ref.Storage.LOOSE, R_HEADS + "bar", idA));
u.put(HEAD, new Ref(Ref.Storage.LOOSE, HEAD, R_HEADS + "master", null));
u.put("foo", new ObjectIdRef.Unpeeled(LOOSE, R_HEADS + "foo", idA));
u.put("bar", new ObjectIdRef.Unpeeled(LOOSE, R_HEADS + "bar", idA));
u.put(HEAD, new SymbolicRef(HEAD, new ObjectIdRef.Unpeeled(LOOSE, R_HEADS
+ "master", null)));
validate().andReturn(pc);
expect(grm.openRepository(eq(name.get()))).andReturn(mockDb);