if (start_active_slot(preq->slot)) {
run_active_slot(preq->slot);
- if (results.curl_result != CURLE_OK) {
+ if (results.curl_result != CURLE_OK &&
+ results.http_code != 416) {
struct url_info url;
char *nurl = url_normalize(preq->url, &url);
if (!nurl || !git_env_bool("GIT_TRACE_REDACT", 1)) {
} else if (request->state == RUN_FETCH_PACKED) {
int fail = 1;
- if (request->curl_result != CURLE_OK) {
+ if (request->curl_result != CURLE_OK &&
+ request->http_code != 416) {
fprintf(stderr, "Unable to get pack file %s\n%s",
request->url, curl_errorstr);
} else {
if (start_active_slot(preq->slot)) {
run_active_slot(preq->slot);
- if (results.curl_result != CURLE_OK) {
+ if (results.curl_result != CURLE_OK &&
+ results.http_code != 416) {
error("Unable to get pack file %s\n%s", preq->url,
curl_errorstr);
goto abort;
git -C packfileclient cat-file -e "$HASH"
'
+test_expect_success 'http-fetch --packfile accepts an already complete partial' '
+ git init packfileclient-complete &&
+ p=$(cd "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git &&
+ ls objects/pack/pack-*.pack) &&
+ packhash=$(basename "$p" .pack) &&
+ packhash=${packhash#pack-} &&
+ tmpfile="packfileclient-complete/.git/objects/pack/pack-$packhash.pack.temp" &&
+ cp "$HTTPD_DOCUMENT_ROOT_PATH/repo_pack.git/$p" "$tmpfile" &&
+ chmod u+w "$tmpfile" &&
+ GIT_TRACE_CURL="$TRASH_DIRECTORY/complete.trace" \
+ git -C packfileclient-complete http-fetch --packfile="$packhash" \
+ --index-pack-arg=index-pack \
+ --index-pack-arg=--stdin --index-pack-arg=--keep \
+ "$HTTPD_URL/dumb/repo_pack.git/$p" >out &&
+ test_grep "416 Requested Range Not Satisfiable" complete.trace &&
+ test_path_is_missing "$tmpfile" &&
+ git -C packfileclient-complete cat-file -e "$HASH"
+'
+
test_expect_success 'fetch notices corrupt pack' '
cp -R "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git "$HTTPD_DOCUMENT_ROOT_PATH"/repo_bad1.git &&
(cd "$HTTPD_DOCUMENT_ROOT_PATH"/repo_bad1.git &&