Merge branch 'ot/ref-filter-object-info'
authorJunio C Hamano <gitster@pobox.com>
Fri, 18 Jan 2019 21:49:56 +0000 (13:49 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 18 Jan 2019 21:49:56 +0000 (13:49 -0800)
The "--format=<placeholder>" option of for-each-ref, branch and tag
learned to show a few more traits of objects that can be learned by
the object_info API.

* ot/ref-filter-object-info:
ref-filter: give uintmax_t to format with %PRIuMAX
ref-filter: add docs for new options
ref-filter: add tests for deltabase
ref-filter: add deltabase option
ref-filter: add tests for objectsize:disk
ref-filter: add check for negative file size
ref-filter: add objectsize:disk option

1  2 
ref-filter.c
diff --cc ref-filter.c
index 61d75d5c86c644225a6a9549ca54d64a117d0c61,b22cab133e1b1f6a917553ffa7a03303c2cd461b..422a9c9ae3fd2cfd552ce48c5e68ce18919b1eb9
@@@ -880,10 -895,14 +899,14 @@@ static void grab_common_values(struct a
                        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, (uintmax_t)oi->disk_size);
+               } else if (!strcmp(name, "objectsize")) {
                        v->value = oi->size;
 -                      v->s = xstrfmt("%lu", oi->size);
 +                      v->s = xstrfmt("%"PRIuMAX , (uintmax_t)oi->size);
-               }
+               } else if (!strcmp(name, "deltabase"))
+                       v->s = xstrdup(oid_to_hex(&oi->delta_base_oid));
                else if (deref)
                        grab_objectname(name, &oi->oid, v, &used_atom[i]);
        }