summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorJonathan Tan <jonathantanmy@google.com>2018-03-13 11:07:36 -0700
committerJonathan Nieder <jrn@google.com>2018-05-16 17:16:35 -0700
commit5a87d50408642f619b77d12a981e6e23f407752e (patch)
tree333ed656d77c2055345cbd8d0b9f44d7be583694 /org.eclipse.jgit
parentc79e7f1c27c73732310bc64c2071a79902447dcc (diff)
downloadjgit-5a87d50408642f619b77d12a981e6e23f407752e.tar.gz
jgit-5a87d50408642f619b77d12a981e6e23f407752e.zip
Teach UploadPack "include-tag" in "fetch"
Add support for the "include-tag" parameter in the "fetch" command in the fetch-pack/upload-pack protocol v2. In order to determine which tags to include, only objects pointed to by refs starting with "refs/tags/" are checked. This restriction is for performance reasons and to match the behavior of Git (see add_ref_tag() in builtin/pack-objects.c). Change-Id: I7d70aa09bcc8a525218ff1559e286c2a610258ca Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Jonathan Nieder <jrn@google.com>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java9
1 files changed, 8 insertions, 1 deletions
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 b1f4d11865..199a007abe 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java
@@ -43,6 +43,7 @@
package org.eclipse.jgit.transport;
+import static org.eclipse.jgit.lib.Constants.R_TAGS;
import static org.eclipse.jgit.lib.RefDatabase.ALL;
import static org.eclipse.jgit.transport.GitProtocolConstants.COMMAND_FETCH;
import static org.eclipse.jgit.transport.GitProtocolConstants.COMMAND_LS_REFS;
@@ -951,6 +952,7 @@ public class UploadPack {
.format(JGitText.get().unexpectedPacketLine, line));
}
+ boolean includeTag = false;
while ((line = pckIn.readString()) != PacketLineIn.END) {
if (line.startsWith("want ")) { //$NON-NLS-1$
wantIds.add(ObjectId.fromString(line.substring(5)));
@@ -962,6 +964,9 @@ public class UploadPack {
options.add(OPTION_THIN_PACK);
} else if (line.equals(OPTION_NO_PROGRESS)) {
options.add(OPTION_NO_PROGRESS);
+ } else if (line.equals(OPTION_INCLUDE_TAG)) {
+ options.add(OPTION_INCLUDE_TAG);
+ includeTag = true;
}
// else ignore it
}
@@ -990,7 +995,9 @@ public class UploadPack {
pckOut.writeDelim();
pckOut.writeString("packfile\n"); //$NON-NLS-1$
sendPack(new PackStatistics.Accumulator(),
- refs == null ? null : refs.values());
+ includeTag
+ ? db.getRefDatabase().getRefsByPrefix(R_TAGS)
+ : null);
}
pckOut.end();
}