summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 348e390)
raw | patch | inline | side by side (parent: 348e390)
author | Shawn O. Pearce <spearce@spearce.org> | |
Tue, 4 Mar 2008 03:27:40 +0000 (22:27 -0500) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 5 Mar 2008 07:28:15 +0000 (23:28 -0800) |
If the remote peer upload-pack process supports the include-tag
protocol extension then we can avoid running a second fetch cycle
on the client side by letting the server send us the annotated tags
along with the objects it is packing for us. In the following graph
we can now fetch both "tag1" and "tag2" on the same connection that
we fetched "master" from the remote when we only have L available
on the local side:
T - tag1 S - tag2
/ /
L - o ------ o ------ B
\ \
\ \
origin/master master
The objects for "tag1" are implicitly downloaded without our direct
knowledge. The existing "quickfetch" optimization within git-fetch
discovers that tag1 is complete after the first connection and does
not open a second connection.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
protocol extension then we can avoid running a second fetch cycle
on the client side by letting the server send us the annotated tags
along with the objects it is packing for us. In the following graph
we can now fetch both "tag1" and "tag2" on the same connection that
we fetched "master" from the remote when we only have L available
on the local side:
T - tag1 S - tag2
/ /
L - o ------ o ------ B
\ \
\ \
origin/master master
The objects for "tag1" are implicitly downloaded without our direct
knowledge. The existing "quickfetch" optimization within git-fetch
discovers that tag1 is complete after the first connection and does
not open a second connection.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-fetch.c | patch | blob | history | |
t/t5503-tagfollow.sh | patch | blob | history | |
transport.c | patch | blob | history | |
transport.h | patch | blob | history |
diff --git a/builtin-fetch.c b/builtin-fetch.c
index 26c3d74b76de701a8e1a5e0c7031751599c1487f..55f611e3c26e55df43eca1f40df74d335c850cc0 100644 (file)
--- a/builtin-fetch.c
+++ b/builtin-fetch.c
read_ref(rm->peer_ref->name, rm->peer_ref->old_sha1);
}
+ if (tags == TAGS_DEFAULT && autotags)
+ transport_set_option(transport, TRANS_OPT_FOLLOWTAGS, "1");
if (fetch_refs(transport, ref_map)) {
free_refs(ref_map);
return 1;
ref_map = NULL;
find_non_local_tags(transport, &ref_map, &tail);
if (ref_map) {
+ transport_set_option(transport, TRANS_OPT_FOLLOWTAGS, NULL);
transport_set_option(transport, TRANS_OPT_DEPTH, "0");
fetch_refs(transport, ref_map);
}
diff --git a/t/t5503-tagfollow.sh b/t/t5503-tagfollow.sh
index 45ff982ec422a26af2a390833028d30891f180ca..86e5b9bc269b3639a882c6652f4d1f66a45121f7 100755 (executable)
--- a/t/t5503-tagfollow.sh
+++ b/t/t5503-tagfollow.sh
git diff expect actual
'
+cat - <<EOF >expect
+#S
+want $B
+want $S
+#E
+EOF
+test_expect_success 'new clone fetch master and tags' '
+ git branch -D cat
+ rm -f $U
+ (
+ mkdir clone2 &&
+ cd clone2 &&
+ git init &&
+ git remote add origin .. &&
+ GIT_DEBUG_SEND_PACK=3 git fetch 3>../$U &&
+ test $B = $(git rev-parse --verify origin/master) &&
+ test $S = $(git rev-parse --verify tag2) &&
+ test $B = $(git rev-parse --verify tag2^0) &&
+ test $T = $(git rev-parse --verify tag1) &&
+ test $A = $(git rev-parse --verify tag1^0)
+ ) &&
+ test -s $U &&
+ cut -d" " -f1,2 $U >actual &&
+ git diff expect actual
+'
+
test_done
diff --git a/transport.c b/transport.c
index 166c1d1d46d954653b50897ca49678bd21f6bdfb..393e0e8fe233ca51dc4c5db94c55e81ee53baa52 100644 (file)
--- a/transport.c
+++ b/transport.c
struct git_transport_data {
unsigned thin : 1;
unsigned keep : 1;
+ unsigned followtags : 1;
int depth;
struct child_process *conn;
int fd[2];
} else if (!strcmp(name, TRANS_OPT_THIN)) {
data->thin = !!value;
return 0;
+ } else if (!strcmp(name, TRANS_OPT_FOLLOWTAGS)) {
+ data->followtags = !!value;
+ return 0;
} else if (!strcmp(name, TRANS_OPT_KEEP)) {
data->keep = !!value;
return 0;
args.keep_pack = data->keep;
args.lock_pack = 1;
args.use_thin_pack = data->thin;
+ args.include_tag = data->followtags;
args.verbose = transport->verbose > 0;
args.depth = data->depth;
diff --git a/transport.h b/transport.h
index 6fb4526cda5fc1ee1178fdf1d0840c90b88aa26c..8abfc0ae60c18165b44ef93ed9115972b991e2dc 100644 (file)
--- a/transport.h
+++ b/transport.h
/* Limit the depth of the fetch if not null */
#define TRANS_OPT_DEPTH "depth"
+/* Aggressively fetch annotated tags if possible */
+#define TRANS_OPT_FOLLOWTAGS "followtags"
+
/**
* Returns 0 if the option was used, non-zero otherwise. Prints a
* message to stderr if the option is not used.