1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-18 04:16:10 +02:00

Merge branch 'jt/tags-to-promised-blobs-fix'

The lazy clone support had a few places where missing but promised
objects were not correctly tolerated, which have been fixed.

* jt/tags-to-promised-blobs-fix:
  tag: don't warn if target is missing but promised
  revision: tolerate promised targets of tags
This commit is contained in:
Junio C Hamano 2018-08-02 15:30:46 -07:00
commit 09ca613049
3 changed files with 57 additions and 3 deletions

View File

@ -251,6 +251,9 @@ static struct commit *handle_commit(struct rev_info *revs,
if (!object) {
if (revs->ignore_missing_links || (flags & UNINTERESTING))
return NULL;
if (revs->exclude_promisor_objects &&
is_promisor_object(&tag->tagged->oid))
return NULL;
die("bad object %s", oid_to_hex(&tag->tagged->oid));
}
object->flags |= flags;

View File

@ -216,6 +216,50 @@ test_expect_success 'upon cloning, check that all refs point to objects' '
! test -e "$HTTPD_ROOT_PATH/one-time-sed"
'
test_expect_success 'when partial cloning, tolerate server not sending target of tag' '
SERVER="$HTTPD_DOCUMENT_ROOT_PATH/server" &&
rm -rf "$SERVER" repo &&
test_create_repo "$SERVER" &&
test_commit -C "$SERVER" foo &&
test_config -C "$SERVER" uploadpack.allowfilter 1 &&
test_config -C "$SERVER" uploadpack.allowanysha1inwant 1 &&
# Create an annotated tag pointing to a blob.
BLOB=$(echo blob-contents | git -C "$SERVER" hash-object --stdin -w) &&
git -C "$SERVER" tag -m message -a myblob "$BLOB" &&
# Craft a packfile including the tag, but not the blob it points to.
# Also, omit objects referenced from HEAD in order to force a second
# fetch (to fetch missing objects) upon the automatic checkout that
# happens after a clone.
printf "%s\n%s\n--not\n%s\n%s\n" \
$(git -C "$SERVER" rev-parse HEAD) \
$(git -C "$SERVER" rev-parse myblob) \
$(git -C "$SERVER" rev-parse HEAD^{tree}) \
$(git -C "$SERVER" rev-parse myblob^{blob}) |
git -C "$SERVER" pack-objects --thin --stdout >incomplete.pack &&
# Replace the existing packfile with the crafted one. The protocol
# requires that the packfile be sent in sideband 1, hence the extra
# \x01 byte at the beginning.
printf "1,/packfile/!c %04x\\\\x01%s0000" \
"$(($(wc -c <incomplete.pack) + 5))" \
"$(sed_escape <incomplete.pack)" \
>"$HTTPD_ROOT_PATH/one-time-sed" &&
# Use protocol v2 because the sed command looks for the "packfile"
# section header.
test_config -C "$SERVER" protocol.version 2 &&
# Exercise to make sure it works.
git -c protocol.version=2 clone \
--filter=blob:none $HTTPD_URL/one_time_sed/server repo 2> err &&
! grep "missing object referenced by" err &&
# Ensure that the one-time-sed script was used.
! test -e "$HTTPD_ROOT_PATH/one-time-sed"
'
stop_httpd
test_done

13
tag.c
View File

@ -6,6 +6,7 @@
#include "blob.h"
#include "alloc.h"
#include "gpg-interface.h"
#include "packfile.h"
const char *tag_type = "tag";
@ -66,12 +67,18 @@ int gpg_verify_tag(const struct object_id *oid, const char *name_to_report,
struct object *deref_tag(struct repository *r, struct object *o, const char *warn, int warnlen)
{
struct object_id *last_oid = NULL;
while (o && o->type == OBJ_TAG)
if (((struct tag *)o)->tagged)
o = parse_object(r, &((struct tag *)o)->tagged->oid);
else
if (((struct tag *)o)->tagged) {
last_oid = &((struct tag *)o)->tagged->oid;
o = parse_object(r, last_oid);
} else {
last_oid = NULL;
o = NULL;
}
if (!o && warn) {
if (last_oid && is_promisor_object(last_oid))
return NULL;
if (!warnlen)
warnlen = strlen(warn);
error("missing object referenced by '%.*s'", warnlen, warn);