Fossil SCM
Make attempts to add _FOSSIL_, manifest, and manifest.uuid warnings, not fatal errors. This allows users to say things like "fossil add *" when initially populating a new project repository.
Commit
844718abbfb4b49f05986501161a90d4a530d1a7
Parent
c23469468bc6a8a…
2 files changed
+15
-11
+12
+15
-11
| --- src/add.c | ||
| +++ src/add.c | ||
| @@ -62,22 +62,26 @@ | ||
| 62 | 62 | if( isDir==2 && access(zName, R_OK) ){ |
| 63 | 63 | fossil_fatal("cannot open %s", zName); |
| 64 | 64 | } |
| 65 | 65 | file_tree_name(zName, &pathname); |
| 66 | 66 | zPath = blob_str(&pathname); |
| 67 | - if( strcmp(zPath, "manifest")==0 || strcmp(zPath, "_FOSSIL_")==0 ){ | |
| 68 | - fossil_fatal("cannot add %s", zPath); | |
| 69 | - } | |
| 70 | - if( !file_is_simple_pathname(zPath) ){ | |
| 71 | - fossil_fatal("filename contains illegal characters: %s", zPath); | |
| 72 | - } | |
| 73 | - if( db_exists("SELECT 1 FROM vfile WHERE pathname=%Q", zPath) ){ | |
| 74 | - db_multi_exec("UPDATE vfile SET deleted=0 WHERE pathname=%Q", zPath); | |
| 67 | + if( strcmp(zPath, "manifest")==0 | |
| 68 | + || strcmp(zPath, "_FOSSIL_")==0 | |
| 69 | + || strcmp(zPath, "manifest.uuid")==0 | |
| 70 | + ){ | |
| 71 | + fossil_warning("cannot add %s", zPath); | |
| 75 | 72 | }else{ |
| 76 | - db_multi_exec( | |
| 77 | - "INSERT INTO vfile(vid,deleted,rid,mrid,pathname)" | |
| 78 | - "VALUES(%d,0,0,0,%Q)", vid, zPath); | |
| 73 | + if( !file_is_simple_pathname(zPath) ){ | |
| 74 | + fossil_fatal("filename contains illegal characters: %s", zPath); | |
| 75 | + } | |
| 76 | + if( db_exists("SELECT 1 FROM vfile WHERE pathname=%Q", zPath) ){ | |
| 77 | + db_multi_exec("UPDATE vfile SET deleted=0 WHERE pathname=%Q", zPath); | |
| 78 | + }else{ | |
| 79 | + db_multi_exec( | |
| 80 | + "INSERT INTO vfile(vid,deleted,rid,mrid,pathname)" | |
| 81 | + "VALUES(%d,0,0,0,%Q)", vid, zPath); | |
| 82 | + } | |
| 79 | 83 | } |
| 80 | 84 | blob_reset(&pathname); |
| 81 | 85 | free(zName); |
| 82 | 86 | } |
| 83 | 87 | db_end_transaction(0); |
| 84 | 88 |
| --- src/add.c | |
| +++ src/add.c | |
| @@ -62,22 +62,26 @@ | |
| 62 | if( isDir==2 && access(zName, R_OK) ){ |
| 63 | fossil_fatal("cannot open %s", zName); |
| 64 | } |
| 65 | file_tree_name(zName, &pathname); |
| 66 | zPath = blob_str(&pathname); |
| 67 | if( strcmp(zPath, "manifest")==0 || strcmp(zPath, "_FOSSIL_")==0 ){ |
| 68 | fossil_fatal("cannot add %s", zPath); |
| 69 | } |
| 70 | if( !file_is_simple_pathname(zPath) ){ |
| 71 | fossil_fatal("filename contains illegal characters: %s", zPath); |
| 72 | } |
| 73 | if( db_exists("SELECT 1 FROM vfile WHERE pathname=%Q", zPath) ){ |
| 74 | db_multi_exec("UPDATE vfile SET deleted=0 WHERE pathname=%Q", zPath); |
| 75 | }else{ |
| 76 | db_multi_exec( |
| 77 | "INSERT INTO vfile(vid,deleted,rid,mrid,pathname)" |
| 78 | "VALUES(%d,0,0,0,%Q)", vid, zPath); |
| 79 | } |
| 80 | blob_reset(&pathname); |
| 81 | free(zName); |
| 82 | } |
| 83 | db_end_transaction(0); |
| 84 |
| --- src/add.c | |
| +++ src/add.c | |
| @@ -62,22 +62,26 @@ | |
| 62 | if( isDir==2 && access(zName, R_OK) ){ |
| 63 | fossil_fatal("cannot open %s", zName); |
| 64 | } |
| 65 | file_tree_name(zName, &pathname); |
| 66 | zPath = blob_str(&pathname); |
| 67 | if( strcmp(zPath, "manifest")==0 |
| 68 | || strcmp(zPath, "_FOSSIL_")==0 |
| 69 | || strcmp(zPath, "manifest.uuid")==0 |
| 70 | ){ |
| 71 | fossil_warning("cannot add %s", zPath); |
| 72 | }else{ |
| 73 | if( !file_is_simple_pathname(zPath) ){ |
| 74 | fossil_fatal("filename contains illegal characters: %s", zPath); |
| 75 | } |
| 76 | if( db_exists("SELECT 1 FROM vfile WHERE pathname=%Q", zPath) ){ |
| 77 | db_multi_exec("UPDATE vfile SET deleted=0 WHERE pathname=%Q", zPath); |
| 78 | }else{ |
| 79 | db_multi_exec( |
| 80 | "INSERT INTO vfile(vid,deleted,rid,mrid,pathname)" |
| 81 | "VALUES(%d,0,0,0,%Q)", vid, zPath); |
| 82 | } |
| 83 | } |
| 84 | blob_reset(&pathname); |
| 85 | free(zName); |
| 86 | } |
| 87 | db_end_transaction(0); |
| 88 |
+12
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -250,10 +250,22 @@ | ||
| 250 | 250 | }else{ |
| 251 | 251 | fprintf(stderr, "%s: %s\n", g.argv[0], z); |
| 252 | 252 | } |
| 253 | 253 | db_force_rollback(); |
| 254 | 254 | exit(1); |
| 255 | +} | |
| 256 | +void fossil_warning(const char *zFormat, ...){ | |
| 257 | + char *z; | |
| 258 | + va_list ap; | |
| 259 | + va_start(ap, zFormat); | |
| 260 | + z = vmprintf(zFormat, ap); | |
| 261 | + va_end(ap); | |
| 262 | + if( g.cgiPanic ){ | |
| 263 | + cgi_printf("<p><font color=\"red\">%h</font></p>", z); | |
| 264 | + }else{ | |
| 265 | + fprintf(stderr, "%s: %s\n", g.argv[0], z); | |
| 266 | + } | |
| 255 | 267 | } |
| 256 | 268 | |
| 257 | 269 | /* |
| 258 | 270 | ** Print a usage comment and quit |
| 259 | 271 | */ |
| 260 | 272 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -250,10 +250,22 @@ | |
| 250 | }else{ |
| 251 | fprintf(stderr, "%s: %s\n", g.argv[0], z); |
| 252 | } |
| 253 | db_force_rollback(); |
| 254 | exit(1); |
| 255 | } |
| 256 | |
| 257 | /* |
| 258 | ** Print a usage comment and quit |
| 259 | */ |
| 260 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -250,10 +250,22 @@ | |
| 250 | }else{ |
| 251 | fprintf(stderr, "%s: %s\n", g.argv[0], z); |
| 252 | } |
| 253 | db_force_rollback(); |
| 254 | exit(1); |
| 255 | } |
| 256 | void fossil_warning(const char *zFormat, ...){ |
| 257 | char *z; |
| 258 | va_list ap; |
| 259 | va_start(ap, zFormat); |
| 260 | z = vmprintf(zFormat, ap); |
| 261 | va_end(ap); |
| 262 | if( g.cgiPanic ){ |
| 263 | cgi_printf("<p><font color=\"red\">%h</font></p>", z); |
| 264 | }else{ |
| 265 | fprintf(stderr, "%s: %s\n", g.argv[0], z); |
| 266 | } |
| 267 | } |
| 268 | |
| 269 | /* |
| 270 | ** Print a usage comment and quit |
| 271 | */ |
| 272 |