Fossil SCM
Improve error message when rejecting unversioned filenames
Commit
493e3bade9ae8dc61ece027603b8d4ce9106941be187e19b33a7bbed688c1af8
Parent
e97d4443d562870…
1 file changed
+11
-4
+11
-4
| --- src/unversioned.c | ||
| +++ src/unversioned.c | ||
| @@ -275,10 +275,11 @@ | ||
| 275 | 275 | }else{ |
| 276 | 276 | mtime = db_int(0, "SELECT strftime('%%s',%Q)", zMtime); |
| 277 | 277 | if( mtime<=0 ) fossil_fatal("bad timestamp: %Q", zMtime); |
| 278 | 278 | } |
| 279 | 279 | if( memcmp(zCmd, "add", nCmd)==0 ){ |
| 280 | + const char *zError = 0; | |
| 280 | 281 | const char *zIn; |
| 281 | 282 | const char *zAs; |
| 282 | 283 | Blob file; |
| 283 | 284 | int i; |
| 284 | 285 | |
| @@ -287,15 +288,21 @@ | ||
| 287 | 288 | verify_all_options(); |
| 288 | 289 | db_begin_transaction(); |
| 289 | 290 | content_rcvid_init("#!fossil unversioned add"); |
| 290 | 291 | for(i=3; i<g.argc; i++){ |
| 291 | 292 | zIn = zAs ? zAs : g.argv[i]; |
| 292 | - if( zIn[0]==0 || zIn[0]=='/' || !file_is_simple_pathname(zIn,1) ){ | |
| 293 | - fossil_fatal("'%Q' is not an acceptable filename", zIn); | |
| 293 | + if( zIn[0]==0 ){ | |
| 294 | + zError = "be empty string"; | |
| 295 | + }else if( zIn[0]=='/' ){ | |
| 296 | + zError = "be absolute"; | |
| 297 | + }else if ( !file_is_simple_pathname(zIn,1) ){ | |
| 298 | + zError = "contain complex paths"; | |
| 299 | + }else if( contains_whitespace(zIn) ){ | |
| 300 | + zError = "contain whitespace"; | |
| 294 | 301 | } |
| 295 | - if( contains_whitespace(zIn) ){ | |
| 296 | - fossil_fatal("names of unversioned files may not contain whitespace"); | |
| 302 | + if( zError ){ | |
| 303 | + fossil_fatal("unversioned filenames may not %s: %Q", zError, zIn); | |
| 297 | 304 | } |
| 298 | 305 | blob_init(&file,0,0); |
| 299 | 306 | blob_read_from_file(&file, g.argv[i]); |
| 300 | 307 | unversioned_write(zIn, &file, mtime); |
| 301 | 308 | blob_reset(&file); |
| 302 | 309 |
| --- src/unversioned.c | |
| +++ src/unversioned.c | |
| @@ -275,10 +275,11 @@ | |
| 275 | }else{ |
| 276 | mtime = db_int(0, "SELECT strftime('%%s',%Q)", zMtime); |
| 277 | if( mtime<=0 ) fossil_fatal("bad timestamp: %Q", zMtime); |
| 278 | } |
| 279 | if( memcmp(zCmd, "add", nCmd)==0 ){ |
| 280 | const char *zIn; |
| 281 | const char *zAs; |
| 282 | Blob file; |
| 283 | int i; |
| 284 | |
| @@ -287,15 +288,21 @@ | |
| 287 | verify_all_options(); |
| 288 | db_begin_transaction(); |
| 289 | content_rcvid_init("#!fossil unversioned add"); |
| 290 | for(i=3; i<g.argc; i++){ |
| 291 | zIn = zAs ? zAs : g.argv[i]; |
| 292 | if( zIn[0]==0 || zIn[0]=='/' || !file_is_simple_pathname(zIn,1) ){ |
| 293 | fossil_fatal("'%Q' is not an acceptable filename", zIn); |
| 294 | } |
| 295 | if( contains_whitespace(zIn) ){ |
| 296 | fossil_fatal("names of unversioned files may not contain whitespace"); |
| 297 | } |
| 298 | blob_init(&file,0,0); |
| 299 | blob_read_from_file(&file, g.argv[i]); |
| 300 | unversioned_write(zIn, &file, mtime); |
| 301 | blob_reset(&file); |
| 302 |
| --- src/unversioned.c | |
| +++ src/unversioned.c | |
| @@ -275,10 +275,11 @@ | |
| 275 | }else{ |
| 276 | mtime = db_int(0, "SELECT strftime('%%s',%Q)", zMtime); |
| 277 | if( mtime<=0 ) fossil_fatal("bad timestamp: %Q", zMtime); |
| 278 | } |
| 279 | if( memcmp(zCmd, "add", nCmd)==0 ){ |
| 280 | const char *zError = 0; |
| 281 | const char *zIn; |
| 282 | const char *zAs; |
| 283 | Blob file; |
| 284 | int i; |
| 285 | |
| @@ -287,15 +288,21 @@ | |
| 288 | verify_all_options(); |
| 289 | db_begin_transaction(); |
| 290 | content_rcvid_init("#!fossil unversioned add"); |
| 291 | for(i=3; i<g.argc; i++){ |
| 292 | zIn = zAs ? zAs : g.argv[i]; |
| 293 | if( zIn[0]==0 ){ |
| 294 | zError = "be empty string"; |
| 295 | }else if( zIn[0]=='/' ){ |
| 296 | zError = "be absolute"; |
| 297 | }else if ( !file_is_simple_pathname(zIn,1) ){ |
| 298 | zError = "contain complex paths"; |
| 299 | }else if( contains_whitespace(zIn) ){ |
| 300 | zError = "contain whitespace"; |
| 301 | } |
| 302 | if( zError ){ |
| 303 | fossil_fatal("unversioned filenames may not %s: %Q", zError, zIn); |
| 304 | } |
| 305 | blob_init(&file,0,0); |
| 306 | blob_read_from_file(&file, g.argv[i]); |
| 307 | unversioned_write(zIn, &file, mtime); |
| 308 | blob_reset(&file); |
| 309 |