From: Paolo Bonzini <bonzini@gnu.org>
To: <git@vger.kernel.org>
Cc: Junio C Hamano <gitster@pobox.com>
Subject: [PATCH 1/2] patch-id: extract parsing one diff out of generate_id_list
Date: Mon, 19 Apr 2010 10:46:13 +0200 [thread overview]
Message-ID: <1271666774-11619-1-git-send-email-bonzini@gnu.org> (raw)
In-Reply-To: <7vfx2ubxz1.fsf@alter.siamese.dyndns.org>
This simplifies a bit the next patch, since it will have more than one
condition to exit the loop.
Signed-off-by: Paolo Bonzini <bonzini@gnu.org>
---
On 04/17/2010 04:43 AM, Junio C Hamano wrote:
> Paolo Bonzini<bonzini@gnu.org> writes:
>
>> I use this when I had to edit the file-being-sent, e.g. to add cover
>> letters or an introduction to a patch series. Since some time passes
>> between format-patch and send-email, I want to test that the file I'm
>> sending is exactly what I have in the repository, and that I'm not
>> submitting the wrong series.
>
> Ok, that is what I missed when I mentioned ignore-if-in-upstream, iow,
> I thought "patch-cmp" were merely to check for failed detection of
> duplicates by format-patch. If you are editing the mbox file and let
> the patches sit there while origin/master may be progressing, then
> that is an entirely different story.
Yes, that is exactly the point. I sometimes have to edit the mbox file
so I cannot use "git send-email origin/master..", and I want a double
check that I'm not doing something stupid.
builtin/patch-id.c | 35 +++++++++++++++++++++--------------
1 files changed, 21 insertions(+), 14 deletions(-)
diff --git a/builtin/patch-id.c b/builtin/patch-id.c
index af0911e..78d24dc 100644
--- a/builtin/patch-id.c
+++ b/builtin/patch-id.c
@@ -28,16 +28,11 @@ static int remove_space(char *line)
return dst - line;
}
-static void generate_id_list(void)
+int get_one_patchid (unsigned char *next_sha1, git_SHA_CTX *ctx)
{
- static unsigned char sha1[20];
static char line[1000];
- git_SHA_CTX ctx;
int patchlen = 0;
-
- git_SHA1_Init(&ctx);
while (fgets(line, sizeof(line), stdin) != NULL) {
- unsigned char n[20];
char *p = line;
int len;
@@ -46,12 +41,8 @@ static void generate_id_list(void)
else if (!memcmp(line, "commit ", 7))
p += 7;
- if (!get_sha1_hex(p, n)) {
- flush_current_id(patchlen, sha1, &ctx);
- hashcpy(sha1, n);
- patchlen = 0;
- continue;
- }
+ if (!get_sha1_hex(p, next_sha1))
+ break;
/* Ignore commit comments */
if (!patchlen && memcmp(line, "diff ", 5))
@@ -68,9 +59,25 @@ static void generate_id_list(void)
/* Compute the sha without whitespace */
len = remove_space(line);
patchlen += len;
- git_SHA1_Update(&ctx, line, len);
+ git_SHA1_Update(ctx, line, len);
+ }
+ return patchlen;
+}
+
+
+static void generate_id_list(void)
+{
+ unsigned char sha1[20], n[20];
+ git_SHA_CTX ctx;
+ int patchlen;
+
+ git_SHA1_Init(&ctx);
+ while (!feof (stdin)) {
+ memset (n, 0, 20);
+ patchlen = get_one_patchid (n, &ctx);
+ flush_current_id(patchlen, sha1, &ctx);
+ hashcpy (sha1, n);
}
- flush_current_id(patchlen, sha1, &ctx);
}
static const char patch_id_usage[] = "git patch-id < patch";
--
1.6.6.1
next prev parent reply other threads:[~2010-04-19 8:46 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-16 16:22 [PATCH] patch-id: Add support for mbox format Paolo Bonzini
2010-04-16 18:30 ` Junio C Hamano
2010-04-16 20:55 ` Paolo Bonzini
2010-04-16 21:23 ` Junio C Hamano
2010-04-16 21:52 ` Paolo Bonzini
2010-04-17 2:43 ` Junio C Hamano
2010-04-19 8:46 ` Paolo Bonzini [this message]
2010-04-19 8:46 ` [PATCH 2/2] " Paolo Bonzini
2010-04-19 21:48 ` Junio C Hamano
2010-04-20 8:47 ` Paolo Bonzini
2010-04-20 16:54 ` Junio C Hamano
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=1271666774-11619-1-git-send-email-bonzini@gnu.org \
--to=bonzini@gnu.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/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).