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

Re: [PATCH 2/2] fast-import: validate entire ident string

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Apr 26, 2010, 16:24 UTC
Message-ID
<20100426162422.GA10859@progeny.tock>
In-Reply-To
<20100426160247.GD7502@spearce.org>
Shawn O. Pearce wrote:
Show 6 quoted lines
> Some importers are probably
> writing "committer <bob> ...." when pulling from systems that don't
> have a concept of name vs. email (e.g. CVS or SVN).  I highly suspect
> that requiring two spaces here will cause a lot of importers to fail.
> 
> If we really need to require two spaces,

It is not a huge deal, but ‘git commit --amend’ will die with "invalid commit" if it does not find a “ <” sequence after the “author ” string. Maybe that should be changed. Patch below.

> I think we need to honor
> the documented input format but rewrite the line inside of the
> import process to match the two space convention.
Yes, that’s doable.

Thanks for the feedback, Jonathan

diff --git a/builtin/commit.c b/builtin/commit.c
index c5ab683..c56f2c9 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -449,19 +449,23 @@ static void determine_author_info(void)
 	date = getenv("GIT_AUTHOR_DATE");
 
 	if (use_message && !renew_authorship) {
-		const char *a, *lb, *rb, *eol;
+		const char *a, *n, *lb, *rb, *eol;
 
 		a = strstr(use_message_buffer, "\nauthor ");
 		if (!a)
 			die("invalid commit: %s", use_message);
 
-		lb = strstr(a + 8, " <");
-		rb = strstr(a + 8, "> ");
-		eol = strchr(a + 8, '\n');
+		n = a + strlen("\nauthor");
+		lb = strstr(n, " <");
+		rb = strstr(lb + 2, "> ");
+		eol = strchr(rb + 2, '\n');
 		if (!lb || !rb || !eol)
 			die("invalid commit: %s", use_message);
 
-		name = xstrndup(a + 8, lb - (a + 8));
+		if (lb == n)
+			name = xstrndup("", 0);
+		else
+			name = xstrndup(n + 1, lb - (n + 1));
 		email = xstrndup(lb + 2, rb - (lb + 2));
 		date = xstrndup(rb + 2, eol - (rb + 2));
 	}
@@ -470,7 +474,7 @@ static void determine_author_info(void)
 		const char *lb = strstr(force_author, " <");
 		const char *rb = strchr(force_author, '>');
 
-		if (!lb || !rb)
+		if (!lb || !rb || rb < lb)
 			die("malformed --author parameter");
 		name = xstrndup(force_author, lb - force_author);
 		email = xstrndup(lb + 2, rb - (lb + 2));
Previous: Shawn O. PearceNext: Jonathan Nieder
Message 9 of 13 in “fast-import docs: LT is valid in email, GT is not”
  1. fast-import docs: LT is valid in email, GT is notMark Lodato, Apr 24, 2010
  2. fsck: check ident lines in commit objectsJonathan Nieder, Apr 24, 2010
  3. Jonathan NiederApr 24, 2010
  4. Shawn O. PearceApr 24, 2010
  5. 0/2 fast-import: tighten up parsing ident lineJonathan Nieder, Apr 24, 2010
  6. 1/2 fast-import: be strict about formatting of raw datesJonathan Nieder, Apr 24, 2010
  7. 2/2 fast-import: validate entire ident stringJonathan Nieder, Apr 24, 2010
  8. Shawn O. PearceApr 26, 2010
  9. Jonathan NiederApr 26, 2010
  10. Jonathan NiederApr 26, 2010
  11. Junio C HamanoMay 4, 2010
  12. Jonathan NiederApr 24, 2010
  13. Mark LodatoApr 24, 2010

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.