summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorLibravatar Matthew DeVore <matvore@google.com>2018-10-05 14:31:23 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2018-10-07 08:55:00 +0900
commit7c0fe330d5f3d2fc7aac57a19c7580ea2543c799 (patch)
tree715ad64110c66efc978120aaab51c5a875dc4911 /t
parentlist-objects: always parse trees gently (diff)
downloadtgif-7c0fe330d5f3d2fc7aac57a19c7580ea2543c799.tar.xz
rev-list: handle missing tree objects properly
Previously, we assumed only blob objects could be missing. This patch makes rev-list handle missing trees like missing blobs. The --missing=* and --exclude-promisor-objects flags now work for trees as they already do for blobs. This is demonstrated in t6112. Signed-off-by: Matthew DeVore <matvore@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-xt/t0410-partial-clone.sh45
-rwxr-xr-xt/t5317-pack-objects-filter-objects.sh13
-rwxr-xr-xt/t6112-rev-list-filters-objects.sh22
3 files changed, 80 insertions, 0 deletions
diff --git a/t/t0410-partial-clone.sh b/t/t0410-partial-clone.sh
index 4984ca583d..2f4ea487a4 100755
--- a/t/t0410-partial-clone.sh
+++ b/t/t0410-partial-clone.sh
@@ -186,6 +186,51 @@ test_expect_success 'rev-list stops traversal at missing and promised commit' '
! grep $FOO out
'
+test_expect_success 'missing tree objects with --missing=allow-promisor and --exclude-promisor-objects' '
+ rm -rf repo &&
+ test_create_repo repo &&
+ test_commit -C repo foo &&
+ test_commit -C repo bar &&
+ test_commit -C repo baz &&
+
+ promise_and_delete $(git -C repo rev-parse bar^{tree}) &&
+ promise_and_delete $(git -C repo rev-parse foo^{tree}) &&
+
+ git -C repo config core.repositoryformatversion 1 &&
+ git -C repo config extensions.partialclone "arbitrary string" &&
+
+ git -C repo rev-list --missing=allow-promisor --objects HEAD >objs 2>rev_list_err &&
+ test_must_be_empty rev_list_err &&
+ # 3 commits, 3 blobs, and 1 tree
+ test_line_count = 7 objs &&
+
+ # Do the same for --exclude-promisor-objects, but with all trees gone.
+ promise_and_delete $(git -C repo rev-parse baz^{tree}) &&
+ git -C repo rev-list --exclude-promisor-objects --objects HEAD >objs 2>rev_list_err &&
+ test_must_be_empty rev_list_err &&
+ # 3 commits, no blobs or trees
+ test_line_count = 3 objs
+'
+
+test_expect_success 'missing non-root tree object and rev-list' '
+ rm -rf repo &&
+ test_create_repo repo &&
+ mkdir repo/dir &&
+ echo foo >repo/dir/foo &&
+ git -C repo add dir/foo &&
+ git -C repo commit -m "commit dir/foo" &&
+
+ promise_and_delete $(git -C repo rev-parse HEAD:dir) &&
+
+ git -C repo config core.repositoryformatversion 1 &&
+ git -C repo config extensions.partialclone "arbitrary string" &&
+
+ git -C repo rev-list --missing=allow-any --objects HEAD >objs 2>rev_list_err &&
+ test_must_be_empty rev_list_err &&
+ # 1 commit and 1 tree
+ test_line_count = 2 objs
+'
+
test_expect_success 'rev-list stops traversal at missing and promised tree' '
rm -rf repo &&
test_create_repo repo &&
diff --git a/t/t5317-pack-objects-filter-objects.sh b/t/t5317-pack-objects-filter-objects.sh
index 6710c8bc8c..9839b48c1c 100755
--- a/t/t5317-pack-objects-filter-objects.sh
+++ b/t/t5317-pack-objects-filter-objects.sh
@@ -59,6 +59,19 @@ test_expect_success 'verify normal and blob:none packfiles have same commits/tre
test_cmp observed expected
'
+test_expect_success 'get an error for missing tree object' '
+ git init r5 &&
+ echo foo >r5/foo &&
+ git -C r5 add foo &&
+ git -C r5 commit -m "foo" &&
+ del=$(git -C r5 rev-parse HEAD^{tree} | sed "s|..|&/|") &&
+ rm r5/.git/objects/$del &&
+ test_must_fail git -C r5 pack-objects --rev --stdout 2>bad_tree <<-EOF &&
+ HEAD
+ EOF
+ grep -q "bad tree object" bad_tree
+'
+
# Test blob:limit=<n>[kmg] filter.
# We boundary test around the size parameter. The filter is strictly less than
# the value, so size 500 and 1000 should have the same results, but 1001 should
diff --git a/t/t6112-rev-list-filters-objects.sh b/t/t6112-rev-list-filters-objects.sh
index 0a37dd5f97..6d69e6a0aa 100755
--- a/t/t6112-rev-list-filters-objects.sh
+++ b/t/t6112-rev-list-filters-objects.sh
@@ -196,6 +196,28 @@ test_expect_success 'verify sparse:oid=oid-ish omits top-level files' '
test_cmp observed expected
'
+test_expect_success 'rev-list W/ --missing=print and --missing=allow-any for trees' '
+ TREE=$(git -C r3 rev-parse HEAD:dir1) &&
+
+ # Create a spare repo because we will be deleting objects from this one.
+ git clone r3 r3.b &&
+
+ rm r3.b/.git/objects/$(echo $TREE | sed "s|^..|&/|") &&
+
+ git -C r3.b rev-list --quiet --missing=print --objects HEAD \
+ >missing_objs 2>rev_list_err &&
+ echo "?$TREE" >expected &&
+ test_cmp expected missing_objs &&
+
+ # do not complain when a missing tree cannot be parsed
+ test_must_be_empty rev_list_err &&
+
+ git -C r3.b rev-list --missing=allow-any --objects HEAD \
+ >objs 2>rev_list_err &&
+ ! grep $TREE objs &&
+ test_must_be_empty rev_list_err
+'
+
# Delete some loose objects and use rev-list, but WITHOUT any filtering.
# This models previously omitted objects that we did not receive.