upload-pack: remove packet debugging harness
If you set the GIT_DEBUG_SEND_PACK environment variable, upload-pack will dump lines it receives in the receive_needs phase to a descriptor. This debugging harness is a strict subset of what GIT_TRACE_PACKET can do. Let's just drop it in favor of that. A few tests used GIT_DEBUG_SEND_PACK to confirm which objects get sent; we have to adapt them to the new output format. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Feb 20, 2013 at 14:55 UTC
97a83fa839d818130bfeca060279c4c355036785
3 files changed
+22
-35
t/t5503-tagfollow.sh
+17
-21
@@ -5,7 +5,7 @@ test_description='test automatic tag following'
5
. ./test-lib.sh
6
7
if ! test_have_prereq NOT_MINGW; then
8
- say "GIT_DEBUG_SEND_PACK not supported - skipping tests"
8
+ say "GIT_TRACE_PACKET not supported - skipping tests"
9
fi
10
11
# End state of the repository:
@@ -42,21 +42,26 @@ U=UPLOAD_LOG
42
43
test_expect_success NOT_MINGW 'setup expect' '
44
cat - <<EOF >expect
45
-#S
45
want $A
47
-#E
46
EOF
47
'
48
49
+get_needs () {
50
+ perl -alne '
51
+ next unless $F[1] eq "upload-pack<";
52
+ last if $F[2] eq "0000";
53
+ print $F[2], " ", $F[3];
54
+ ' "$@"
55
+}
56
+
57
test_expect_success NOT_MINGW 'fetch A (new commit : 1 connection)' '
58
rm -f $U &&
59
(
60
cd cloned &&
55
- GIT_DEBUG_SEND_PACK=3 git fetch 3>../$U &&
61
+ GIT_TRACE_PACKET=3 git fetch 3>../$U &&
62
test $A = $(git rev-parse --verify origin/master)
63
) &&
58
- test -s $U &&
59
- cut -d" " -f1,2 $U >actual &&
64
+ get_needs $U >actual &&
65
test_cmp expect actual
66
'
67
@@ -74,10 +79,8 @@ test_expect_success NOT_MINGW "create tag T on A, create C on branch cat" '
79
80
test_expect_success NOT_MINGW 'setup expect' '
81
cat - <<EOF >expect
77
-#S
82
want $C
83
want $T
80
-#E
84
EOF
85
'
86
@@ -85,13 +88,12 @@ test_expect_success NOT_MINGW 'fetch C, T (new branch, tag : 1 connection)' '
88
rm -f $U &&
89
(
90
cd cloned &&
88
- GIT_DEBUG_SEND_PACK=3 git fetch 3>../$U &&
91
+ GIT_TRACE_PACKET=3 git fetch 3>../$U &&
92
test $C = $(git rev-parse --verify origin/cat) &&
93
test $T = $(git rev-parse --verify tag1) &&
94
test $A = $(git rev-parse --verify tag1^0)
95
) &&
93
- test -s $U &&
94
- cut -d" " -f1,2 $U >actual &&
96
+ get_needs $U >actual &&
97
test_cmp expect actual
98
'
99
@@ -113,10 +115,8 @@ test_expect_success NOT_MINGW "create commits O, B, tag S on B" '
115
116
test_expect_success NOT_MINGW 'setup expect' '
117
cat - <<EOF >expect
116
-#S
118
want $B
119
want $S
119
-#E
120
EOF
121
'
122
@@ -124,22 +124,19 @@ test_expect_success NOT_MINGW 'fetch B, S (commit and tag : 1 connection)' '
124
rm -f $U &&
125
(
126
cd cloned &&
127
- GIT_DEBUG_SEND_PACK=3 git fetch 3>../$U &&
127
+ GIT_TRACE_PACKET=3 git fetch 3>../$U &&
128
test $B = $(git rev-parse --verify origin/master) &&
129
test $B = $(git rev-parse --verify tag2^0) &&
130
test $S = $(git rev-parse --verify tag2)
131
) &&
132
- test -s $U &&
133
- cut -d" " -f1,2 $U >actual &&
132
+ get_needs $U >actual &&
133
test_cmp expect actual
134
'
135
136
test_expect_success NOT_MINGW 'setup expect' '
137
cat - <<EOF >expect
139
-#S
138
want $B
139
want $S
142
-#E
140
EOF
141
'
142
@@ -151,15 +148,14 @@ test_expect_success NOT_MINGW 'new clone fetch master and tags' '
148
cd clone2 &&
149
git init &&
150
git remote add origin .. &&
154
- GIT_DEBUG_SEND_PACK=3 git fetch 3>../$U &&
151
+ GIT_TRACE_PACKET=3 git fetch 3>../$U &&
152
test $B = $(git rev-parse --verify origin/master) &&
153
test $S = $(git rev-parse --verify tag2) &&
154
test $B = $(git rev-parse --verify tag2^0) &&
155
test $T = $(git rev-parse --verify tag1) &&
156
test $A = $(git rev-parse --verify tag1^0)
157
) &&
161
- test -s $U &&
162
- cut -d" " -f1,2 $U >actual &&
158
+ get_needs $U >actual &&
159
test_cmp expect actual
160
'
161
t/t5700-clone-reference.sh
+5
-5
@@ -55,10 +55,10 @@ cd "$base_dir"
55
rm -f "$U.D"
56
57
test_expect_success 'cloning with reference (no -l -s)' \
58
-'GIT_DEBUG_SEND_PACK=3 git clone --reference B "file://$(pwd)/A" D 3>"$U.D"'
58
+'GIT_TRACE_PACKET=3 git clone --reference B "file://$(pwd)/A" D 3>"$U.D"'
59
60
test_expect_success 'fetched no objects' \
61
-'! grep "^want" "$U.D"'
61
+'! grep " want" "$U.D"'
62
63
cd "$base_dir"
64
@@ -173,12 +173,12 @@ test_expect_success 'fetch with incomplete alternates' '
173
(
174
cd K &&
175
git remote add J "file://$base_dir/J" &&
176
- GIT_DEBUG_SEND_PACK=3 git fetch J 3>"$U.K"
176
+ GIT_TRACE_PACKET=3 git fetch J 3>"$U.K"
177
) &&
178
master_object=$(cd A && git for-each-ref --format="%(objectname)" refs/heads/master) &&
179
- ! grep "^want $master_object" "$U.K" &&
179
+ ! grep " want $master_object" "$U.K" &&
180
tag_object=$(cd A && git for-each-ref --format="%(objectname)" refs/tags/HEAD) &&
181
- ! grep "^want $tag_object" "$U.K"
181
+ ! grep " want $tag_object" "$U.K"
182
'
183
184
test_done
upload-pack.c
-9
@@ -42,7 +42,6 @@ static unsigned int timeout;
42
* otherwise maximum packet size (up to 65520 bytes).
43
*/
44
static int use_sideband;
45
-static int debug_fd;
45
static int advertise_refs;
46
static int stateless_rpc;
47
@@ -580,8 +579,6 @@ static void receive_needs(void)
579
int has_non_tip = 0;
580
581
shallow_nr = 0;
583
- if (debug_fd)
584
- write_str_in_full(debug_fd, "#S\n");
582
for (;;) {
583
struct object *o;
584
const char *features;
@@ -590,8 +587,6 @@ static void receive_needs(void)
587
reset_timeout();
588
if (!len)
589
break;
593
- if (debug_fd)
594
- write_in_full(debug_fd, line, len);
590
591
if (!prefixcmp(line, "shallow ")) {
592
unsigned char sha1[20];
@@ -653,8 +648,6 @@ static void receive_needs(void)
648
add_object_array(o, NULL, &want_obj);
649
}
650
}
656
- if (debug_fd)
657
- write_str_in_full(debug_fd, "#E\n");
651
652
/*
653
* We have sent all our refs already, and the other end
@@ -845,8 +838,6 @@ int main(int argc, char **argv)
838
if (is_repository_shallow())
839
die("attempt to fetch/clone from a shallow repository");
840
git_config(upload_pack_config, NULL);
848
- if (getenv("GIT_DEBUG_SEND_PACK"))
849
- debug_fd = atoi(getenv("GIT_DEBUG_SEND_PACK"));
841
upload_pack();
842
return 0;
843
}