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

[PATCH 3/4] Make for-each-ref allow atom names like "<name>:<something>"

From
APAndy Parkins <andyparkins@gmail.com>
Date
Sep 28, 2007, 14:17 UTC
Message-ID
<200709281517.39245.andyparkins@gmail.com>
In-Reply-To
<200709281516.05438.andyparkins@gmail.com>

In anticipation of supplying a per-field date format specifier, this patch makes parse_atom() in builtin-for-each-ref.c allow atoms that have a valid atom name (as determined by the valid_atom[] table) followed by a colon, followed by an arbitrary string.

The arbitrary string is where the format for the atom will be specified.

Note, if different formats are specified for the same atom, multiple entries will be made in the used_atoms table to allow them to be distinguished by the grab_XXXX() functions.

Signed-off-by: Andy Parkins <andyparkins@gmail.com>
---
 builtin-for-each-ref.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/builtin-for-each-ref.c b/builtin-for-each-ref.c
index 0afa1c5..3280516 100644
--- a/builtin-for-each-ref.c
+++ b/builtin-for-each-ref.c
@@ -106,7 +106,13 @@ static int parse_atom(const char *atom, const char *ep)
 	/* Is the atom a valid one? */
 	for (i = 0; i < ARRAY_SIZE(valid_atom); i++) {
 		int len = strlen(valid_atom[i].name);
-		if (len == ep - sp && !memcmp(valid_atom[i].name, sp, len))
+		/* If the atom name has a colon, strip it and everything after
+		 * it off - it specifies the format for this entry, and
+		 * shouldn't be used for checking against the valid_atom table */
+		const char *formatp = strrchr(sp, ':' );
+		if (formatp == NULL )
+			formatp = ep;
+		if (len == formatp - sp && !memcmp(valid_atom[i].name, sp, len))
 			break;
 	}
 
-- 
1.5.3.2.105.gf47f2-dirty
Previous: Andy ParkinsNext: Andy Parkins
Message 12 of 15 in “Add a --dateformat= option to git-for-each-ref”
  1. Add a --dateformat= option to git-for-each-refAndy Parkins, Sep 26, 2007
  2. Jeff KingSep 26, 2007
  3. Andy ParkinsSep 28, 2007
  4. 1/4 Add parse_date_format() convenience function for converting a format string to an enum date_modeAndy Parkins, Sep 28, 2007
  5. 2/4 Use parse_date_format() in revisions.c to parse the --date parameterAndy Parkins, Sep 28, 2007
  6. Johannes SchindelinSep 28, 2007
  7. Andy ParkinsSep 28, 2007
  8. Junio C HamanoSep 28, 2007
  9. 1/3 Use parse_date_format() convenience function for converting a format string to an enum date_mode in revisions.cAndy Parkins, Sep 29, 2007
  10. 2/3 Make for-each-ref allow atom names like "<name>:<something>"Andy Parkins, Sep 29, 2007
  11. 3/3 Make for-each-ref's grab_date() support per-atom formattingAndy Parkins, Sep 29, 2007
  12. 3/4 Make for-each-ref allow atom names like "<name>:<something>"Andy Parkins, Sep 28, 2007
  13. 4/4 Make for-each-ref's grab_date() support per-atom formattingAndy Parkins, Sep 28, 2007
  14. Junio C HamanoSep 29, 2007
  15. Jeff KingSep 28, 2007

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.