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

Re: [PATCH 4/5] coccinelle: put sane filenames into output patches

From
Derrick Stolee <stolee@gmail.com>
Date
Jul 23, 2018, 14:34 UTC
Message-ID
<9f560db6-b50a-e2f3-7215-d046c60e255a@gmail.com>
In-Reply-To
<20180723135100.24288-5-szeder.dev@gmail.com>
On 7/23/2018 9:50 AM, SZEDER Gábor wrote:
Show 35 quoted lines
> Coccinelle outputs its suggested transformations as patches, whose
> header looks something like this:
>
>    --- commit.c
>    +++ /tmp/cocci-output-19250-7ae78a-commit.c
>
> Note the lack of 'diff --opts <old> <new>' line, the differing number
> of path components on the --- and +++ lines, and the nonsensical
> filename on the +++ line.  'patch -p0' can still apply these patches,
> as it takes the filename to be modified from the --- line.  Alas, 'git
> apply' can't, because it takes the filename from the +++ line, and
> then complains about the nonexisting file.
>
> Pass the '--patch .' options to Coccinelle via the SPATCH_FLAGS 'make'
> variable, as it seems to make it generate proper context diff patches,
> with the header starting with a 'diff ...' line and containing sane
> filenames.  The resulting 'contrib/coccinelle/*.cocci.patch' files
> then can be applied both with 'git apply' and 'patch' (even without
> '-p0').
>
> Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
> ---
>   Makefile | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/Makefile b/Makefile
> index 73e2d16926..72ea29df4e 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -564,7 +564,7 @@ SPATCH = spatch
>   export TCL_PATH TCLTK_PATH
>   
>   SPARSE_FLAGS =
> -SPATCH_FLAGS = --all-includes
> +SPATCH_FLAGS = --all-includes --patch .

Thank you for this! These garbage filenames cause significant pain when trying to apply the suggested patch.

Previous: SZEDER GáborNext: SZEDER Gábor
Message 12 of 31 in “Misc Coccinelle-related improvements”
  1. 0/5 Misc Coccinelle-related improvementsSZEDER Gábor, Jul 23, 2018
  2. 1/5 coccinelle: mark the 'coccicheck' make target as .PHONYSZEDER Gábor, Jul 23, 2018
  3. Derrick StoleeJul 23, 2018
  4. Junio C HamanoJul 23, 2018
  5. 2/5 coccinelle: use $(addsuffix) in 'coccicheck' make targetSZEDER Gábor, Jul 23, 2018
  6. Junio C HamanoJul 23, 2018
  7. 3/5 coccinelle: exclude sha1dc source files from static analysisSZEDER Gábor, Jul 23, 2018
  8. Eric SunshineJul 23, 2018
  9. SZEDER GáborJul 23, 2018
  10. Eric SunshineJul 23, 2018
  11. 4/5 coccinelle: put sane filenames into output patchesSZEDER Gábor, Jul 23, 2018
  12. Derrick StoleeJul 23, 2018
  13. 5/5 coccinelle: extract dedicated make target to clean Coccinelle's resultsSZEDER Gábor, Jul 23, 2018
  14. Derrick StoleeJul 23, 2018
  15. Duy NguyenJul 23, 2018
  16. René ScharfeJul 23, 2018
  17. Junio C HamanoJul 23, 2018
  18. [PoC] coccinelle: make Coccinelle-related make targets more fine-grainedSZEDER Gábor, Aug 2, 2018
  19. René ScharfeAug 2, 2018
  20. Jeff KingAug 2, 2018
  21. Jeff KingAug 2, 2018
  22. Jonathan NiederAug 3, 2018
  23. Jeff KingAug 3, 2018
  24. Jonathan NiederAug 5, 2018
  25. Eric SunshineAug 2, 2018
  26. Jeff KingAug 2, 2018
  27. Ævar Arnfjörð BjarmasonAug 2, 2018
  28. Julia LawallAug 3, 2018
  29. Jonathan NiederAug 3, 2018
  30. Julia LawallAug 3, 2018
  31. Julia LawallAug 3, 2018

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.