Fossil SCM

Add the "fossil test-nondir-path" command for testing parts of the new symlink logic.

drh 2020-08-19 15:21 sec2020
Commit 13cfef3383968d3aff5ad94050472416f00c9e25eace59d826adb3d83e93206b
1 file changed +22
+22
--- src/file.c
+++ src/file.c
@@ -370,10 +370,32 @@
370370
i = j;
371371
}
372372
fossil_free(z);
373373
return 0;
374374
}
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
+}
375397
376398
/*
377399
** The file named zFile is suppose to be an in-tree file. Check to
378400
** ensure that it will be safe to write to this file by verifying that
379401
** there are no symlinks or other non-directory objects in between the
380402
--- 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

Keyboard Shortcuts

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