bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: patch and CVS


From: Bruno Haible
Subject: Re: patch and CVS
Date: Sun, 23 Sep 2001 20:08:57 +0200 (CEST)

Carlo Wood <address@hidden> wrote:
> Diffs generated by 'cvs diff' are unuable with patch, and have been
> for many years.  Why is this never fixed?  Is there a way to work
> around this?

I've been using the appended program for years without problems.
It converts 'cvs diff' output to proper 'patch' input.

Bruno

============================ cvsdiff2patch ============================
#!/usr/bin/clisp -C
;; -*- lisp -*-
;; File: <cvsdiff2patch - 1998-09-28 Mon 18:40:51 EDT address@hidden>
;; Convert a CVS diff to a patchable diff.
;; Usage: cvs diff | cvsdiff2patch | patch -p0
;; Copyright (C) 1996 Bruno Haible, 1998 Sam Steingold
;; released under GPL2.

(defun filter-diff (istream ostream)
  (do* ((eof (list nil)) path base
        (line (read-line istream nil eof) (read-line istream nil eof))
        (len (length line) (length line)))
       ((eq line eof))
    (declare (simple-string line) (fixnum len))
    (cond ((or (and (>= len 2) (string= line "? " :end1 2)) ; skip
               (and (>= len 2) (string= line "==" :end1 2))
               (and (>= len 3) (string= line "RCS" :end1 3))
               (and (>= len 4) (string= line "diff" :end1 4))
               (and (>= len 10) (string= line "retrieving" :end1 10))))
          ((and (>= len 7) (string= line "Index: " :end1 7))
           (setq path (subseq line 7)
                 base (subseq path (1+ (or (position #\/ path :from-end t)
                                           -1)))))
          ((and (>= len (+ 4 (length base))) (string= line "*** " :end1 4)
                (or (string= line base :start1 4 :end1 (+ 4 (length base)))
                    (string= line "/tmp/" :start1 4 :end1 9)))
           (format ostream "*** ~a~a~%" path
                   (subseq line (position #\tab line))))
          ((and (>= len (+ 4 (length base))) (string= line "--- " :end1 4)
                (or (string= line base :start1 4 :end1 (+ 4 (length base)))
                    (string= line "/tmp/" :start1 4 :end1 9)))
           (format ostream "--- ~a~a~%" path
                   (subseq line (position #\tab line))))
          ((write-line line ostream)))))

(filter-diff *standard-input* *standard-output*)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]