Fossil SCM
Allow commit warning for binary data to be disabled via the 'binary-glob' setting.
Commit
d25f6ddf35ae0e42a3792042cd5ff07657ed3070
Parent
7d881d82802ec8c…
1 file changed
+15
-5
+15
-5
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -885,11 +885,16 @@ | ||
| 885 | 885 | /* |
| 886 | 886 | ** Issue a warning and give the user an opportunity to abandon out |
| 887 | 887 | ** if a Unicode (UTF-16) byte-order-mark (BOM) or a \r\n line ending |
| 888 | 888 | ** is seen in a text file. |
| 889 | 889 | */ |
| 890 | -static void commit_warning(const Blob *p, int crnlOk, const char *zFilename){ | |
| 890 | +static void commit_warning( | |
| 891 | + const Blob *p, /* The content of the file being committed. */ | |
| 892 | + int crnlOk, /* Non-zero if CR/NL warnings should be disabled. */ | |
| 893 | + int binOk, /* Non-zero if binary warnings should be disabled. */ | |
| 894 | + const char *zFilename /* The full name of the file being committed. */ | |
| 895 | +){ | |
| 891 | 896 | int eType; /* return value of looks_like_utf8/utf16() */ |
| 892 | 897 | int fUnicode; /* return value of starts_with_utf16_bom() */ |
| 893 | 898 | char *zMsg; /* Warning message */ |
| 894 | 899 | Blob fname; /* Relative pathname of the file */ |
| 895 | 900 | static int allOk = 0; /* Set to true to disable this routine */ |
| @@ -908,10 +913,13 @@ | ||
| 908 | 913 | if( crnlOk ){ |
| 909 | 914 | return; /* We don't want CR/NL warnings for this file. */ |
| 910 | 915 | } |
| 911 | 916 | zWarning = "CR/NL line endings"; |
| 912 | 917 | }else if( eType==0 ){ |
| 918 | + if( binOk ){ | |
| 919 | + return; /* We don't want binary warnings for this file. */ | |
| 920 | + } | |
| 913 | 921 | zWarning = "binary data"; |
| 914 | 922 | }else{ |
| 915 | 923 | zWarning = "Unicode"; |
| 916 | 924 | } |
| 917 | 925 | file_relative_name(zFilename, &fname, 0); |
| @@ -1216,34 +1224,36 @@ | ||
| 1216 | 1224 | /* Step 1: Insert records for all modified files into the blob |
| 1217 | 1225 | ** table. If there were arguments passed to this command, only |
| 1218 | 1226 | ** the identified fils are inserted (if they have been modified). |
| 1219 | 1227 | */ |
| 1220 | 1228 | db_prepare(&q, |
| 1221 | - "SELECT id, %Q || pathname, mrid, %s, chnged FROM vfile " | |
| 1229 | + "SELECT id, %Q || pathname, mrid, %s, chnged, %s FROM vfile " | |
| 1222 | 1230 | "WHERE chnged==1 AND NOT deleted AND is_selected(id)", |
| 1223 | - g.zLocalRoot, glob_expr("pathname", db_get("crnl-glob","")) | |
| 1231 | + g.zLocalRoot, glob_expr("pathname", db_get("crnl-glob","")), | |
| 1232 | + glob_expr("pathname", db_get("binary-glob","")) | |
| 1224 | 1233 | ); |
| 1225 | 1234 | while( db_step(&q)==SQLITE_ROW ){ |
| 1226 | 1235 | int id, rid; |
| 1227 | 1236 | const char *zFullname; |
| 1228 | 1237 | Blob content; |
| 1229 | - int crnlOk, chnged; | |
| 1238 | + int crnlOk, binOk, chnged; | |
| 1230 | 1239 | |
| 1231 | 1240 | id = db_column_int(&q, 0); |
| 1232 | 1241 | zFullname = db_column_text(&q, 1); |
| 1233 | 1242 | rid = db_column_int(&q, 2); |
| 1234 | 1243 | crnlOk = db_column_int(&q, 3); |
| 1235 | 1244 | chnged = db_column_int(&q, 4); |
| 1245 | + binOk = db_column_int(&q, 5); | |
| 1236 | 1246 | |
| 1237 | 1247 | blob_zero(&content); |
| 1238 | 1248 | if( file_wd_islink(zFullname) ){ |
| 1239 | 1249 | /* Instead of file content, put link destination path */ |
| 1240 | 1250 | blob_read_link(&content, zFullname); |
| 1241 | 1251 | }else{ |
| 1242 | 1252 | blob_read_from_file(&content, zFullname); |
| 1243 | 1253 | } |
| 1244 | - commit_warning(&content, crnlOk, zFullname); | |
| 1254 | + commit_warning(&content, crnlOk, binOk, zFullname); | |
| 1245 | 1255 | if( chnged==1 && contains_merge_marker(&content) ){ |
| 1246 | 1256 | Blob fname; /* Relative pathname of the file */ |
| 1247 | 1257 | |
| 1248 | 1258 | nConflict++; |
| 1249 | 1259 | file_relative_name(zFullname, &fname, 0); |
| 1250 | 1260 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -885,11 +885,16 @@ | |
| 885 | /* |
| 886 | ** Issue a warning and give the user an opportunity to abandon out |
| 887 | ** if a Unicode (UTF-16) byte-order-mark (BOM) or a \r\n line ending |
| 888 | ** is seen in a text file. |
| 889 | */ |
| 890 | static void commit_warning(const Blob *p, int crnlOk, const char *zFilename){ |
| 891 | int eType; /* return value of looks_like_utf8/utf16() */ |
| 892 | int fUnicode; /* return value of starts_with_utf16_bom() */ |
| 893 | char *zMsg; /* Warning message */ |
| 894 | Blob fname; /* Relative pathname of the file */ |
| 895 | static int allOk = 0; /* Set to true to disable this routine */ |
| @@ -908,10 +913,13 @@ | |
| 908 | if( crnlOk ){ |
| 909 | return; /* We don't want CR/NL warnings for this file. */ |
| 910 | } |
| 911 | zWarning = "CR/NL line endings"; |
| 912 | }else if( eType==0 ){ |
| 913 | zWarning = "binary data"; |
| 914 | }else{ |
| 915 | zWarning = "Unicode"; |
| 916 | } |
| 917 | file_relative_name(zFilename, &fname, 0); |
| @@ -1216,34 +1224,36 @@ | |
| 1216 | /* Step 1: Insert records for all modified files into the blob |
| 1217 | ** table. If there were arguments passed to this command, only |
| 1218 | ** the identified fils are inserted (if they have been modified). |
| 1219 | */ |
| 1220 | db_prepare(&q, |
| 1221 | "SELECT id, %Q || pathname, mrid, %s, chnged FROM vfile " |
| 1222 | "WHERE chnged==1 AND NOT deleted AND is_selected(id)", |
| 1223 | g.zLocalRoot, glob_expr("pathname", db_get("crnl-glob","")) |
| 1224 | ); |
| 1225 | while( db_step(&q)==SQLITE_ROW ){ |
| 1226 | int id, rid; |
| 1227 | const char *zFullname; |
| 1228 | Blob content; |
| 1229 | int crnlOk, chnged; |
| 1230 | |
| 1231 | id = db_column_int(&q, 0); |
| 1232 | zFullname = db_column_text(&q, 1); |
| 1233 | rid = db_column_int(&q, 2); |
| 1234 | crnlOk = db_column_int(&q, 3); |
| 1235 | chnged = db_column_int(&q, 4); |
| 1236 | |
| 1237 | blob_zero(&content); |
| 1238 | if( file_wd_islink(zFullname) ){ |
| 1239 | /* Instead of file content, put link destination path */ |
| 1240 | blob_read_link(&content, zFullname); |
| 1241 | }else{ |
| 1242 | blob_read_from_file(&content, zFullname); |
| 1243 | } |
| 1244 | commit_warning(&content, crnlOk, zFullname); |
| 1245 | if( chnged==1 && contains_merge_marker(&content) ){ |
| 1246 | Blob fname; /* Relative pathname of the file */ |
| 1247 | |
| 1248 | nConflict++; |
| 1249 | file_relative_name(zFullname, &fname, 0); |
| 1250 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -885,11 +885,16 @@ | |
| 885 | /* |
| 886 | ** Issue a warning and give the user an opportunity to abandon out |
| 887 | ** if a Unicode (UTF-16) byte-order-mark (BOM) or a \r\n line ending |
| 888 | ** is seen in a text file. |
| 889 | */ |
| 890 | static void commit_warning( |
| 891 | const Blob *p, /* The content of the file being committed. */ |
| 892 | int crnlOk, /* Non-zero if CR/NL warnings should be disabled. */ |
| 893 | int binOk, /* Non-zero if binary warnings should be disabled. */ |
| 894 | const char *zFilename /* The full name of the file being committed. */ |
| 895 | ){ |
| 896 | int eType; /* return value of looks_like_utf8/utf16() */ |
| 897 | int fUnicode; /* return value of starts_with_utf16_bom() */ |
| 898 | char *zMsg; /* Warning message */ |
| 899 | Blob fname; /* Relative pathname of the file */ |
| 900 | static int allOk = 0; /* Set to true to disable this routine */ |
| @@ -908,10 +913,13 @@ | |
| 913 | if( crnlOk ){ |
| 914 | return; /* We don't want CR/NL warnings for this file. */ |
| 915 | } |
| 916 | zWarning = "CR/NL line endings"; |
| 917 | }else if( eType==0 ){ |
| 918 | if( binOk ){ |
| 919 | return; /* We don't want binary warnings for this file. */ |
| 920 | } |
| 921 | zWarning = "binary data"; |
| 922 | }else{ |
| 923 | zWarning = "Unicode"; |
| 924 | } |
| 925 | file_relative_name(zFilename, &fname, 0); |
| @@ -1216,34 +1224,36 @@ | |
| 1224 | /* Step 1: Insert records for all modified files into the blob |
| 1225 | ** table. If there were arguments passed to this command, only |
| 1226 | ** the identified fils are inserted (if they have been modified). |
| 1227 | */ |
| 1228 | db_prepare(&q, |
| 1229 | "SELECT id, %Q || pathname, mrid, %s, chnged, %s FROM vfile " |
| 1230 | "WHERE chnged==1 AND NOT deleted AND is_selected(id)", |
| 1231 | g.zLocalRoot, glob_expr("pathname", db_get("crnl-glob","")), |
| 1232 | glob_expr("pathname", db_get("binary-glob","")) |
| 1233 | ); |
| 1234 | while( db_step(&q)==SQLITE_ROW ){ |
| 1235 | int id, rid; |
| 1236 | const char *zFullname; |
| 1237 | Blob content; |
| 1238 | int crnlOk, binOk, chnged; |
| 1239 | |
| 1240 | id = db_column_int(&q, 0); |
| 1241 | zFullname = db_column_text(&q, 1); |
| 1242 | rid = db_column_int(&q, 2); |
| 1243 | crnlOk = db_column_int(&q, 3); |
| 1244 | chnged = db_column_int(&q, 4); |
| 1245 | binOk = db_column_int(&q, 5); |
| 1246 | |
| 1247 | blob_zero(&content); |
| 1248 | if( file_wd_islink(zFullname) ){ |
| 1249 | /* Instead of file content, put link destination path */ |
| 1250 | blob_read_link(&content, zFullname); |
| 1251 | }else{ |
| 1252 | blob_read_from_file(&content, zFullname); |
| 1253 | } |
| 1254 | commit_warning(&content, crnlOk, binOk, zFullname); |
| 1255 | if( chnged==1 && contains_merge_marker(&content) ){ |
| 1256 | Blob fname; /* Relative pathname of the file */ |
| 1257 | |
| 1258 | nConflict++; |
| 1259 | file_relative_name(zFullname, &fname, 0); |
| 1260 |