Hi, >> > When I create a patch file using >> > fossil diff > patch.txt >> > >> > the resulting file cannot be used for patching. It seems there is an >> > extra 0D line separator (0d 0d 0a) for the actual source lines. (---, >> > +++, @@ lines are OK). >> >> Fossil is not taking any steps to insert extra CR characters in the >> output. The output of "fossil diff" is generated using printf(). Do >> you suppose that the windows implementation of printf() is trying to >> be "helpful" by converting NL to CRNL? > > Yup. One of the "benefits" of using that OS. The patch file must > have been written in text mode. Here are some references:
Shedding some light on this, since I've also just been caught by it: If the file was checked into the repository with CRLF line endings, then diff.c:break_into_lines() preserves the CR on the end of each line. When preparing the diff for display diff.c:appendDiffLine() appends a \n to the end of the line, which is translated via STDOUT (which is a text mode stream) to \r\n, thus leading to \r\r\n in the output. In short, Fossil only works with binary files for checkout/commit, but assumes a Unix text file for diff, causing a CR to be part of the line being diff'ed rather than part of the EOL. One solution is to strip CR from the diff before displaying it: Index: src/diff.c =================================================================== --- src/diff.c +++ src/diff.c @@ -558,10 +558,11 @@ diff_all(&c); if( pOut ){ /* Compute a context diff if requested */ contextDiff(&c, pOut, nContext); + blob_remove_cr(pOut); free(c.aFrom); free(c.aTo); free(c.aEdit); return 0; }else{ This works as expected in most cases, with the peculiar side-effect that if you convert a file from Unix (LF) to DOS (CRLF) line endings or vice versa the diff will show all lines changed, but applying it as a patch will result in no change (since the added/removed CR doesn't make it into the diff output). I think the above patch is what you want to do 99% of the time. Or that could just be me ;) Regards, Twylite _______________________________________________ fossil-users mailing list fossil-users@lists.fossil-scm.org http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users