[Top][All Lists]

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

Re: diff-goto-source fails if "-p" is in diff-switches

From: Per Cederqvist
Subject: Re: diff-goto-source fails if "-p" is in diff-switches
Date: 08 Feb 2007 10:49:36 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

Per Cederqvist <ceder@lysator.liu.se> writes:

> Revision 1.94 of diff-mode.el (committed 2007-01-11) introduced a
> regression.  Now, the diff-goto-source function fails with either of
> the error messages below if "-p" is present in diff-switches:
>     Unrecognized context diff first hunk header format
>     Unrecognized unified diff hunk header format
> The enclosed patch makes diff-sanity-check-hunk less picky on the
> format, so that diff-goto-sources starts working again even if
> diff-switches is set to "-p" or "-up".
> One way to reproduce the problem is to check out the Emacs source code
> from CVS, edit emacs/src/abbrev.c, inserting a character in the
> syms_of_abbrev function, saving the buffer, do M-x set-variable RET
> diff-switches RET "-up" RET, do M-x vc-diff, move the cursor down to
> the character you inserted, and press C-c C-c.  Instead of jumping to
> the same place in the source buffer, you will get the second error
> message reported above.
>     /ceder

I see that the committer dediced to improve my patch before committing
it.  Unfortunately, the improvement casuses context diffs produced
with "-p" to fail.  Here is an example of a diff header for a context
diff with "-p":

*************** func_name(int x, int y)
*** 10,14 ****

Note how the extra text is placed: at the end of the all-star line,
not after the numbers.  This is documented in the diff manual:

> Then they add that line to the end of the line of asterisks in the
> context format, or to the `@@' line in unified format.

The enclosed patch (which was produced using "cvs diff -c -F
'^(defun'") just to show another way to produce that output format)
fixes this problem.  Please note that "." in a regexp does not match a
newline, so this regexp should be safe.

If there are versions of diff that actually place the function name
after the line numbers, the trailing dollar sign in the regexp should
be removed.  I'm not aware of any, though.  I have tested GNU diff
2.8.7 and GNU diff 2.8.1.

    /ceder, who doesn't like getting the blame for committing code I
            never wrote -- if you edit this before making the commit,
            please say so in the ChangeLog entry as well

Attachment: patch
Description: Fix parsing of \"diff -p\" for context diffs.

reply via email to

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