git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: "Shawn O. Pearce" <spearce@spearce.org>
Cc: Mark Lodato <lodatom@gmail.com>,
	git@vger.kernel.org, Nicolas Pitre <nico@fluxnic.net>
Subject: Re: [PATCH 2/2] fast-import: validate entire ident string
Date: Mon, 26 Apr 2010 11:24:22 -0500	[thread overview]
Message-ID: <20100426162422.GA10859@progeny.tock> (raw)
In-Reply-To: <20100426160247.GD7502@spearce.org>

Shawn O. Pearce wrote:

> 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));
-- 

  reply	other threads:[~2010-04-26 16:24 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-24  0:45 [PATCH] fast-import docs: LT is valid in email, GT is not Mark Lodato
2010-04-24 16:06 ` [PATCH] fsck: check ident lines in commit objects Jonathan Nieder
2010-04-24 16:59   ` Jonathan Nieder
2010-04-24 19:04   ` Shawn O. Pearce
2010-04-24 20:38     ` [PATCH 0/2] fast-import: tighten up parsing ident line Jonathan Nieder
2010-04-24 20:50       ` [PATCH 1/2] fast-import: be strict about formatting of raw dates Jonathan Nieder
2010-04-24 21:10       ` [PATCH 2/2] fast-import: validate entire ident string Jonathan Nieder
2010-04-26 16:02         ` Shawn O. Pearce
2010-04-26 16:24           ` Jonathan Nieder [this message]
2010-04-26 16:30             ` Jonathan Nieder
2010-05-04 17:11           ` Junio C Hamano
2010-04-24 16:12 ` [PATCH] fast-import docs: LT is valid in email, GT is not Jonathan Nieder
2010-04-24 16:59   ` Mark Lodato

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=20100426162422.GA10859@progeny.tock \
    --to=jrnieder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=lodatom@gmail.com \
    --cc=nico@fluxnic.net \
    --cc=spearce@spearce.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).