Fossil SCM
Add the "fossil test-nondir-path" command for testing parts of the new symlink logic.
Commit
13cfef3383968d3aff5ad94050472416f00c9e25eace59d826adb3d83e93206b
Parent
feef827504c7742…
1 file changed
+22
+22
| --- src/file.c | ||
| +++ src/file.c | ||
| @@ -370,10 +370,32 @@ | ||
| 370 | 370 | i = j; |
| 371 | 371 | } |
| 372 | 372 | fossil_free(z); |
| 373 | 373 | return 0; |
| 374 | 374 | } |
| 375 | + | |
| 376 | +/* | |
| 377 | +** COMMAND: test-nondir-path | |
| 378 | +** Usage: %fossil test-nondir-path ROOT FILE | |
| 379 | +** | |
| 380 | +** If there are any objects on the path from ROOT to FILE (exluding | |
| 381 | +** ROOT and FILE themselves) that are not directories, then print | |
| 382 | +** the name of the first object found. | |
| 383 | +*/ | |
| 384 | +void test_nondir_path_cmd(void){ | |
| 385 | + int n; | |
| 386 | + if( g.argc!=4 ){ | |
| 387 | + usage("ROOT FILE"); | |
| 388 | + } | |
| 389 | + if( fossil_strnicmp(g.argv[2],g.argv[3],(int)strlen(g.argv[2]))!=0 ){ | |
| 390 | + fossil_fatal("%s should be a prefix of %s", g.argv[2], g.argv[3]); | |
| 391 | + } | |
| 392 | + n = file_nondir_objects_on_path(g.argv[2],g.argv[3]); | |
| 393 | + if( n ){ | |
| 394 | + fossil_print("%.*s\n", n, g.argv[3]); | |
| 395 | + } | |
| 396 | +} | |
| 375 | 397 | |
| 376 | 398 | /* |
| 377 | 399 | ** The file named zFile is suppose to be an in-tree file. Check to |
| 378 | 400 | ** ensure that it will be safe to write to this file by verifying that |
| 379 | 401 | ** there are no symlinks or other non-directory objects in between the |
| 380 | 402 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -370,10 +370,32 @@ | |
| 370 | i = j; |
| 371 | } |
| 372 | fossil_free(z); |
| 373 | return 0; |
| 374 | } |
| 375 | |
| 376 | /* |
| 377 | ** The file named zFile is suppose to be an in-tree file. Check to |
| 378 | ** ensure that it will be safe to write to this file by verifying that |
| 379 | ** there are no symlinks or other non-directory objects in between the |
| 380 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -370,10 +370,32 @@ | |
| 370 | i = j; |
| 371 | } |
| 372 | fossil_free(z); |
| 373 | return 0; |
| 374 | } |
| 375 | |
| 376 | /* |
| 377 | ** COMMAND: test-nondir-path |
| 378 | ** Usage: %fossil test-nondir-path ROOT FILE |
| 379 | ** |
| 380 | ** If there are any objects on the path from ROOT to FILE (exluding |
| 381 | ** ROOT and FILE themselves) that are not directories, then print |
| 382 | ** the name of the first object found. |
| 383 | */ |
| 384 | void test_nondir_path_cmd(void){ |
| 385 | int n; |
| 386 | if( g.argc!=4 ){ |
| 387 | usage("ROOT FILE"); |
| 388 | } |
| 389 | if( fossil_strnicmp(g.argv[2],g.argv[3],(int)strlen(g.argv[2]))!=0 ){ |
| 390 | fossil_fatal("%s should be a prefix of %s", g.argv[2], g.argv[3]); |
| 391 | } |
| 392 | n = file_nondir_objects_on_path(g.argv[2],g.argv[3]); |
| 393 | if( n ){ |
| 394 | fossil_print("%.*s\n", n, g.argv[3]); |
| 395 | } |
| 396 | } |
| 397 | |
| 398 | /* |
| 399 | ** The file named zFile is suppose to be an in-tree file. Check to |
| 400 | ** ensure that it will be safe to write to this file by verifying that |
| 401 | ** there are no symlinks or other non-directory objects in between the |
| 402 |