Skip to content

Commit 348e390

Browse files
spearcegitster
authored andcommitted
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>
1 parent f0a24aa commit 348e390

File tree

4 files changed

+24
-6
lines changed

4 files changed

+24
-6
lines changed

Documentation/git-fetch-pack.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ git-fetch-pack - Receive missing objects from another repository
88

99
SYNOPSIS
1010
--------
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>...]
1212

1313
DESCRIPTION
1414
-----------
@@ -45,6 +45,12 @@ OPTIONS
4545
Spend extra cycles to minimize the number of objects to be sent.
4646
Use it on slower connection.
4747

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+
4854
\--upload-pack=<git-upload-pack>::
4955
Use this to specify the path to 'git-upload-pack' on the
5056
remote side, if is not found on your $PATH.

builtin-fetch-pack.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ static struct fetch_pack_args args = {
1818
};
1919

2020
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>...]";
2222

2323
#define COMPLETE (1U << 0)
2424
#define COMMON (1U << 1)
@@ -174,13 +174,14 @@ static int find_common(int fd[2], unsigned char *result_sha1,
174174
}
175175

176176
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",
178178
sha1_to_hex(remote),
179179
(multi_ack ? " multi_ack" : ""),
180180
(use_sideband == 2 ? " side-band-64k" : ""),
181181
(use_sideband == 1 ? " side-band" : ""),
182182
(args.use_thin_pack ? " thin-pack" : ""),
183183
(args.no_progress ? " no-progress" : ""),
184+
(args.include_tag ? " include-tag" : ""),
184185
" ofs-delta");
185186
else
186187
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)
680681
args.use_thin_pack = 1;
681682
continue;
682683
}
684+
if (!strcmp("--include-tag", arg)) {
685+
args.include_tag = 1;
686+
continue;
687+
}
683688
if (!strcmp("--all", arg)) {
684689
args.fetch_all = 1;
685690
continue;

fetch-pack.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ struct fetch_pack_args
1212
use_thin_pack:1,
1313
fetch_all:1,
1414
verbose:1,
15-
no_progress:1;
15+
no_progress:1,
16+
include_tag:1;
1617
};
1718

1819
struct ref *fetch_pack(struct fetch_pack_args *args,

upload-pack.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ static const char upload_pack_usage[] = "git-upload-pack [--strict] [--timeout=n
2727
static unsigned long oldest_have;
2828

2929
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;
3132
static struct object_array have_obj;
3233
static struct object_array want_obj;
3334
static unsigned int timeout;
@@ -162,6 +163,8 @@ static void create_pack_file(void)
162163
argv[arg++] = "--progress";
163164
if (use_ofs_delta)
164165
argv[arg++] = "--delta-base-offset";
166+
if (use_include_tag)
167+
argv[arg++] = "--include-tag";
165168
argv[arg++] = NULL;
166169

167170
memset(&pack_objects, 0, sizeof(pack_objects));
@@ -494,6 +497,8 @@ static void receive_needs(void)
494497
use_sideband = DEFAULT_PACKET_MAX;
495498
if (strstr(line+45, "no-progress"))
496499
no_progress = 1;
500+
if (strstr(line+45, "include-tag"))
501+
use_include_tag = 1;
497502

498503
/* We have sent all our refs already, and the other end
499504
* should have chosen out of them; otherwise they are
@@ -565,7 +570,8 @@ static void receive_needs(void)
565570
static int send_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data)
566571
{
567572
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";
569575
struct object *o = parse_object(sha1);
570576

571577
if (!o)

0 commit comments

Comments
 (0)