From: Junio C Hamano <gitster@pobox.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: git@vger.kernel.org, sunshine@sunshineco.com, jrnieder@gmail.com,
peff@peff.net
Subject: Re: [PATCH v2 1/3] patch-id: make it stable against hunk reordering
Date: Fri, 28 Mar 2014 15:26:56 -0700 [thread overview]
Message-ID: <xmqqppl67ydr.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <xmqqzjka7z26.fsf@gitster.dls.corp.google.com> (Junio C. Hamano's message of "Fri, 28 Mar 2014 15:12:17 -0700")
Junio C Hamano <gitster@pobox.com> writes:
>> @@ -99,6 +116,18 @@ static int get_one_patchid(unsigned char *next_sha1, git_SHA_CTX *ctx, struct st
>> if (!memcmp(line, "@@ -", 4)) {
>> /* Parse next hunk, but ignore line numbers. */
>> scan_hunk_header(line, &before, &after);
>> + if (stable) {
>> + if (hunks) {
>> + flush_one_hunk(result, &ctx);
>> + memcpy(&ctx, &header_ctx,
>> + sizeof ctx);
>> + } else {
>> + /* Save ctx for next hunk. */
>> + memcpy(&header_ctx, &ctx,
>> + sizeof ctx);
>> + }
>> + }
>> + hunks++;
>> continue;
>> }
>>
>> @@ -107,7 +136,10 @@ static int get_one_patchid(unsigned char *next_sha1, git_SHA_CTX *ctx, struct st
>> break;
>>
>> /* Else we're parsing another header. */
>> + if (stable && hunks)
>> + flush_one_hunk(result, &ctx);
>> before = after = -1;
>> + hunks = 0;
>> }
>>
>> /* If we get here, we're inside a hunk. */
>> @@ -119,39 +151,46 @@ static int get_one_patchid(unsigned char *next_sha1, git_SHA_CTX *ctx, struct st
>> /* Compute the sha without whitespace */
>> len = remove_space(line);
>> patchlen += len;
>> - git_SHA1_Update(ctx, line, len);
>> + git_SHA1_Update(&ctx, line, len);
>> }
>>
>> if (!found_next)
>> hashclr(next_sha1);
>>
>> + flush_one_hunk(result, &ctx);
>
> What I read from these changes is that you do not do anything
> special about the per-file header, so two no overlapping patches
> with a single hunk each that touches the same path concatenated
> together would not result in the same patch-id as a single-patch
> that has the same two hunks. Which would break your earlier 'Yes,
> reordering only the hunks will not make sense, but before each hunk
> you could insert the same "diff --git a/... b/..." to make them a
> concatenation of patches that touch the same file', I would think.
>
> Is that what we want to happen? Or is my reading mistaken?
Heh, I was blind---copying into header_ctx and then restoring that
in preparation for the next round is exactly for duplicating the
per-file header sum to each and every hunk, so you are already doing
that.
prev parent reply other threads:[~2014-03-28 22:27 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-28 12:30 [PATCH v2 1/3] patch-id: make it stable against hunk reordering Michael S. Tsirkin
2014-03-28 12:30 ` [PATCH v2 2/3] patch-id: document new behaviour Michael S. Tsirkin
2014-03-28 12:30 ` [PATCH v2 3/3] patch-id-test: test new --stable and --unstable flags Michael S. Tsirkin
2014-03-28 18:20 ` [PATCH v2 1/3] patch-id: make it stable against hunk reordering Junio C Hamano
2014-03-28 19:20 ` Junio C Hamano
2014-03-30 10:52 ` Michael S. Tsirkin
2014-03-28 22:12 ` Junio C Hamano
2014-03-28 22:26 ` Junio C Hamano [this message]
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=xmqqppl67ydr.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=jrnieder@gmail.com \
--cc=mst@redhat.com \
--cc=peff@peff.net \
--cc=sunshine@sunshineco.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.