assertTrue(sw.toString().isEmpty());
}
+ @Test
+ public void testV2FetchIncludeTag() throws Exception {
+ RevCommit commit = remote.commit().message("x").create();
+ RevTag tag = remote.tag("tag", commit);
+ remote.update("branch1", commit);
+ remote.update("refs/tags/tag", tag);
+
+ // Without include-tag.
+ ByteArrayInputStream recvStream = uploadPackV2(
+ "command=fetch\n",
+ PacketLineIn.DELIM,
+ "want " + commit.toObjectId().getName() + "\n",
+ "done\n",
+ PacketLineIn.END);
+ PacketLineIn pckIn = new PacketLineIn(recvStream);
+ assertThat(pckIn.readString(), is("packfile"));
+ parsePack(recvStream);
+ assertFalse(client.hasObject(tag.toObjectId()));
+
+ // With tag.
+ recvStream = uploadPackV2(
+ "command=fetch\n",
+ PacketLineIn.DELIM,
+ "want " + commit.toObjectId().getName() + "\n",
+ "include-tag\n",
+ "done\n",
+ PacketLineIn.END);
+ pckIn = new PacketLineIn(recvStream);
+ assertThat(pckIn.readString(), is("packfile"));
+ parsePack(recvStream);
+ assertTrue(client.hasObject(tag.toObjectId()));
+ }
+
private static class RejectAllRefFilter implements RefFilter {
@Override
public Map<String, Ref> filter(Map<String, Ref> refs) {
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;
.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)));
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
}
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();
}