3 test_description
='git patch-id'
7 test_expect_success
'setup' '
8 test_commit initial foo a &&
9 test_commit first foo b &&
10 git checkout -b same HEAD^ &&
11 test_commit same-msg foo b &&
12 git checkout -b notsame HEAD^ &&
13 test_commit notsame-msg foo c
16 test_expect_success
'patch-id output is well-formed' '
17 git log -p -1 | git patch-id > output &&
18 grep "^[a-f0-9]\{40\} $(git rev-parse HEAD)$" output
23 sed "s# .*##" > patch-id_
"$1"
27 git log
-p -1 "$1" | git patch-id |
28 sed "s# .*##" > patch-id_
"$1"
31 test_expect_success
'patch-id detects equality' '
32 get_patch_id master &&
34 test_cmp patch-id_master patch-id_same
37 test_expect_success
'patch-id detects inequality' '
38 get_patch_id master &&
39 get_patch_id notsame &&
40 ! test_cmp patch-id_master patch-id_notsame
43 test_expect_success
'patch-id supports git-format-patch output' '
44 get_patch_id master &&
46 git format-patch -1 --stdout | calc_patch_id same &&
47 test_cmp patch-id_master patch-id_same &&
48 set `git format-patch -1 --stdout | git patch-id` &&
49 test "$2" = `git rev-parse HEAD`
52 test_expect_success
'whitespace is irrelevant in footer' '
53 get_patch_id master &&
55 git format-patch -1 --stdout | sed "s/ \$//" | calc_patch_id same &&
56 test_cmp patch-id_master patch-id_same
59 test_expect_success
'patch-id supports git-format-patch MIME output' '
60 get_patch_id master &&
62 git format-patch -1 --attach --stdout | calc_patch_id same &&
63 test_cmp patch-id_master patch-id_same