Discussion:
[Cocci] Perforce support, or generating list of files that would be changed?
Timur Tabi
2018-07-26 19:52:58 UTC
Permalink
I need to run the "p4 edit" command before spatch can modify any file.
Is there a way to do either of the following:

1. Provide a list of files that "spatch --in-place --dir ." would edit
2. Have spatch run the "p4 edit" command on a file before changing it
Julia Lawall
2018-07-26 20:26:59 UTC
Permalink
Post by Timur Tabi
I need to run the "p4 edit" command before spatch can modify any file.
1. Provide a list of files that "spatch --in-place --dir ." would edit
I'm not sure to understand what you are asking for here.
Post by Timur Tabi
2. Have spatch run the "p4 edit" command on a file before changing it
I don't think so. Maybe you could make a script to do this.

julia
Timur Tabi
2018-07-26 20:38:02 UTC
Permalink
Post by Julia Lawall
Post by Timur Tabi
1. Provide a list of files that "spatch --in-place --dir ." would edit
I'm not sure to understand what you are asking for here.
So when I run "spatch --in-place --dir .", spatch run my cocci script
on a bunch of files, but not all of them will need to be changed. For
some, there won't be a match.

I would like a list of files that spatch *would* change in this
situation. Something like "spatch --list-only", so I can do this:

$ p4 edit `spatch --sp-file nvprintf.cocci --in-place --list-only --dir .`
$ spatch --sp-file nvprintf.cocci --in-place --list-only --dir .
Julia Lawall
2018-07-26 20:42:45 UTC
Permalink
Post by Timur Tabi
Post by Julia Lawall
Post by Timur Tabi
1. Provide a list of files that "spatch --in-place --dir ." would edit
I'm not sure to understand what you are asking for here.
So when I run "spatch --in-place --dir .", spatch run my cocci script
on a bunch of files, but not all of them will need to be changed. For
some, there won't be a match.
I would like a list of files that spatch *would* change in this
$ p4 edit `spatch --sp-file nvprintf.cocci --in-place --list-only --dir .`
$ spatch --sp-file nvprintf.cocci --in-place --list-only --dir .
Coccinelle can make a list of relevant files, but there is not a guarantee
that the rule will actually match on those files. The option is
--selected-only.

julia
Timur Tabi
2018-07-27 20:52:32 UTC
Permalink
Post by Julia Lawall
Coccinelle can make a list of relevant files, but there is not a guarantee
that the rule will actually match on those files. The option is
--selected-only.
Thanks, that works. I also discovered that this works:

spatch --very-quiet --dir . | lsdiff --strip 1

Loading...