Fossil SCM
Fail with an error if a file is outside the checkout tree.
Commit
b3ec774ab7edcaa610aa216fd94cd5029650555c
Parent
2ae7890060340a4…
5 files changed
+1
-3
+1
-3
+3
-2
+1
-3
-1
+1
-3
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -290,13 +290,11 @@ | ||
| 290 | 290 | blob_zero(&b); |
| 291 | 291 | g.aCommitFile = malloc(sizeof(int)*(g.argc-1)); |
| 292 | 292 | |
| 293 | 293 | for(ii=2; ii<g.argc; ii++){ |
| 294 | 294 | int iId; |
| 295 | - if( !file_tree_name(g.argv[ii], &b) ){ | |
| 296 | - fossil_fatal("file is not in tree: %s", g.argv[ii]); | |
| 297 | - } | |
| 295 | + file_tree_name(g.argv[ii], &b); | |
| 298 | 296 | iId = db_int(-1, "SELECT id FROM vfile WHERE pathname=%Q", blob_str(&b)); |
| 299 | 297 | if( iId<0 ){ |
| 300 | 298 | fossil_fatal("fossil knows nothing about: %s", g.argv[ii]); |
| 301 | 299 | } |
| 302 | 300 | g.aCommitFile[ii-2] = iId; |
| 303 | 301 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -290,13 +290,11 @@ | |
| 290 | blob_zero(&b); |
| 291 | g.aCommitFile = malloc(sizeof(int)*(g.argc-1)); |
| 292 | |
| 293 | for(ii=2; ii<g.argc; ii++){ |
| 294 | int iId; |
| 295 | if( !file_tree_name(g.argv[ii], &b) ){ |
| 296 | fossil_fatal("file is not in tree: %s", g.argv[ii]); |
| 297 | } |
| 298 | iId = db_int(-1, "SELECT id FROM vfile WHERE pathname=%Q", blob_str(&b)); |
| 299 | if( iId<0 ){ |
| 300 | fossil_fatal("fossil knows nothing about: %s", g.argv[ii]); |
| 301 | } |
| 302 | g.aCommitFile[ii-2] = iId; |
| 303 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -290,13 +290,11 @@ | |
| 290 | blob_zero(&b); |
| 291 | g.aCommitFile = malloc(sizeof(int)*(g.argc-1)); |
| 292 | |
| 293 | for(ii=2; ii<g.argc; ii++){ |
| 294 | int iId; |
| 295 | file_tree_name(g.argv[ii], &b); |
| 296 | iId = db_int(-1, "SELECT id FROM vfile WHERE pathname=%Q", blob_str(&b)); |
| 297 | if( iId<0 ){ |
| 298 | fossil_fatal("fossil knows nothing about: %s", g.argv[ii]); |
| 299 | } |
| 300 | g.aCommitFile[ii-2] = iId; |
| 301 |
+1
-3
| --- src/diffcmd.c | ||
| +++ src/diffcmd.c | ||
| @@ -99,13 +99,11 @@ | ||
| 99 | 99 | } |
| 100 | 100 | blob_zero(&cmd); |
| 101 | 101 | blob_appendf(&cmd, "%s ", zExternalCommand); |
| 102 | 102 | } |
| 103 | 103 | zFile = g.argv[g.argc-1]; |
| 104 | - if( !file_tree_name(zFile, &fname) ){ | |
| 105 | - fossil_panic("unknown file: %s", zFile); | |
| 106 | - } | |
| 104 | + file_tree_name(zFile, &fname); | |
| 107 | 105 | |
| 108 | 106 | blob_zero(&vname); |
| 109 | 107 | do{ |
| 110 | 108 | blob_reset(&vname); |
| 111 | 109 | blob_appendf(&vname, "%s~%d", zFile, cnt++); |
| 112 | 110 |
| --- src/diffcmd.c | |
| +++ src/diffcmd.c | |
| @@ -99,13 +99,11 @@ | |
| 99 | } |
| 100 | blob_zero(&cmd); |
| 101 | blob_appendf(&cmd, "%s ", zExternalCommand); |
| 102 | } |
| 103 | zFile = g.argv[g.argc-1]; |
| 104 | if( !file_tree_name(zFile, &fname) ){ |
| 105 | fossil_panic("unknown file: %s", zFile); |
| 106 | } |
| 107 | |
| 108 | blob_zero(&vname); |
| 109 | do{ |
| 110 | blob_reset(&vname); |
| 111 | blob_appendf(&vname, "%s~%d", zFile, cnt++); |
| 112 |
| --- src/diffcmd.c | |
| +++ src/diffcmd.c | |
| @@ -99,13 +99,11 @@ | |
| 99 | } |
| 100 | blob_zero(&cmd); |
| 101 | blob_appendf(&cmd, "%s ", zExternalCommand); |
| 102 | } |
| 103 | zFile = g.argv[g.argc-1]; |
| 104 | file_tree_name(zFile, &fname); |
| 105 | |
| 106 | blob_zero(&vname); |
| 107 | do{ |
| 108 | blob_reset(&vname); |
| 109 | blob_appendf(&vname, "%s~%d", zFile, cnt++); |
| 110 |
+3
-2
| --- src/file.c | ||
| +++ src/file.c | ||
| @@ -284,12 +284,12 @@ | ||
| 284 | 284 | } |
| 285 | 285 | } |
| 286 | 286 | |
| 287 | 287 | /* |
| 288 | 288 | ** Compute a pathname for a file relative to the root of the local |
| 289 | -** tree. Return TRUE on success and FALSE if the file is not contained | |
| 290 | -** in the local tree. | |
| 289 | +** tree. Return TRUE on success. On failure, print and error | |
| 290 | +** message and quit. | |
| 291 | 291 | ** |
| 292 | 292 | ** The root of the tree is defined by the g.zLocalRoot variable. |
| 293 | 293 | */ |
| 294 | 294 | int file_tree_name(const char *zOrigName, Blob *pOut){ |
| 295 | 295 | int n; |
| @@ -297,10 +297,11 @@ | ||
| 297 | 297 | db_must_be_within_tree(); |
| 298 | 298 | file_canonical_name(zOrigName, &full); |
| 299 | 299 | n = strlen(g.zLocalRoot); |
| 300 | 300 | if( blob_size(&full)<=n || memcmp(g.zLocalRoot, blob_buffer(&full), n) ){ |
| 301 | 301 | blob_reset(&full); |
| 302 | + fossil_fatal("file outside of checkout tree: %s", zOrigName); | |
| 302 | 303 | return 0; |
| 303 | 304 | } |
| 304 | 305 | blob_zero(pOut); |
| 305 | 306 | blob_append(pOut, blob_buffer(&full)+n, blob_size(&full)-n); |
| 306 | 307 | return 1; |
| 307 | 308 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -284,12 +284,12 @@ | |
| 284 | } |
| 285 | } |
| 286 | |
| 287 | /* |
| 288 | ** Compute a pathname for a file relative to the root of the local |
| 289 | ** tree. Return TRUE on success and FALSE if the file is not contained |
| 290 | ** in the local tree. |
| 291 | ** |
| 292 | ** The root of the tree is defined by the g.zLocalRoot variable. |
| 293 | */ |
| 294 | int file_tree_name(const char *zOrigName, Blob *pOut){ |
| 295 | int n; |
| @@ -297,10 +297,11 @@ | |
| 297 | db_must_be_within_tree(); |
| 298 | file_canonical_name(zOrigName, &full); |
| 299 | n = strlen(g.zLocalRoot); |
| 300 | if( blob_size(&full)<=n || memcmp(g.zLocalRoot, blob_buffer(&full), n) ){ |
| 301 | blob_reset(&full); |
| 302 | return 0; |
| 303 | } |
| 304 | blob_zero(pOut); |
| 305 | blob_append(pOut, blob_buffer(&full)+n, blob_size(&full)-n); |
| 306 | return 1; |
| 307 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -284,12 +284,12 @@ | |
| 284 | } |
| 285 | } |
| 286 | |
| 287 | /* |
| 288 | ** Compute a pathname for a file relative to the root of the local |
| 289 | ** tree. Return TRUE on success. On failure, print and error |
| 290 | ** message and quit. |
| 291 | ** |
| 292 | ** The root of the tree is defined by the g.zLocalRoot variable. |
| 293 | */ |
| 294 | int file_tree_name(const char *zOrigName, Blob *pOut){ |
| 295 | int n; |
| @@ -297,10 +297,11 @@ | |
| 297 | db_must_be_within_tree(); |
| 298 | file_canonical_name(zOrigName, &full); |
| 299 | n = strlen(g.zLocalRoot); |
| 300 | if( blob_size(&full)<=n || memcmp(g.zLocalRoot, blob_buffer(&full), n) ){ |
| 301 | blob_reset(&full); |
| 302 | fossil_fatal("file outside of checkout tree: %s", zOrigName); |
| 303 | return 0; |
| 304 | } |
| 305 | blob_zero(pOut); |
| 306 | blob_append(pOut, blob_buffer(&full)+n, blob_size(&full)-n); |
| 307 | return 1; |
| 308 |
+1
-3
| --- src/update.c | ||
| +++ src/update.c | ||
| @@ -303,13 +303,11 @@ | ||
| 303 | 303 | } |
| 304 | 304 | db_must_be_within_tree(); |
| 305 | 305 | |
| 306 | 306 | zFile = mprintf("%/", g.argv[g.argc-1]); |
| 307 | 307 | |
| 308 | - if( !file_tree_name(zFile, &fname) ){ | |
| 309 | - fossil_panic("unknown file: %s", zFile); | |
| 310 | - } | |
| 308 | + file_tree_name(zFile, &fname); | |
| 311 | 309 | |
| 312 | 310 | if( access(zFile, 0) ) yesRevert = 1; |
| 313 | 311 | if( yesRevert==0 ){ |
| 314 | 312 | char *prompt = mprintf("revert file %B? this will" |
| 315 | 313 | " destroy local changes [y/N]? ", |
| 316 | 314 |
| --- src/update.c | |
| +++ src/update.c | |
| @@ -303,13 +303,11 @@ | |
| 303 | } |
| 304 | db_must_be_within_tree(); |
| 305 | |
| 306 | zFile = mprintf("%/", g.argv[g.argc-1]); |
| 307 | |
| 308 | if( !file_tree_name(zFile, &fname) ){ |
| 309 | fossil_panic("unknown file: %s", zFile); |
| 310 | } |
| 311 | |
| 312 | if( access(zFile, 0) ) yesRevert = 1; |
| 313 | if( yesRevert==0 ){ |
| 314 | char *prompt = mprintf("revert file %B? this will" |
| 315 | " destroy local changes [y/N]? ", |
| 316 |
| --- src/update.c | |
| +++ src/update.c | |
| @@ -303,13 +303,11 @@ | |
| 303 | } |
| 304 | db_must_be_within_tree(); |
| 305 | |
| 306 | zFile = mprintf("%/", g.argv[g.argc-1]); |
| 307 | |
| 308 | file_tree_name(zFile, &fname); |
| 309 | |
| 310 | if( access(zFile, 0) ) yesRevert = 1; |
| 311 | if( yesRevert==0 ){ |
| 312 | char *prompt = mprintf("revert file %B? this will" |
| 313 | " destroy local changes [y/N]? ", |
| 314 |
-1
| --- src/wiki.c | ||
| +++ src/wiki.c | ||
| @@ -596,6 +596,5 @@ | ||
| 596 | 596 | @ disables all wiki formatting rules through the matching |
| 597 | 597 | @ </nowiki> element. |
| 598 | 598 | @ </ol> |
| 599 | 599 | style_footer(); |
| 600 | 600 | } |
| 601 | - | |
| 602 | 601 |
| --- src/wiki.c | |
| +++ src/wiki.c | |
| @@ -596,6 +596,5 @@ | |
| 596 | @ disables all wiki formatting rules through the matching |
| 597 | @ </nowiki> element. |
| 598 | @ </ol> |
| 599 | style_footer(); |
| 600 | } |
| 601 | |
| 602 |
| --- src/wiki.c | |
| +++ src/wiki.c | |
| @@ -596,6 +596,5 @@ | |
| 596 | @ disables all wiki formatting rules through the matching |
| 597 | @ </nowiki> element. |
| 598 | @ </ol> |
| 599 | style_footer(); |
| 600 | } |
| 601 |