@matheusbsbs / matheus-bagliano / commits / 348e390b17
Fork 0

Teach fetch-pack/upload-pack about --include-tag

The new protocol extension "include-tag" allows the client side of the connection (fetch-pack) to request that the server side of the native git protocol (upload-pack / pack-objects) use --include-tag as it prepares the packfile, thus ensuring that an annotated tag object will be included in the resulting packfile if the object it refers to was also included into the packfile. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Shawn O. Pearce committed Mar 3, 2008 at 22:27 UTC 348e390b17e7a2b0618fbbfe8cdefa3d73ecbea2
4 files changed +24 -6
Documentation/git-fetch-pack.txt
+7 -1
@@ -8,7 +8,7 @@ git-fetch-pack - Receive missing objects from another repository
8
9 SYNOPSIS
10 --------
11 -'git-fetch-pack' [--all] [--quiet|-q] [--keep|-k] [--thin] [--upload-pack=<git-upload-pack>] [--depth=<n>] [--no-progress] [-v] [<host>:]<directory> [<refs>...]
11 +'git-fetch-pack' [--all] [--quiet|-q] [--keep|-k] [--thin] [--include-tag] [--upload-pack=<git-upload-pack>] [--depth=<n>] [--no-progress] [-v] [<host>:]<directory> [<refs>...]
12
13 DESCRIPTION
14 -----------
@@ -45,6 +45,12 @@ OPTIONS
45 Spend extra cycles to minimize the number of objects to be sent.
46 Use it on slower connection.
47
48 +\--include-tag::
49 + If the remote side supports it, annotated tags objects will
50 + be downloaded on the same connection as the other objects if
51 + the object the tag references is downloaded. The caller must
52 + otherwise determine the tags this option made available.
53 +
54 \--upload-pack=<git-upload-pack>::
55 Use this to specify the path to 'git-upload-pack' on the
56 remote side, if is not found on your $PATH.
builtin-fetch-pack.c
+7 -2
@@ -18,7 +18,7 @@ static struct fetch_pack_args args = {
18 };
19
20 static const char fetch_pack_usage[] =
21 -"git-fetch-pack [--all] [--quiet|-q] [--keep|-k] [--thin] [--upload-pack=<git-upload-pack>] [--depth=<n>] [--no-progress] [-v] [<host>:]<directory> [<refs>...]";
21 +"git-fetch-pack [--all] [--quiet|-q] [--keep|-k] [--thin] [--include-tag] [--upload-pack=<git-upload-pack>] [--depth=<n>] [--no-progress] [-v] [<host>:]<directory> [<refs>...]";
22
23 #define COMPLETE (1U << 0)
24 #define COMMON (1U << 1)
@@ -174,13 +174,14 @@ static int find_common(int fd[2], unsigned char *result_sha1,
174 }
175
176 if (!fetching)
177 - packet_write(fd[1], "want %s%s%s%s%s%s%s\n",
177 + packet_write(fd[1], "want %s%s%s%s%s%s%s%s\n",
178 sha1_to_hex(remote),
179 (multi_ack ? " multi_ack" : ""),
180 (use_sideband == 2 ? " side-band-64k" : ""),
181 (use_sideband == 1 ? " side-band" : ""),
182 (args.use_thin_pack ? " thin-pack" : ""),
183 (args.no_progress ? " no-progress" : ""),
184 + (args.include_tag ? " include-tag" : ""),
185 " ofs-delta");
186 else
187 packet_write(fd[1], "want %s\n", sha1_to_hex(remote));
@@ -680,6 +681,10 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
681 args.use_thin_pack = 1;
682 continue;
683 }
684 + if (!strcmp("--include-tag", arg)) {
685 + args.include_tag = 1;
686 + continue;
687 + }
688 if (!strcmp("--all", arg)) {
689 args.fetch_all = 1;
690 continue;
fetch-pack.h
+2 -1
@@ -12,7 +12,8 @@ struct fetch_pack_args
12 use_thin_pack:1,
13 fetch_all:1,
14 verbose:1,
15 - no_progress:1;
15 + no_progress:1,
16 + include_tag:1;
17 };
18
19 struct ref *fetch_pack(struct fetch_pack_args *args,
upload-pack.c
+8 -2
@@ -27,7 +27,8 @@ static const char upload_pack_usage[] = "git-upload-pack [--strict] [--timeout=n
27 static unsigned long oldest_have;
28
29 static int multi_ack, nr_our_refs;
30 -static int use_thin_pack, use_ofs_delta, no_progress;
30 +static int use_thin_pack, use_ofs_delta, use_include_tag;
31 +static int no_progress;
32 static struct object_array have_obj;
33 static struct object_array want_obj;
34 static unsigned int timeout;
@@ -162,6 +163,8 @@ static void create_pack_file(void)
163 argv[arg++] = "--progress";
164 if (use_ofs_delta)
165 argv[arg++] = "--delta-base-offset";
166 + if (use_include_tag)
167 + argv[arg++] = "--include-tag";
168 argv[arg++] = NULL;
169
170 memset(&pack_objects, 0, sizeof(pack_objects));
@@ -494,6 +497,8 @@ static void receive_needs(void)
497 use_sideband = DEFAULT_PACKET_MAX;
498 if (strstr(line+45, "no-progress"))
499 no_progress = 1;
500 + if (strstr(line+45, "include-tag"))
501 + use_include_tag = 1;
502
503 /* We have sent all our refs already, and the other end
504 * should have chosen out of them; otherwise they are
@@ -565,7 +570,8 @@ static void receive_needs(void)
570 static int send_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data)
571 {
572 static const char *capabilities = "multi_ack thin-pack side-band"
568 - " side-band-64k ofs-delta shallow no-progress";
573 + " side-band-64k ofs-delta shallow no-progress"
574 + " include-tag";
575 struct object *o = parse_object(sha1);
576
577 if (!o)