Browse Source

Skip unborn branches in UploadPack

The ObjectId of an unborn branch is null, skip those in UploadPack.

Change-Id: I7cbf66b05dff98c4fe9f33e20a647ba6acf364b2
Signed-off-by: Zhen Chen <czhen@google.com>
stable-4.11
Zhen Chen 7 years ago
parent
commit
21d22e6f63
  1. 3
      org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java
  2. 11
      org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java

3
org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java

@ -1104,7 +1104,8 @@ public abstract class Repository implements AutoCloseable {
}
/**
* Get mutable map of all known refs
* Get mutable map of all known refs, including symrefs like HEAD that may
* not point to any object yet.
*
* @return mutable map of all known refs (heads, tags, remotes).
*/

11
org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java

@ -1617,6 +1617,10 @@ public class UploadPack {
if (options.contains(OPTION_INCLUDE_TAG) && refs != null) {
for (Ref ref : refs.values()) {
ObjectId objectId = ref.getObjectId();
if (objectId == null) {
// skip unborn branch
continue;
}
// If the object was already requested, skip it.
if (wantAll.isEmpty()) {
@ -1632,12 +1636,13 @@ public class UploadPack {
ref = db.peel(ref);
ObjectId peeledId = ref.getPeeledObjectId();
if (peeledId == null)
objectId = ref.getObjectId();
if (peeledId == null || objectId == null)
continue;
objectId = ref.getObjectId();
if (pw.willInclude(peeledId) && !pw.willInclude(objectId))
if (pw.willInclude(peeledId) && !pw.willInclude(objectId)) {
pw.addObject(rw.parseAny(objectId));
}
}
}

Loading…
Cancel
Save