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

[PATCH RFC v2 2/4] ref-filter: add objectsize:disk formatting option

From
Olga Telezhnaya <olyatelezhnaya@gmail.com>
Date
May 18, 2018, 08:19 UTC
Message-ID
<010201637254c9fc-6c6958f9-5b32-44df-abbe-8455d4ca9535-000000@eu-west-1.amazonses.com>
In-Reply-To
<010201637254c969-a346030e-0b75-41ad-8ef3-2ac7e04ba4fb-000000@eu-west-1.amazonses.com>

Add %(objectsize:disk) support. It is still not working for deref: I am thinking how to support it in a more elegant way.

Signed-off-by: Olga Telezhnaia <olyatelezhnaya@gmail.com>
---
 ref-filter.c | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/ref-filter.c b/ref-filter.c
index 4008351553391..c00de58455301 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -277,10 +277,15 @@ 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 *unused_err)
+				  const char *arg, struct strbuf *err)
 {
+	if (!arg)
+		oi_data.info.sizep = &oi_data.size;
+	else if (!strcmp(arg, "disk"))
+		oi_data.info.disk_sizep = &oi_data.disk_size;
+	else
+		return strbuf_addf_ret(err, -1, _("unrecognized %%(objectsize) argument: %s"), arg);
 	oi_data.use_data = 1;
-	oi_data.info.sizep = &oi_data.size;
 	return 0;
 }
 
@@ -1557,9 +1562,15 @@ static int populate_value(struct ref_array_item *ref, struct strbuf *err)
 		} else if (!deref && !strcmp(name, "objecttype") && oi_data.use_data) {
 			v->s = type_name(oi_data.type);
 			continue;
-		} else if (!deref && !strcmp(name, "objectsize") && oi_data.use_data) {
-			v->value = oi_data.size;
-			v->s = xstrfmt("%lu", oi_data.size);
+		} else if (!deref && starts_with(name, "objectsize") && oi_data.use_data) {
+			if (!strcmp(name, "objectsize")) {
+				v->value = oi_data.size;
+				v->s = xstrfmt("%lu", oi_data.size);
+			} else {
+				/* It can be only objectsize:disk, we checked it in parser */
+				v->value = oi_data.disk_size;
+				v->s = xstrfmt("%lu", oi_data.disk_size);
+			}
 			continue;
 		} else if (!strcmp(name, "HEAD")) {
 			if (atom->u.head && !strcmp(ref->refname, atom->u.head))

--
https://github.com/git/git/pull/493
Previous: Olga Telezhnaya
Message 4 of 4 in “ref-filter: start using oid_object_info”
  1. 1/4 ref-filter: start using oid_object_infoOlga Telezhnaya, May 18, 2018
  2. 4/4 ref-filter: add deltabase formatting optionOlga Telezhnaya, May 18, 2018
  3. 3/4 ref-filter: add tests for objectsize:diskOlga Telezhnaya, May 18, 2018
  4. 2/4 ref-filter: add objectsize:disk formatting optionOlga Telezhnaya, May 18, 2018

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.