Re: [PATCH 2/2] patch-id: Add support for mbox format

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Junio C Hamano
Date: Monday, April 19, 2010 - 2:48 pm

Paolo Bonzini <bonzini@gnu.org> writes:


I don't know how this patch will affect the difficulty of enhancing it to
handle MIME attachments later, but let's say we won't worry about it for
now, because we do not even know if we want to do so at this moment.

I fixed up some style issues locally before applying, but please be
careful next time.

 - One SP after a keyword used in syntactic constructs (e.g. "if (cond)",
   not "while(cond)"); your patches were fine wrt this;

 - No SP after a function (e.g. "memcpy(args...)", not "memcpy (args...)").

Also please be careful when calling get_sha1_hex(); an unsuccessful call
to this function is allowed to clobber the buffer.  In addition to the
style fixes, I squashed something like this (not exactly this).

Thanks.

 builtin/patch-id.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/builtin/patch-id.c b/builtin/patch-id.c
index 40af5c7..4785411 100644
--- a/builtin/patch-id.c
+++ b/builtin/patch-id.c
@@ -61,7 +61,8 @@ int get_one_patchid(unsigned char *next_sha1, git_SHA_CTX *ctx)
 {
 	static char line[1000];
 	int patchlen = 0;
-	int before = -1, after = -1;
+	int before = -1, after = -1, found_next = 0;
+
 	while (fgets(line, sizeof(line), stdin) != NULL) {
 		char *p = line;
 		int len;
@@ -73,8 +74,10 @@ int get_one_patchid(unsigned char *next_sha1, git_SHA_CTX *ctx)
 		else if (!memcmp(line, "From ", 5))
 			p += 5;
 
-		if (!get_sha1_hex(p, next_sha1))
+		if (!get_sha1_hex(p, next_sha1)) {
+			found_next = 1;
 			break;
+		}
 
 		/* Ignore commit comments */
 		if (!patchlen && memcmp(line, "diff ", 5))
@@ -117,6 +120,8 @@ int get_one_patchid(unsigned char *next_sha1, git_SHA_CTX *ctx)
 		patchlen += len;
 		git_SHA1_Update(ctx, line, len);
 	}
+	if (!found_next)
+		hashclr(next_sha1);
 	return patchlen;
 }
 
@@ -128,8 +133,8 @@ static void generate_id_list(void)
 	int patchlen;
 
 	git_SHA1_Init(&ctx);
+	hashclr(sha1);
 	while (!feof(stdin)) {
-		memset(n, 0, 20);
 		patchlen = get_one_patchid(n, &ctx);
 		flush_current_id(patchlen, sha1, &ctx);
 		hashcpy(sha1, n);
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] patch-id: Add support for mbox format, Paolo Bonzini, (Fri Apr 16, 9:22 am)
Re: [PATCH] patch-id: Add support for mbox format, Junio C Hamano, (Fri Apr 16, 11:30 am)
Re: [PATCH] patch-id: Add support for mbox format, Paolo Bonzini, (Fri Apr 16, 1:55 pm)
Re: [PATCH] patch-id: Add support for mbox format, Junio C Hamano, (Fri Apr 16, 2:23 pm)
Re: [PATCH] patch-id: Add support for mbox format, Paolo Bonzini, (Fri Apr 16, 2:52 pm)
Re: [PATCH] patch-id: Add support for mbox format, Junio C Hamano, (Fri Apr 16, 7:43 pm)
[PATCH 2/2] patch-id: Add support for mbox format, Paolo Bonzini, (Mon Apr 19, 1:46 am)
Re: [PATCH 2/2] patch-id: Add support for mbox format, Junio C Hamano, (Mon Apr 19, 2:48 pm)
Re: [PATCH 2/2] patch-id: Add support for mbox format, Paolo Bonzini, (Tue Apr 20, 1:47 am)
Re: [PATCH 2/2] patch-id: Add support for mbox format, Junio C Hamano, (Tue Apr 20, 9:54 am)