Here it is. If you prefer a link I will upload it somewhere:
--- src/db.c
+++ src/db.c
@@ -1894,10 +1894,11 @@
{ "autosync", 0, 0, 0, "on" },
{ "binary-glob", 0, 32, 1, "" },
{ "clearsign", 0, 0, 0, "off" },
{ "case-sensitive",0, 0, 0, "on" },
{ "crnl-glob", 0, 16, 1, "" },
+ { "crnl-autofix-glob", 0, 16, 1, "" },
{ "default-perms", 0, 16, 0, "u" },
{ "diff-command", 0, 16, 0, "" },
{ "dont-push", 0, 0, 0, "off" },
{ "editor", 0, 16, 0, "" },
{ "gdiff-command", 0, 16, 0, "gdiff" },
@@ -1983,10 +1984,14 @@
** be unsigned. Default: off
**
** crnl-glob A comma or newline-separated list of GLOB patterns
for
** (versionable) text files in which it is ok to have CR+NL line
endings.
** Set to "*" to disable CR+NL checking.
+**
+** crnl-autofix-glob A comma or newline-separated list of GLOB
patterns for
+** (versionable) text files which should have CR+NL line endings
+** automatically fixed to CR
**
** default-perms Permissions given automatically to new users. For
more
** information on permissions see Users page in Server
** Administration of the HTTP UI. Default: u.
**
--- src/checkin.c
+++ src/checkin.c
@@ -816,16 +816,24 @@
blob_appendf(pOut, "U %F\n", zUserOvrd ? zUserOvrd : g.zLogin);
md5sum_blob(pOut, &mcksum);
blob_appendf(pOut, "Z %b\n", &mcksum);
if( pnFBcard ) *pnFBcard = nFBcard;
}
+
+/*
+** Correct al \r\n line endings in a text file to \n
+*/
+static void cr_fix(Blob *p, const char *zFilename){
+ blob_remove_cr(p);
+ blob_write_to_file(p, zFilename);
+}
/*
** Issue a warning and give the user an opportunity to abandon out
** if a \r\n line ending is seen in a text file.
*/
-static void cr_warning(const Blob *p, const char *zFilename){
+static void cr_warning(Blob *p, const char *zFilename){
int nCrNl = 0; /* Number of \r\n line endings seen */
const unsigned char *z; /* File text */
int n; /* Size of the file in bytes */
int lastNl = 0; /* Characters since last \n */
int i; /* Loop counter */
@@ -854,17 +862,19 @@
if( nCrNl ){
char c;
file_relative_name(zFilename, &fname, 0);
blob_zero(&ans);
zMsg = mprintf(
- "%s contains CR/NL line endings; commit anyhow (yes/no/all)?",
+ "%s contains CR/NL line endings; commit anyhow
(yes/no/all/fix)?",
blob_str(&fname));
prompt_user(zMsg, &ans);
fossil_free(zMsg);
c = blob_str(&ans)[0];
if( c=='a' ){
allOk = 1;
+ }else if( c=='f' ){
+ cr_fix(p, zFilename);
}else if( c!='y' ){
fossil_fatal("Abandoning commit due to CR+NL line endings in %s",
blob_str(&fname));
}
blob_reset(&ans);
@@ -1150,33 +1160,42 @@
/* Step 1: Insert records for all modified files into the blob
** table. If there were arguments passed to this command, only
** the identified fils are inserted (if they have been modified).
*/
db_prepare(&q,
- "SELECT id, %Q || pathname, mrid, %s FROM vfile "
+ "SELECT id, %Q || pathname, mrid, %s, %s FROM vfile "
"WHERE chnged==1 AND NOT deleted AND file_is_selected(id)",
- g.zLocalRoot, glob_expr("pathname", db_get("crnl-glob",""))
+ g.zLocalRoot,
+ glob_expr("pathname", db_get("crnl-glob","")),
+ glob_expr("pathname", db_get("crnl-autofix-glob",""))
);
while( db_step(&q)==SQLITE_ROW ){
int id, rid;
const char *zFullname;
Blob content;
- int crnlOk;
+ int crnlOk, crnlFix;
id = db_column_int(&q, 0);
zFullname = db_column_text(&q, 1);
rid = db_column_int(&q, 2);
crnlOk = db_column_int(&q, 3);
+ crnlFix = db_column_int(&q, 4);
blob_zero(&content);
if( file_wd_islink(zFullname) ){
/* Instead of file content, put link destination path */
blob_read_link(&content, zFullname);
}else{
blob_read_from_file(&content, zFullname);
}
- if( !crnlOk ) cr_warning(&content, zFullname);
+ if( !crnlOk ){
+ if( crnlFix ){
+ cr_fix(&content, zFullname);
+ }else{
+ cr_warning(&content, zFullname);
+ }
+ }
nrid = content_put(&content);
blob_reset(&content);
if( rid>0 ){
content_deltify(rid, nrid, 0);
}
On Mon, Jun 11, 2012 at 10:18 PM, Richard Hipp <[email protected]> wrote:
>
>
> On Mon, Jun 11, 2012 at 3:12 PM, Baruch Burstein <[email protected]>wrote:
>
>> I have made a small addition that I would like to propose for fossil
>> (option to auto-convert line endings). How and where should I send it?
>>
>
> Post the diffs, or a link to the diffs, on this mailing list.
>
>
>
>>
>> --
>> ˙uʍop-ǝpısdn sı ɹoʇıuoɯ ɹnoʎ 'sıɥʇ pɐǝɹ uɐɔ noʎ ɟı
>>
>>
>> _______________________________________________
>> fossil-users mailing list
>> [email protected]
>> http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users
>>
>>
>
>
> --
> D. Richard Hipp
> [email protected]
>
> _______________________________________________
> fossil-users mailing list
> [email protected]
> http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users
>
>
--
˙uʍop-ǝpısdn sı ɹoʇıuoɯ ɹnoʎ 'sıɥʇ pɐǝɹ uɐɔ noʎ ɟı
_______________________________________________
fossil-users mailing list
[email protected]
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users