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

[PATCH 2/4] pretty: make show_ident_date public

From
Jeff King <peff@peff.net>
Date
May 2, 2014, 01:07 UTC
Message-ID
<20140502010722.GB25413@sigill.intra.peff.net>
In-Reply-To
<20140502010328.GA30556@sigill.intra.peff.net>

We use this function internally to format "Date" lines in commit logs, but other parts of the code will want it, too.

Signed-off-by: Jeff King <peff@peff.net>
---
 cache.h  | 7 +++++++
 pretty.c | 4 ++--
 2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/cache.h b/cache.h
index 107ac61..dd9e689 100644
--- a/cache.h
+++ b/cache.h
@@ -1046,6 +1046,13 @@ struct ident_split {
 extern int split_ident_line(struct ident_split *, const char *, int);
 
 /*
+ * Like show_date, but pull the timestamp and tz parameters from
+ * the ident_split. It will also sanity-check the values and produce
+ * a well-known sentinel date if they appear bogus.
+ */
+const char *show_ident_date(const struct ident_split *id, enum date_mode mode);
+
+/*
  * Compare split idents for equality or strict ordering. Note that we
  * compare only the ident part of the line, ignoring any timestamp.
  *
diff --git a/pretty.c b/pretty.c
index 3c43db5..e1e2cad 100644
--- a/pretty.c
+++ b/pretty.c
@@ -393,8 +393,8 @@ static void add_rfc2047(struct strbuf *sb, const char *line, size_t len,
 	strbuf_addstr(sb, "?=");
 }
 
-static const char *show_ident_date(const struct ident_split *ident,
-				   enum date_mode mode)
+const char *show_ident_date(const struct ident_split *ident,
+			    enum date_mode mode)
 {
 	unsigned long date = 0;
 	long tz = 0;
-- 
1.9.1.656.ge8a0637
Previous: Jeff KingNext: Jeff King
Message 6 of 9 in “[RFD] use approxidate for "git commit --date=xyz"?”
  1. Linus TorvaldsApr 30, 2014
  2. Junio C HamanoApr 30, 2014
  3. Jeff KingMay 1, 2014
  4. 0/4 approxidate for "git commit --date=foo"Jeff King, May 2, 2014
  5. 1/4 commit: use split_ident_line to compare author/committerJeff King, May 2, 2014
  6. 2/4 pretty: make show_ident_date publicJeff King, May 2, 2014
  7. 3/4 commit: print "Date" line when the user has set dateJeff King, May 2, 2014
  8. 4/4 commit: accept more date formats for "--date"Jeff King, May 2, 2014
  9. Peter KreftingMay 7, 2014

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.