format-patch: inform user that patch-id generation is unstable
I tried out 'git format-patch --base' with a set of commits that modifies more than one file. It turns out that the way this command is implemented it actually uses the unstable version of patch-id instead of the stable version that's documented. When I tried to modify the existing test to use 'git patch-id --stable' vs. 'git patch-id --unstable' I found that it didn't matter, the test still passed. Let's expand on the test here so it is a little more complicated and then use that to show that the patch-id generation is actually unstable vs. stable. Update the documentation as well. Cc: Xiaolong Ye <xiaolong.ye@intel.com> Signed-off-by: Stephen Boyd <sboyd@kernel.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Stephen Boyd committed
Apr 26, 2019 at 16:51 UTC
6f93d261fa8ca6a84c2e03e20558c0ddca3c05c3
2 files changed
+32
-6
Documentation/git-format-patch.txt
+1
-1
@@ -583,7 +583,7 @@ of 'base commit' in topological order before the patches can be applied.
583
The 'base commit' is shown as "base-commit: " followed by the 40-hex of
584
the commit object name. A 'prerequisite patch' is shown as
585
"prerequisite-patch-id: " followed by the 40-hex 'patch id', which can
586
-be obtained by passing the patch through the `git patch-id --stable`
586
+be obtained by passing the patch through the `git patch-id --unstable`
587
command.
588
589
Imagine that on top of the public commit P, you applied well-known
t/t4014-format-patch.sh
+31
-5
@@ -36,8 +36,27 @@ test_expect_success setup '
36
git checkout master &&
37
git diff-tree -p C2 | git apply --index &&
38
test_tick &&
39
- git commit -m "Master accepts moral equivalent of #2"
39
+ git commit -m "Master accepts moral equivalent of #2" &&
40
41
+ git checkout side &&
42
+ git checkout -b patchid &&
43
+ for i in 5 6 1 2 3 A 4 B C 7 8 9 10 D E F; do echo "$i"; done >file2 &&
44
+ for i in 1 2 3 A 4 B C 7 8 9 10 D E F 5 6; do echo "$i"; done >file3 &&
45
+ for i in 8 9 10; do echo "$i"; done >file &&
46
+ git add file file2 file3 &&
47
+ test_tick &&
48
+ git commit -m "patchid 1" &&
49
+ for i in 4 A B 7 8 9 10; do echo "$i"; done >file2 &&
50
+ for i in 8 9 10 5 6; do echo "$i"; done >file3 &&
51
+ git add file2 file3 &&
52
+ test_tick &&
53
+ git commit -m "patchid 2" &&
54
+ for i in 10 5 6; do echo "$i"; done >file &&
55
+ git add file &&
56
+ test_tick &&
57
+ git commit -m "patchid 3" &&
58
+
59
+ git checkout master
60
'
61
62
test_expect_success "format-patch --ignore-if-in-upstream" '
@@ -1559,16 +1578,23 @@ test_expect_success 'format-patch -o overrides format.outputDirectory' '
1578
'
1579
1580
test_expect_success 'format-patch --base' '
1562
- git checkout side &&
1581
+ git checkout patchid &&
1582
git format-patch --stdout --base=HEAD~3 -1 | tail -n 7 >actual1 &&
1583
git format-patch --stdout --base=HEAD~3 HEAD~.. | tail -n 7 >actual2 &&
1584
echo >expected &&
1585
echo "base-commit: $(git rev-parse HEAD~3)" >>expected &&
1567
- echo "prerequisite-patch-id: $(git show --patch HEAD~2 | git patch-id --stable | awk "{print \$1}")" >>expected &&
1568
- echo "prerequisite-patch-id: $(git show --patch HEAD~1 | git patch-id --stable | awk "{print \$1}")" >>expected &&
1586
+ echo "prerequisite-patch-id: $(git show --patch HEAD~2 | git patch-id --unstable | awk "{print \$1}")" >>expected &&
1587
+ echo "prerequisite-patch-id: $(git show --patch HEAD~1 | git patch-id --unstable | awk "{print \$1}")" >>expected &&
1588
signature >> expected &&
1589
test_cmp expected actual1 &&
1571
- test_cmp expected actual2
1590
+ test_cmp expected actual2 &&
1591
+ echo >fail &&
1592
+ echo "base-commit: $(git rev-parse HEAD~3)" >>fail &&
1593
+ echo "prerequisite-patch-id: $(git show --patch HEAD~2 | git patch-id --stable | awk "{print \$1}")" >>fail &&
1594
+ echo "prerequisite-patch-id: $(git show --patch HEAD~1 | git patch-id --stable | awk "{print \$1}")" >>fail &&
1595
+ signature >> fail &&
1596
+ ! test_cmp fail actual1 &&
1597
+ ! test_cmp fail actual2
1598
'
1599
1600
test_expect_success 'format-patch --base errors out when base commit is in revision list' '