summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2014-01-10 18:33:11 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-01-10 18:33:11 (GMT)
commitb2132068c6df38b24b49dfc6fbbf0645b21ec037 (patch)
tree56fc704257887e0788cc73e654393605da8171c2 /t
parentf06a5e607dde266884db4a99b70fbee09d5c5efc (diff)
parent65ea9c3c3d0e74b1f8c0c1d9fea6988550133dba (diff)
downloadgit-b2132068c6df38b24b49dfc6fbbf0645b21ec037.zip
git-b2132068c6df38b24b49dfc6fbbf0645b21ec037.tar.gz
git-b2132068c6df38b24b49dfc6fbbf0645b21ec037.tar.bz2
Merge branch 'jk/oi-delta-base'
Teach "cat-file --batch" to show delta-base object name for a packed object that is represented as a delta. * jk/oi-delta-base: cat-file: provide %(deltabase) batch format sha1_object_info_extended: provide delta base sha1s
Diffstat (limited to 't')
-rwxr-xr-xt/t1006-cat-file.sh34
1 files changed, 34 insertions, 0 deletions
diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh
index 1687098..a72e700 100755
--- a/t/t1006-cat-file.sh
+++ b/t/t1006-cat-file.sh
@@ -262,4 +262,38 @@ test_expect_success "--batch-check with multiple sha1s gives correct format" '
"$(echo_without_newline "$batch_check_input" | git cat-file --batch-check)"
'
+test_expect_success 'setup blobs which are likely to delta' '
+ test-genrandom foo 10240 >foo &&
+ { cat foo; echo plus; } >foo-plus &&
+ git add foo foo-plus &&
+ git commit -m foo &&
+ cat >blobs <<-\EOF
+ HEAD:foo
+ HEAD:foo-plus
+ EOF
+'
+
+test_expect_success 'confirm that neither loose blob is a delta' '
+ cat >expect <<-EOF
+ $_z40
+ $_z40
+ EOF
+ git cat-file --batch-check="%(deltabase)" <blobs >actual &&
+ test_cmp expect actual
+'
+
+# To avoid relying too much on the current delta heuristics,
+# we will check only that one of the two objects is a delta
+# against the other, but not the order. We can do so by just
+# asking for the base of both, and checking whether either
+# sha1 appears in the output.
+test_expect_success '%(deltabase) reports packed delta bases' '
+ git repack -ad &&
+ git cat-file --batch-check="%(deltabase)" <blobs >actual &&
+ {
+ grep "$(git rev-parse HEAD:foo)" actual ||
+ grep "$(git rev-parse HEAD:foo-plus)" actual
+ }
+'
+
test_done