[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Wrong assumption about unidiff syntax in libsvn_diff?

From: Julian Foad <julianfoad_at_btopenworld.com>
Date: Tue, 20 Nov 2012 16:19:42 +0000 (GMT)

I committed a patch implementing this, and incorporating your patch below, in r1411723.

I would say it's a portability fix and should be considered for backport -- but I don't feel strongly.

- Julian

Stefan Sperling wrote:
> Currently, lines such as:
> \\ this is a comment
> anywhere in the patch are silently ignored.
>
> If we follow your suggestion we must treat any such lines as hunk
> terminators and assume the hunk lacks a trailing newline.
> I suppose such a change is correct but it's a behaviour change so
> I wouldn't want to backport it to 1.7.x.
>
> Below is a patch. Diff parser tests and patch tests are still passing.
>
> [[[
> * subversion/libsvn_diff/parse-diff.c
>   (parse_next_hunk): Treat any line that starts with a backslash as a
>   hunk terminator, indicating that the hunk does not end with EOL.
>   Comments following the backslash might be localised or missing
>   in which case parsing the patch would fail.
>
> Suggested by: brane
> ]]]
>
> Index: subversion/libsvn_diff/parse-diff.c
> ===================================================================
> --- subversion/libsvn_diff/parse-diff.c    (revision 1411078)
> +++ subversion/libsvn_diff/parse-diff.c    (working copy)
> @@ -555,15 +555,11 @@ parse_next_hunk(svn_diff_hunk_t **hunk,
>       pos = 0;
>       SVN_ERR(svn_io_file_seek(apr_file, APR_CUR, &pos, iterpool));
>
> -      /* Lines starting with a backslash are comments, such as
> +      /* Lines starting with a backslash indicate a missing EOL:
>         * "\ No newline at end of file". */
>       if (line->data[0] == '\\')
>         {
> -          if (in_hunk &&
> -              ((!*is_property &&
> -                strcmp(line->data, "\\ No newline at end of
> file") == 0) ||
> -              (*is_property &&
> -                strcmp(line->data, "\\ No newline at end of
> property") == 0)))
> +          if (in_hunk)
>             {
>               char eolbuf[2];
>               apr_size_t len;
>
Received on 2012-11-20 17:20:19 CET

This is an archived mail posted to the Subversion Dev mailing list.