summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorZhen Chen <czhen@google.com>2018-01-03 14:12:30 -0800
committerZhen Chen <czhen@google.com>2018-01-03 14:21:05 -0800
commit21d22e6f63a1adcfaeaee155f1be32f8123fd789 (patch)
tree643e07c833ec435ab850aaecbe67a067e91260ee /org.eclipse.jgit
parent5a4b6fd237ebab03001f55a06cdf2a59d4ca3566 (diff)
downloadjgit-21d22e6f63a1adcfaeaee155f1be32f8123fd789.tar.gz
jgit-21d22e6f63a1adcfaeaee155f1be32f8123fd789.zip
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>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java3
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java11
2 files changed, 10 insertions, 4 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java
index 8c448af904..4c0bde1376 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java
+++ b/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).
*/
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java
index 822d47c7c2..5034c34d84 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java
+++ b/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));
+ }
}
}