git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Parkins <andyparkins@gmail.com>
To: git@vger.kernel.org
Subject: [PATCH 3/4] Make for-each-ref allow atom names like "<name>:<something>"
Date: Fri, 28 Sep 2007 15:17:39 +0100	[thread overview]
Message-ID: <200709281517.39245.andyparkins@gmail.com> (raw)
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

  parent reply	other threads:[~2007-09-28 14:17 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-26  9:09 [PATCH] Add a --dateformat= option to git-for-each-ref Andy Parkins
2007-09-26 12:58 ` Jeff King
2007-09-28 14:15   ` Andy Parkins
2007-09-28 14:17     ` [PATCH 1/4] Add parse_date_format() convenience function for converting a format string to an enum date_mode Andy Parkins
2007-09-28 14:17     ` [PATCH 2/4] Use parse_date_format() in revisions.c to parse the --date parameter Andy Parkins
2007-09-28 15:22       ` Johannes Schindelin
2007-09-28 18:00         ` Andy Parkins
2007-09-28 18:11           ` Junio C Hamano
2007-09-29  7:39             ` [PATCH 1/3] Use parse_date_format() convenience function for converting a format string to an enum date_mode in revisions.c Andy Parkins
2007-09-29  7:39             ` [PATCH 2/3] Make for-each-ref allow atom names like "<name>:<something>" Andy Parkins
2007-09-29  7:39             ` [PATCH 3/3] Make for-each-ref's grab_date() support per-atom formatting Andy Parkins
2007-09-28 14:17     ` Andy Parkins [this message]
2007-09-28 14:17     ` [PATCH 4/4] " Andy Parkins
2007-09-29  8:17       ` Junio C Hamano
2007-09-28 18:47     ` [PATCH] Add a --dateformat= option to git-for-each-ref Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200709281517.39245.andyparkins@gmail.com \
    --to=andyparkins@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).