git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 3/3] patch-id-test: test new --stable and --unstable flags

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Mar 28, 2014, 00:25 UTC
Message-ID
<CAPig+cQ4=joCcjyhOLGAiTV2WCLk7a1Vb5R=wNCLwX1gTp8V9A@mail.gmail.com>
In-Reply-To
<1395912239-29663-3-git-send-email-mst@redhat.com>
On Thu, Mar 27, 2014 at 5:25 AM, Michael S. Tsirkin <mst@redhat.com> wrote:
Show 33 quoted lines
> Verify that patch ID is now stable against hunk reordering.
>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>  t/t4204-patch-id.sh | 68 +++++++++++++++++++++++++++++++++++++++++++++++++----
>  1 file changed, 63 insertions(+), 5 deletions(-)
>
> diff --git a/t/t4204-patch-id.sh b/t/t4204-patch-id.sh
> index d2c930d..75f77ef 100755
> --- a/t/t4204-patch-id.sh
> +++ b/t/t4204-patch-id.sh
> @@ -5,12 +5,27 @@ test_description='git patch-id'
>  . ./test-lib.sh
>
>  test_expect_success 'setup' '
> -       test_commit initial foo a &&
> -       test_commit first foo b &&
> +       test_commit initial-foo foo a &&
> +       test_commit initial-bar bar a &&
> +       echo b > foo &&
> +       echo b > bar &&
> +       git commit -a -m first &&
>         git checkout -b same HEAD^ &&
> -       test_commit same-msg foo b &&
> +       echo b > foo &&
> +       echo b > bar &&
> +       git commit -a -m same-msg &&
>         git checkout -b notsame HEAD^ &&
> -       test_commit notsame-msg foo c
> +       echo c > foo &&
> +       echo c > bar &&
> +       git commit -a -m notsame-msg &&
> +       cat > bar-then-foo <<EOF
Broken &&-chain.

If you use -EOF, you can indent the content rather than having to hang it on the left margin. Better, use -\EOF to indicate that you're not interested in interpolation within the block.

Show 80 quoted lines
> +bar
> +foo
> +EOF
> +       cat > foo-then-bar <<EOF
> +foo
> +bar
> +EOF
>  '
>
>  test_expect_success 'patch-id output is well-formed' '
> @@ -23,11 +38,33 @@ calc_patch_id () {
>                 sed "s# .*##" > patch-id_"$1"
>  }
>
> +calc_patch_id_unstable () {
> +       git patch-id --unstable |
> +               sed "s# .*##" > patch-id_"$1"
> +}
> +
> +calc_patch_id_stable () {
> +       git patch-id --stable |
> +               sed "s# .*##" > patch-id_"$1"
> +}
> +
> +
>  get_patch_id () {
> -       git log -p -1 "$1" | git patch-id |
> +       git log -p -1 "$1" -O bar-then-foo -- | git patch-id |
> +               sed "s# .*##" > patch-id_"$1"
> +}
> +
> +get_patch_id_stable () {
> +       git log -p -1 "$1" -O bar-then-foo | git patch-id --stable |
> +               sed "s# .*##" > patch-id_"$1"
> +}
> +
> +get_patch_id_unstable () {
> +       git log -p -1 "$1" -O bar-then-foo | git patch-id --unstable |
>                 sed "s# .*##" > patch-id_"$1"
>  }
>
> +
>  test_expect_success 'patch-id detects equality' '
>         get_patch_id master &&
>         get_patch_id same &&
> @@ -56,6 +93,27 @@ test_expect_success 'whitespace is irrelevant in footer' '
>         test_cmp patch-id_master patch-id_same
>  '
>
> +test_expect_success 'file order is irrelevant by default' '
> +       get_patch_id master &&
> +       git checkout same &&
> +       git format-patch -1 --stdout -O foo-then-bar | calc_patch_id same &&
> +       test_cmp patch-id_master patch-id_same
> +'
> +
> +test_expect_success 'file order is irrelevant with --stable' '
> +       get_patch_id_stable master &&
> +       git checkout same &&
> +       git format-patch -1 --stdout -O foo-then-bar | calc_patch_id_stable same &&
> +       test_cmp patch-id_master patch-id_same
> +'
> +
> +test_expect_success 'file order is relevant with --unstable' '
> +       get_patch_id_unstable master &&
> +       git checkout same &&
> +       git format-patch -1 --stdout -O foo-then-bar | calc_patch_id_unstable notsame &&
> +       ! test_cmp patch-id_master patch-id_notsame
> +'
> +
>  test_expect_success 'patch-id supports git-format-patch MIME output' '
>         get_patch_id master &&
>         git checkout same &&
> --
> MST
>
> --
> 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: Michael S. TsirkinNext: Junio C Hamano
Message 4 of 10 in “patch-id: make it stable against hunk reordering”
  1. 1/3 patch-id: make it stable against hunk reorderingMichael S. Tsirkin, Mar 27, 2014
  2. 2/3 patch-id: document new behaviourMichael S. Tsirkin, Mar 27, 2014
  3. 3/3 patch-id-test: test new --stable and --unstable flagsMichael S. Tsirkin, Mar 27, 2014
  4. Eric SunshineMar 28, 2014
  5. Junio C HamanoMar 27, 2014
  6. Michael S. TsirkinMar 27, 2014
  7. Michael S. TsirkinMar 27, 2014
  8. Junio C HamanoMar 27, 2014
  9. Michael S. TsirkinMar 27, 2014
  10. Michael S. TsirkinMar 27, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.