Re: [PATCH v2 1/3] patch-id: make it stable against hunk reordering

2014-03-30 Thread Michael S. Tsirkin
On Fri, Mar 28, 2014 at 12:20:13PM -0700, Junio C Hamano wrote: Michael S. Tsirkin m...@redhat.com writes: Patch id changes if you reorder hunks in a diff. As the result is functionally equivalent, this is surprising to many people. In particular, reordering hunks is helpful to make

[PATCH v2 1/3] patch-id: make it stable against hunk reordering

2014-03-28 Thread Michael S. Tsirkin
Patch id changes if you reorder hunks in a diff. As the result is functionally equivalent, this is surprising to many people. In particular, reordering hunks is helpful to make patches more readable (e.g. API header diff before implementation diff). In git, it is often done e.g. using the -O

Re: [PATCH v2 1/3] patch-id: make it stable against hunk reordering

2014-03-28 Thread Junio C Hamano
Michael S. Tsirkin m...@redhat.com writes: Patch id changes if you reorder hunks in a diff. Reording files is fine, and as we discussed, having multiple patches that touch the same path is fine, but do not sound as if you are allowing to reorder hunks inside a single patch that touch a single

Re: [PATCH v2 1/3] patch-id: make it stable against hunk reordering

2014-03-28 Thread Junio C Hamano
Michael S. Tsirkin m...@redhat.com writes: Patch id changes if you reorder hunks in a diff. As the result is functionally equivalent, this is surprising to many people. In particular, reordering hunks is helpful to make patches more readable (e.g. API header diff before implementation diff).

Re: [PATCH v2 1/3] patch-id: make it stable against hunk reordering

2014-03-28 Thread Junio C Hamano
Michael S. Tsirkin m...@redhat.com writes: +static void flush_one_hunk(unsigned char *result, git_SHA_CTX *ctx) { - int patchlen = 0, found_next = 0; + unsigned char hash[20]; + unsigned short carry = 0; + int i; + + git_SHA1_Final(hash, ctx); +

Re: [PATCH v2 1/3] patch-id: make it stable against hunk reordering

2014-03-28 Thread Junio C Hamano
Junio C Hamano gits...@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. */