home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cvs1929.zip / cvs / scripts / fix-diff.awk < prev    next >
Text File  |  1998-08-02  |  2KB  |  54 lines

  1. #
  2. # $Id: fix-diff.awk,v 1.1.2.1 1998/07/31 10:49:28 ahuber Exp $
  3. #
  4. # This awk script adds the directory prefix to the file names in
  5. # "cvs diff -c" generated diffs so "patch -p0 -i diffs" will find
  6. # the file to patch, even if it is not in the current directory.
  7. # It also removes empty diffs.
  8. #
  9. # Usage:
  10. #  cvs -Q diff -c | awk -f fix-diff.awk >diffs
  11. #
  12. # Copyright (C) 1998  Andreas Huber <ahuber@ping.at>
  13. #
  14. # This program is free software; you can redistribute it and/or
  15. # modify it under the terms of the GNU General Public License
  16. # as published by the Free Software Foundation; either version 2
  17. # of the License, or (at your option) any later version.
  18. #
  19. # This program is distributed in the hope that it will be useful,
  20. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  22. # GNU General Public License for more details.
  23. #
  24. # You should have received a copy of the GNU General Public License
  25. # along with this program; see the file COPYING. If not, write to
  26. # the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  27. # Boston, MA 02111-1307, USA.
  28. #
  29. /^Index: .*$/, /^\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*$/ {
  30.     if ($0 ~ /^Index: .*$/) {
  31.         file = $2
  32.         nlines = 0
  33.         delete linebuf
  34.     }
  35.     if ($0 ~ /^(\*\*\*|---)[     ][^     ]*[     ][0-9]+\/[0-9]+\/[0-9]+[     ][0-9]+:[0-9]+:[0-9]+([     ][0-9.]*)?$/) {
  36.         linebuf[nlines++] = gensub($2, file, 1)
  37.         next
  38.     }
  39.     if ($0 ~ /^\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*$/) {
  40.         for (i = 0; i < nlines; ++i) {
  41.             print linebuf[i]
  42.         }
  43.         print $0
  44.         next
  45.     }
  46.     linebuf[nlines++] = $0
  47.     next
  48. }
  49. {
  50.     if ($0 !~ /^\? /)
  51.         print $0
  52. }
  53.  
  54.