diff mbox

[v3,5/5] tools: Update to use 'hasher'

Message ID 20161201094652.11590-6-stephen@that.guru
State Accepted
Headers show

Commit Message

Stephen Finucane Dec. 1, 2016, 9:46 a.m. UTC
The old 'parser' module used to extract diffs from their surrounding
mbox fluff before hashing this. Seeing as this was only used in the
context of an actual git repo, avoid all of that rigmarole by just using
'git diff', which produces a plain diff, rather than 'git show'.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Cc: Paul Jakma <paul@jakma.org>
Cc: Tom Rini <trini@konsulko.com>
---
 tools/patchwork-update-commits | 2 +-
 tools/post-receive.hook        | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Comments

Tom Rini Dec. 1, 2016, 3:07 p.m. UTC | #1
On Thu, Dec 01, 2016 at 09:46:52AM +0000, Stephen Finucane wrote:
> The old 'parser' module used to extract diffs from their surrounding
> mbox fluff before hashing this. Seeing as this was only used in the
> context of an actual git repo, avoid all of that rigmarole by just using
> 'git diff', which produces a plain diff, rather than 'git show'.
> 
> Signed-off-by: Stephen Finucane <stephen@that.guru>
> Cc: Paul Jakma <paul@jakma.org>
> Cc: Tom Rini <trini@konsulko.com>
> ---
>  tools/patchwork-update-commits | 2 +-
>  tools/post-receive.hook        | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/patchwork-update-commits b/tools/patchwork-update-commits
> index d0f63a9..61952c0 100755
> --- a/tools/patchwork-update-commits
> +++ b/tools/patchwork-update-commits
> @@ -29,6 +29,6 @@ fi
>  
>  git rev-list --reverse "$@" |
>  while read commit; do
> -    hash=$(git show "$commit" | python $pwpath/parser.py -#)
> +    hash=$(git diff "$commit~..$commit" | python $pwpath/hasher.py)
>      $pwpath/bin/pwclient update -s Accepted -c "$commit" -h "$hash"
>  done
> diff --git a/tools/post-receive.hook b/tools/post-receive.hook
> index a19e1b2..9222264 100755
> --- a/tools/post-receive.hook
> +++ b/tools/post-receive.hook
> @@ -38,7 +38,7 @@ trap "do_exit=1" INT
>  get_patchwork_hash()
>  {
>      local hash
> -    hash=$(git show -C $1 | python $PWDIR/parser.py --hash)
> +    hash=$(git diff "$1~..$1" | python $pwpath/hasher.py)

copy/past error, it's PWDIR not pwpath in the hook.

After fixing that and the other changes I mentioned:

Tested-by: Tom Rini <trini@konsulko.com>
Daniel Axtens Dec. 2, 2016, 4:42 a.m. UTC | #2
Hi,

>      local hash
> -    hash=$(git show -C $1 | python $PWDIR/parser.py --hash)
> +    hash=$(git diff "$1~..$1" | python $pwpath/hasher.py)

Does this function appropriately in the presence of merge commits? ISTR
they had interesting behaviour and there was a difference between using
~ and using ^, and I just wanted to flag that for consideration...

Regards,
Daniel
Stephen Finucane Dec. 2, 2016, 10:18 a.m. UTC | #3
On Fri, 2016-12-02 at 15:42 +1100, Daniel Axtens wrote:
> Hi,
> 
> >      local hash
> > -    hash=$(git show -C $1 | python $PWDIR/parser.py --hash)
> > +    hash=$(git diff "$1~..$1" | python $pwpath/hasher.py)

That's a good point - I don't think the existing code handled merge
commits and neither will this...

> Does this function appropriately in the presence of merge commits?
> ISTR
> they had interesting behaviour and there was a difference between
> using
> ~ and using ^, and I just wanted to flag that for consideration...

That's a very good point - I had no idea these did different things but
it would appear so:

  http://stackoverflow.com/a/12527561/613428

I've gone with '~' for now to fix Tom's issue, but I'm going to
investigate this over the weekend and submit a follow-up patch if
necessary.

Stephen
diff mbox

Patch

diff --git a/tools/patchwork-update-commits b/tools/patchwork-update-commits
index d0f63a9..61952c0 100755
--- a/tools/patchwork-update-commits
+++ b/tools/patchwork-update-commits
@@ -29,6 +29,6 @@  fi
 
 git rev-list --reverse "$@" |
 while read commit; do
-    hash=$(git show "$commit" | python $pwpath/parser.py -#)
+    hash=$(git diff "$commit~..$commit" | python $pwpath/hasher.py)
     $pwpath/bin/pwclient update -s Accepted -c "$commit" -h "$hash"
 done
diff --git a/tools/post-receive.hook b/tools/post-receive.hook
index a19e1b2..9222264 100755
--- a/tools/post-receive.hook
+++ b/tools/post-receive.hook
@@ -38,7 +38,7 @@  trap "do_exit=1" INT
 get_patchwork_hash()
 {
     local hash
-    hash=$(git show -C $1 | python $PWDIR/parser.py --hash)
+    hash=$(git diff "$1~..$1" | python $pwpath/hasher.py)
     echo $hash
     test -n "$hash"
 }