Index: src/checkin.c ================================================================== --- src/checkin.c +++ src/checkin.c @@ -907,13 +907,10 @@ int encodingOk, /* Non-zero if encoding warnings should be disabled. */ const char *zFilename /* The full name of the file being committed. */ ){ int fUnicode; /* return value of starts_with_utf16_bom() */ int lookFlags; /* output flags from looks_like_utf8/utf16() */ - int fHasNul; /* the blob contains one or more NUL chars */ - int fHasCrLf; /* the blob contains one or more CR/LF pairs */ - int fHasLength; /* the blob contains an overly long line */ char *zMsg; /* Warning message */ Blob fname; /* Relative pathname of the file */ static int allOk = 0; /* Set to true to disable this routine */ if( allOk ) return 0; @@ -927,42 +924,50 @@ lookFlags = looks_like_utf8(p); } }else{ lookFlags = looks_like_utf8(p); } - fHasNul = (lookFlags & LOOK_NUL); - fHasCrLf = (lookFlags & LOOK_CRLF); - fHasLength = (lookFlags & LOOK_LENGTH); - if( fHasNul || fHasLength || fHasCrLf || fUnicode ){ + if( lookFlags&(LOOK_NUL|LOOK_LENGTH|LOOK_LONE_CR|LOOK_CRLF) || fUnicode ){ const char *zWarning; const char *zDisable; const char *zConvert = "c=convert/"; Blob ans; char cReply; - if( fHasNul || fHasLength ){ + if( lookFlags&(LOOK_NUL|LOOK_LENGTH) ){ if( binOk ){ return 0; /* We don't want binary warnings for this file. */ } - if( !fHasNul && fHasLength ){ + if( (lookFlags&LOOK_LONE_CR) && !(lookFlags&LOOK_NUL) ){ + zWarning = "CR line endings (would be handled as binary)"; + }else if( (lookFlags&LOOK_LENGTH) && !(lookFlags&LOOK_NUL) ){ zWarning = "long lines"; + zConvert = ""; /* We cannot convert binary files. */ }else{ zWarning = "binary data"; + zConvert = ""; /* We cannot convert binary files. */ } zDisable = "\"binary-glob\" setting"; - zConvert = ""; /* We cannot convert binary files. */ - }else if( fHasCrLf && fUnicode ){ + }else if( lookFlags&(LOOK_LONE_CR|LOOK_CRLF) && fUnicode ){ if( crnlOk && encodingOk ){ return 0; /* We don't want CR/NL and Unicode warnings for this file. */ } - zWarning = "CR/NL line endings and Unicode"; + if( lookFlags&LOOK_LONE_CR ){ + zWarning = "CR line endings and Unicode"; + }else{ + zWarning = "CR/NL line endings and Unicode"; + } zDisable = "\"crnl-glob\" and \"encoding-glob\" settings"; - }else if( fHasCrLf ){ + }else if( lookFlags&(LOOK_LONE_CR|LOOK_CRLF) ){ if( crnlOk ){ return 0; /* We don't want CR/NL warnings for this file. */ } - zWarning = "CR/NL line endings"; + if( lookFlags&LOOK_LONE_CR ){ + zWarning = "CR line endings"; + }else{ + zWarning = "CR/NL line endings"; + } zDisable = "\"crnl-glob\" setting"; }else{ if( encodingOk ){ return 0; /* We don't want encoding warnings for this file. */ } @@ -993,11 +998,13 @@ int bomSize; const unsigned char *bom = get_utf8_bom(&bomSize); fwrite(bom, 1, bomSize, f); blob_to_utf8_no_bom(p, 0); } - blob_remove_cr(p); + if( lookFlags&(LOOK_LONE_CR|LOOK_CRLF) ){ + blob_remove_cr(p); + } fwrite(blob_buffer(p), 1, blob_size(p), f); fclose(f); return 1; }else if( cReply!='y' && cReply!='Y' ){ fossil_fatal("Abandoning commit due to %s in %s",