Fossil SCM

Allow commit warning for binary data to be disabled via the 'binary-glob' setting.

mistachkin 2012-11-02 17:37 trunk
Commit d25f6ddf35ae0e42a3792042cd5ff07657ed3070
1 file changed +15 -5
+15 -5
--- src/checkin.c
+++ src/checkin.c
@@ -885,11 +885,16 @@
885885
/*
886886
** Issue a warning and give the user an opportunity to abandon out
887887
** if a Unicode (UTF-16) byte-order-mark (BOM) or a \r\n line ending
888888
** is seen in a text file.
889889
*/
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
+){
891896
int eType; /* return value of looks_like_utf8/utf16() */
892897
int fUnicode; /* return value of starts_with_utf16_bom() */
893898
char *zMsg; /* Warning message */
894899
Blob fname; /* Relative pathname of the file */
895900
static int allOk = 0; /* Set to true to disable this routine */
@@ -908,10 +913,13 @@
908913
if( crnlOk ){
909914
return; /* We don't want CR/NL warnings for this file. */
910915
}
911916
zWarning = "CR/NL line endings";
912917
}else if( eType==0 ){
918
+ if( binOk ){
919
+ return; /* We don't want binary warnings for this file. */
920
+ }
913921
zWarning = "binary data";
914922
}else{
915923
zWarning = "Unicode";
916924
}
917925
file_relative_name(zFilename, &fname, 0);
@@ -1216,34 +1224,36 @@
12161224
/* Step 1: Insert records for all modified files into the blob
12171225
** table. If there were arguments passed to this command, only
12181226
** the identified fils are inserted (if they have been modified).
12191227
*/
12201228
db_prepare(&q,
1221
- "SELECT id, %Q || pathname, mrid, %s, chnged FROM vfile "
1229
+ "SELECT id, %Q || pathname, mrid, %s, chnged, %s FROM vfile "
12221230
"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",""))
12241233
);
12251234
while( db_step(&q)==SQLITE_ROW ){
12261235
int id, rid;
12271236
const char *zFullname;
12281237
Blob content;
1229
- int crnlOk, chnged;
1238
+ int crnlOk, binOk, chnged;
12301239
12311240
id = db_column_int(&q, 0);
12321241
zFullname = db_column_text(&q, 1);
12331242
rid = db_column_int(&q, 2);
12341243
crnlOk = db_column_int(&q, 3);
12351244
chnged = db_column_int(&q, 4);
1245
+ binOk = db_column_int(&q, 5);
12361246
12371247
blob_zero(&content);
12381248
if( file_wd_islink(zFullname) ){
12391249
/* Instead of file content, put link destination path */
12401250
blob_read_link(&content, zFullname);
12411251
}else{
12421252
blob_read_from_file(&content, zFullname);
12431253
}
1244
- commit_warning(&content, crnlOk, zFullname);
1254
+ commit_warning(&content, crnlOk, binOk, zFullname);
12451255
if( chnged==1 && contains_merge_marker(&content) ){
12461256
Blob fname; /* Relative pathname of the file */
12471257
12481258
nConflict++;
12491259
file_relative_name(zFullname, &fname, 0);
12501260
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button