Clean up pkt-line API, implementation and its callers to make them
more robust.
* jk/pkt-line-cleanup:
do not use GIT_TRACE_PACKET=3 in tests
remote-curl: always parse incoming refs
remote-curl: move ref-parsing code up in file
remote-curl: pass buffer straight to get_remote_heads
teach get_remote_heads to read from a memory buffer
pkt-line: share buffer/descriptor reading implementation
pkt-line: provide a LARGE_PACKET_MAX static buffer
pkt-line: move LARGE_PACKET_MAX definition from sideband
pkt-line: teach packet_read_line to chomp newlines
pkt-line: provide a generic reading function with options
pkt-line: drop safe_write function
pkt-line: move a misplaced comment
write_or_die: raise SIGPIPE when we get EPIPE
upload-archive: use argv_array to store client arguments
upload-archive: do not copy repo name
send-pack: prefer prefixcmp over memcmp in receive_status
fetch-pack: fix out-of-bounds buffer offset in get_ack
upload-pack: remove packet debugging harness
upload-pack: do not add duplicate objects to shallow list
upload-pack: use get_sha1_hex to parse "shallow" lines
@ -37,7 +38,7 @@ int recv_sideband(const char *me, int in_stream, int out)
@@ -37,7 +38,7 @@ int recv_sideband(const char *me, int in_stream, int out)
while (1) {
int band, len;
len = packet_read_line(in_stream, buf + pf, LARGE_PACKET_MAX);
len = packet_read(in_stream, NULL, NULL, buf + pf, LARGE_PACKET_MAX, 0);
if (len == 0)
break;
if (len < 1) {
@ -108,7 +109,7 @@ int recv_sideband(const char *me, int in_stream, int out)
@@ -108,7 +109,7 @@ int recv_sideband(const char *me, int in_stream, int out)
} while (len);
continue;
case 1:
safe_write(out, buf + pf+1, len);
write_or_die(out, buf + pf+1, len);
continue;
default:
fprintf(stderr, "%s: protocol error: bad band #%d\n",
@ -138,12 +139,12 @@ ssize_t send_sideband(int fd, int band, const char *data, ssize_t sz, int packet
@@ -138,12 +139,12 @@ ssize_t send_sideband(int fd, int band, const char *data, ssize_t sz, int packet
test_expect_success NOT_MINGW 'fetch A (new commit : 1 connection)' '
get_needs () {
test -s "$1" &&
perl -alne '
next unless $F[1] eq "upload-pack<";
last if $F[2] eq "0000";
print $F[2], " ", $F[3];
' "$1"
}
test_expect_success 'fetch A (new commit : 1 connection)' '
rm -f $U &&
(
cd cloned &&
GIT_DEBUG_SEND_PACK=3 git fetch 3>../$U &&
GIT_TRACE_PACKET=$UPATH git fetch &&
test $A = $(git rev-parse --verify origin/master)
) &&
test -s $U &&
cut -d" " -f1,2 $U >actual &&
get_needs $U >actual &&
test_cmp expect actual
'
test_expect_success NOT_MINGW "create tag T on A, create C on branch cat" '
test_expect_success "create tag T on A, create C on branch cat" '
git tag -a -m tag1 tag1 $A &&
T=$(git rev-parse --verify tag1) &&
@ -72,30 +75,27 @@ test_expect_success NOT_MINGW "create tag T on A, create C on branch cat" '
@@ -72,30 +75,27 @@ test_expect_success NOT_MINGW "create tag T on A, create C on branch cat" '
git checkout master
'
test_expect_success NOT_MINGW 'setup expect' '
test_expect_success 'setup expect' '
cat - <<EOF >expect
#S
want $C
want $T
#E
EOF
'
test_expect_success NOT_MINGW 'fetch C, T (new branch, tag : 1 connection)' '
test_expect_success 'fetch C, T (new branch, tag : 1 connection)' '
rm -f $U &&
(
cd cloned &&
GIT_DEBUG_SEND_PACK=3 git fetch 3>../$U &&
GIT_TRACE_PACKET=$UPATH git fetch &&
test $C = $(git rev-parse --verify origin/cat) &&
test $T = $(git rev-parse --verify tag1) &&
test $A = $(git rev-parse --verify tag1^0)
) &&
test -s $U &&
cut -d" " -f1,2 $U >actual &&
get_needs $U >actual &&
test_cmp expect actual
'
test_expect_success NOT_MINGW "create commits O, B, tag S on B" '
test_expect_success "create commits O, B, tag S on B" '
test_tick &&
echo O >file &&
git add file &&
@ -111,39 +111,34 @@ test_expect_success NOT_MINGW "create commits O, B, tag S on B" '
@@ -111,39 +111,34 @@ test_expect_success NOT_MINGW "create commits O, B, tag S on B" '
S=$(git rev-parse --verify tag2)
'
test_expect_success NOT_MINGW 'setup expect' '
test_expect_success 'setup expect' '
cat - <<EOF >expect
#S
want $B
want $S
#E
EOF
'
test_expect_success NOT_MINGW 'fetch B, S (commit and tag : 1 connection)' '
test_expect_success 'fetch B, S (commit and tag : 1 connection)' '
rm -f $U &&
(
cd cloned &&
GIT_DEBUG_SEND_PACK=3 git fetch 3>../$U &&
GIT_TRACE_PACKET=$UPATH git fetch &&
test $B = $(git rev-parse --verify origin/master) &&
test $B = $(git rev-parse --verify tag2^0) &&
test $S = $(git rev-parse --verify tag2)
) &&
test -s $U &&
cut -d" " -f1,2 $U >actual &&
get_needs $U >actual &&
test_cmp expect actual
'
test_expect_success NOT_MINGW 'setup expect' '
test_expect_success 'setup expect' '
cat - <<EOF >expect
#S
want $B
want $S
#E
EOF
'
test_expect_success NOT_MINGW 'new clone fetch master and tags' '
test_expect_success 'new clone fetch master and tags' '
@ -508,7 +508,7 @@ static struct ref *get_refs_via_connect(struct transport *transport, int for_pus
@@ -508,7 +508,7 @@ static struct ref *get_refs_via_connect(struct transport *transport, int for_pus
struct ref *refs;
connect_setup(transport, for_push, 0);
get_remote_heads(data->fd[0], &refs,
get_remote_heads(data->fd[0], NULL, 0, &refs,
for_push ? REF_NORMAL : 0, &data->extra_have);
data->got_remote_heads = 1;
@ -537,7 +537,7 @@ static int fetch_refs_via_pack(struct transport *transport,
@@ -537,7 +537,7 @@ static int fetch_refs_via_pack(struct transport *transport,