Re: RFE: git-patch-id should handle patches without leading "diff"
From: Jonathan Nieder <hidden>
Date: 2018-12-07 22:34:11
Ævar Arnfjörð Bjarmason wrote:
On Fri, Dec 07 2018, Jonathan Nieder wrote:
quoted
The patch-id appears to only care about the diff text, so it should be able to handle this. So if we have a better heuristic for where the diff starts, it would be good to use it.No, the patch-id doesn't just care about the diff, it cares about the context before the diff too.
Sorry, I did a bad job of communicating. When I said "diff text", I was including context. [...]
Observe that the diff --git line matters, we hash it:
$ git diff-tree -p HEAD~.. | git patch-id
5870d115b7e2a9a936ab8fdc254932234413c710 0000000000000000000000000000000000000000
$ git diff-tree --src-prefix=a/ --dst-prefix=b/ -p HEAD~.. | git patch-id --stable
5870d115b7e2a9a936ab8fdc254932234413c710 0000000000000000000000000000000000000000
$ git diff-tree --src-prefix=x/ --dst-prefix=y/ -p HEAD~.. | git patch-id --stable
4cd136f2b98760150f700ac6a5b126389d6d05a7 0000000000000000000000000000000000000000Oh, hm. That's unfortunate. [...]
So it seems most sensible to me if this is going to be supported that we
go a bit beyond the call of duty and fake up the start of it, namely:
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
To be:
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.cRight. We may want to handle diff.mnemonicPrefix as well. Jonathan