37 messages in com.perforce.perforce-userRemoving unchanged files from changel...| Subject: | Removing unchanged files from changelist?![]() |
|---|---|
| From: | Scot...@seaslug.org (Scot...@seaslug.org) |
| Date: | 06/15/1999 04:40:15 PM |
| List: | com.perforce.perforce-user |
"Kendall Bennett" <KendallB at scitechsoft.com> wrote:
Steve Cogorno <Steven.Cogorno at Eng.Sun.COM> wrote:
p4 diff -sr | p4 -x - revert
Ok, this works like a charm!
Now is there some way to do something similar to run 'grep' over all changed files, looking for a particular string? Specifically I want to check for hard coded debug interrupts (DebugInt() is our macro for this) in the code before any submissions are made.
How about this:
p4 diff -sa | xargs grep DebugInt /dev/null
along with some explanation...
1) Do 'p4 help diff' to see what the '-sa' switch does.
2) Use 'xargs' (on Unix or Unix-like toolsets elsewhere) to bundle up command args for [possibly] multiple invocations of the given command (see 'man xargs').
3) Give 'grep' an initial filename of '/dev/null' to make sure that it always has at least 2 filenames on its command line. That way, it will be sure to always include the filename prefix on each of its output lines. Otherwise, if you end up with a 'grep' invocation that got only one filename, [most?] greps would leave the filename prefix off of the output.
And, if you want to restrict things to particular types of filenames, try something like this:
p4 diff -sa //.../%1.c | xargs grep DebugInt /dev/null
or whatever...the general idea being to use Perforce filemasking to restrict the set of files that 'p4 diff' operates over.
Scott.Blachowicz at seaslug.org




