summaryrefslogtreecommitdiff
path: root/t/t1006-cat-file.sh
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2013-12-21 14:25:22 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-12-26 19:54:26 (GMT)
commit65ea9c3c3d0e74b1f8c0c1d9fea6988550133dba (patch)
tree471e8fce5c07dff93a2653d31548d400560cfef9 /t/t1006-cat-file.sh
parent5d642e75069334944fcc795a80cf04749dd12857 (diff)
downloadgit-65ea9c3c3d0e74b1f8c0c1d9fea6988550133dba.zip
git-65ea9c3c3d0e74b1f8c0c1d9fea6988550133dba.tar.gz
git-65ea9c3c3d0e74b1f8c0c1d9fea6988550133dba.tar.bz2
cat-file: provide %(deltabase) batch format
It can be useful for debugging or analysis to see which objects are stored as delta bases on top of others. This information is available by running `git verify-pack`, but that is extremely expensive (and is harder than necessary to parse). Instead, let's make it available as a cat-file query format, which makes it fast and simple to get the bases for a subset of the objects. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t1006-cat-file.sh')
-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 8a1bc5c..633dc82 100755
--- a/t/t1006-cat-file.sh
+++ b/t/t1006-cat-file.sh
@@ -240,4 +240,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