git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v3 1/6] ref-filter: add objectsize:disk option

From
Olga Telezhnaya <olyatelezhnaya@gmail.com>
Date
Jan 10, 2019, 06:32 UTC
Message-ID
<0102016836761b8b-8616fc01-3489-4e53-a5b7-cd4b52e20e01-000000@eu-west-1.amazonses.com>
In-Reply-To
<CAL21Bm=stCR8-yJ-eh396veQ2kAoGwLX5ci_T0N-6femAwk4jA@mail.gmail.com>

Add new formatting option objectsize:disk to know exact size that object takes up on disk.

Signed-off-by: Olga Telezhnaia <olyatelezhnaya@gmail.com>
---
 ref-filter.c | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/ref-filter.c b/ref-filter.c
index 61d75d5c86c64..ecef4b47c751c 100644
--- a/ref-filter.c
+++ b/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;
 }
 
@@ -880,7 +886,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, (uintmax_t)oi->disk_size);
+		} else if (!strcmp(name, "objectsize")) {
 			v->value = oi->size;
 			v->s = xstrfmt("%"PRIuMAX , (uintmax_t)oi->size);
 		}

--
https://github.com/git/git/pull/552
Previous: Оля ТележнаяNext: Olga Telezhnaya
Message 4 of 10 in “ref-filter: add new formatting options”
  1. 0/5 ref-filter: add new formatting optionsОля Тележная, Nov 9, 2018
  2. 0/5 ref-filter: add new formatting optionsОля Тележная, Dec 24, 2018
  3. Оля ТележнаяJan 10, 2019
  4. 1/6 ref-filter: add objectsize:disk optionOlga Telezhnaya, Jan 10, 2019
  5. 5/6 ref-filter: add tests for deltabaseOlga Telezhnaya, Jan 10, 2019
  6. 4/6 ref-filter: add deltabase optionOlga Telezhnaya, Jan 10, 2019
  7. 2/6 ref-filter: add check for negative file sizeOlga Telezhnaya, Jan 10, 2019
  8. 6/6 ref-filter: add docs for new optionsOlga Telezhnaya, Jan 10, 2019
  9. 3/6 ref-filter: add tests for objectsize:diskOlga Telezhnaya, Jan 10, 2019
  10. Junio C HamanoJan 10, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.