Skip to content

Commit 6f93d26

Browse files
bebarinogitster
authored andcommitted
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 <[email protected]> Signed-off-by: Stephen Boyd <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 83232e3 commit 6f93d26

File tree

2 files changed

+32
-6
lines changed

2 files changed

+32
-6
lines changed

Documentation/git-format-patch.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ of 'base commit' in topological order before the patches can be applied.
583583
The 'base commit' is shown as "base-commit: " followed by the 40-hex of
584584
the commit object name. A 'prerequisite patch' is shown as
585585
"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`
587587
command.
588588

589589
Imagine that on top of the public commit P, you applied well-known

t/t4014-format-patch.sh

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,27 @@ test_expect_success setup '
3636
git checkout master &&
3737
git diff-tree -p C2 | git apply --index &&
3838
test_tick &&
39-
git commit -m "Master accepts moral equivalent of #2"
39+
git commit -m "Master accepts moral equivalent of #2" &&
4040
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
4160
'
4261

4362
test_expect_success "format-patch --ignore-if-in-upstream" '
@@ -1559,16 +1578,23 @@ test_expect_success 'format-patch -o overrides format.outputDirectory' '
15591578
'
15601579

15611580
test_expect_success 'format-patch --base' '
1562-
git checkout side &&
1581+
git checkout patchid &&
15631582
git format-patch --stdout --base=HEAD~3 -1 | tail -n 7 >actual1 &&
15641583
git format-patch --stdout --base=HEAD~3 HEAD~.. | tail -n 7 >actual2 &&
15651584
echo >expected &&
15661585
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 &&
15691588
signature >> expected &&
15701589
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
15721598
'
15731599

15741600
test_expect_success 'format-patch --base errors out when base commit is in revision list' '

0 commit comments

Comments
 (0)