summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorLibravatar Jeff King <peff@peff.net>2013-12-21 09:25:22 -0500
committerLibravatar Junio C Hamano <gitster@pobox.com>2013-12-26 11:54:26 -0800
commit65ea9c3c3d0e74b1f8c0c1d9fea6988550133dba (patch)
tree471e8fce5c07dff93a2653d31548d400560cfef9 /builtin
parentsha1_object_info_extended: provide delta base sha1s (diff)
downloadtgif-65ea9c3c3d0e74b1f8c0c1d9fea6988550133dba.tar.xz
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 'builtin')
-rw-r--r--builtin/cat-file.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index b2ca775a80..2e0af2e617 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -118,6 +118,7 @@ struct expand_data {
unsigned long size;
unsigned long disk_size;
const char *rest;
+ unsigned char delta_base_sha1[20];
/*
* If mark_query is true, we do not expand anything, but rather
@@ -174,6 +175,11 @@ static void expand_atom(struct strbuf *sb, const char *atom, int len,
data->split_on_whitespace = 1;
else if (data->rest)
strbuf_addstr(sb, data->rest);
+ } else if (is_atom("deltabase", atom, len)) {
+ if (data->mark_query)
+ data->info.delta_base_sha1 = data->delta_base_sha1;
+ else
+ strbuf_addstr(sb, sha1_to_hex(data->delta_base_sha1));
} else
die("unknown format element: %.*s", len, atom);
}