зеркало из https://github.com/microsoft/git.git
ref-filter: add objectsize:disk option
Add new formatting option objectsize:disk to know exact size that object takes up on disk. Signed-off-by: Olga Telezhnaia <olyatelezhnaya@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Родитель
8858448bb4
Коммит
1867ce6cbe
23
ref-filter.c
23
ref-filter.c
|
@ -231,12 +231,18 @@ static int objecttype_atom_parser(const struct ref_format *format, struct used_a
|
|||
static int objectsize_atom_parser(const struct ref_format *format, struct used_atom *atom,
|
||||
const char *arg, struct strbuf *err)
|
||||
{
|
||||
if (arg)
|
||||
return strbuf_addf_ret(err, -1, _("%%(objectsize) does not take arguments"));
|
||||
if (*atom->name == '*')
|
||||
oi_deref.info.sizep = &oi_deref.size;
|
||||
else
|
||||
oi.info.sizep = &oi.size;
|
||||
if (!arg) {
|
||||
if (*atom->name == '*')
|
||||
oi_deref.info.sizep = &oi_deref.size;
|
||||
else
|
||||
oi.info.sizep = &oi.size;
|
||||
} else if (!strcmp(arg, "disk")) {
|
||||
if (*atom->name == '*')
|
||||
oi_deref.info.disk_sizep = &oi_deref.disk_size;
|
||||
else
|
||||
oi.info.disk_sizep = &oi.disk_size;
|
||||
} else
|
||||
return strbuf_addf_ret(err, -1, _("unrecognized %%(objectsize) argument: %s"), arg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -876,7 +882,10 @@ static void grab_common_values(struct atom_value *val, int deref, struct expand_
|
|||
name++;
|
||||
if (!strcmp(name, "objecttype"))
|
||||
v->s = xstrdup(type_name(oi->type));
|
||||
else if (!strcmp(name, "objectsize")) {
|
||||
else if (!strcmp(name, "objectsize:disk")) {
|
||||
v->value = oi->disk_size;
|
||||
v->s = xstrfmt("%"PRIuMAX, (intmax_t)oi->disk_size);
|
||||
} else if (!strcmp(name, "objectsize")) {
|
||||
v->value = oi->size;
|
||||
v->s = xstrfmt("%lu", oi->size);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче