Fossil SCM

Factor out common parts of "fossil extra" and "fossil clean" into a subroutine. Combine vfile_scan2() into vfile_scan().

drh 2013-06-20 11:44 UTC ticket-967cedbf20
Commit 69327d278aabd89874fc4d5e0f9c38db230c5d4b
3 files changed +2 -2 +56 -69 +7 -11
+2 -2
--- src/add.c
+++ src/add.c
@@ -283,11 +283,11 @@
283283
284284
file_canonical_name(g.argv[i], &fullName, 0);
285285
zName = blob_str(&fullName);
286286
isDir = file_wd_isdir(zName);
287287
if( isDir==1 ){
288
- vfile_scan2(&fullName, nRoot-1, scanFlags, pClean, pIgnore);
288
+ vfile_scan(&fullName, nRoot-1, scanFlags, pClean, pIgnore);
289289
}else if( isDir==0 ){
290290
fossil_warning("not found: %s", zName);
291291
}else if( file_access(zName, R_OK) ){
292292
fossil_fatal("cannot open %s", zName);
293293
}else{
@@ -523,11 +523,11 @@
523523
n = strlen(g.zLocalRoot);
524524
blob_init(&path, g.zLocalRoot, n-1);
525525
/* now we read the complete file structure into a temp table */
526526
pClean = glob_create(zCleanFlag);
527527
pIgnore = glob_create(zIgnoreFlag);
528
- vfile_scan2(&path, blob_size(&path), scanFlags, pClean, pIgnore);
528
+ vfile_scan(&path, blob_size(&path), scanFlags, pClean, pIgnore);
529529
glob_free(pIgnore);
530530
glob_free(pClean);
531531
nAdd = add_files_in_sfile(vid);
532532
533533
/* step 2: search for missing files */
534534
--- src/add.c
+++ src/add.c
@@ -283,11 +283,11 @@
283
284 file_canonical_name(g.argv[i], &fullName, 0);
285 zName = blob_str(&fullName);
286 isDir = file_wd_isdir(zName);
287 if( isDir==1 ){
288 vfile_scan2(&fullName, nRoot-1, scanFlags, pClean, pIgnore);
289 }else if( isDir==0 ){
290 fossil_warning("not found: %s", zName);
291 }else if( file_access(zName, R_OK) ){
292 fossil_fatal("cannot open %s", zName);
293 }else{
@@ -523,11 +523,11 @@
523 n = strlen(g.zLocalRoot);
524 blob_init(&path, g.zLocalRoot, n-1);
525 /* now we read the complete file structure into a temp table */
526 pClean = glob_create(zCleanFlag);
527 pIgnore = glob_create(zIgnoreFlag);
528 vfile_scan2(&path, blob_size(&path), scanFlags, pClean, pIgnore);
529 glob_free(pIgnore);
530 glob_free(pClean);
531 nAdd = add_files_in_sfile(vid);
532
533 /* step 2: search for missing files */
534
--- src/add.c
+++ src/add.c
@@ -283,11 +283,11 @@
283
284 file_canonical_name(g.argv[i], &fullName, 0);
285 zName = blob_str(&fullName);
286 isDir = file_wd_isdir(zName);
287 if( isDir==1 ){
288 vfile_scan(&fullName, nRoot-1, scanFlags, pClean, pIgnore);
289 }else if( isDir==0 ){
290 fossil_warning("not found: %s", zName);
291 }else if( file_access(zName, R_OK) ){
292 fossil_fatal("cannot open %s", zName);
293 }else{
@@ -523,11 +523,11 @@
523 n = strlen(g.zLocalRoot);
524 blob_init(&path, g.zLocalRoot, n-1);
525 /* now we read the complete file structure into a temp table */
526 pClean = glob_create(zCleanFlag);
527 pIgnore = glob_create(zIgnoreFlag);
528 vfile_scan(&path, blob_size(&path), scanFlags, pClean, pIgnore);
529 glob_free(pIgnore);
530 glob_free(pClean);
531 nAdd = add_files_in_sfile(vid);
532
533 /* step 2: search for missing files */
534
+56 -69
--- src/checkin.c
+++ src/checkin.c
@@ -297,10 +297,58 @@
297297
}
298298
free(zFullName);
299299
}
300300
db_finalize(&q);
301301
}
302
+
303
+/*
304
+** Create a TEMP table named SFILE and add all unmanaged files named on the command-line
305
+** to that table. If directories are named, then add all unmanged files contained
306
+** underneath those directories. If there are no files or directories named on the
307
+** command-line, then add all unmanaged files anywhere in the checkout.
308
+*/
309
+static void locate_unmanaged_files(
310
+ int argc, /* Number of command-line arguments to examine */
311
+ char **argv, /* values of command-line arguments */
312
+ unsigned scanFlags, /* Zero or more SCAN_xxx flags */
313
+ Glob *pIgnore1, /* Do not add files that match this GLOB */
314
+ Glob *pIgnore2 /* Omit files matching this GLOB too */
315
+){
316
+ Blob name; /* Name of a candidate file or directory */
317
+ char *zName; /* Name of a candidate file or directory */
318
+ int isDir; /* 1 for a directory, 0 if doesn't exist, 2 for anything else */
319
+ int i; /* Loop counter */
320
+ int nRoot; /* length of g.zLocalRoot */
321
+
322
+ db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)",
323
+ filename_collation());
324
+ nRoot = (int)strlen(g.zLocalRoot);
325
+ if( argc==0 ){
326
+ blob_init(&name, g.zLocalRoot, nRoot - 1);
327
+ vfile_scan(&name, blob_size(&name), scanFlags, pIgnore1, pIgnore2);
328
+ blob_reset(&name);
329
+ }else{
330
+ for(i=0; i<argc; i++){
331
+ file_canonical_name(argv[i], &name, 0);
332
+ zName = blob_str(&name);
333
+ isDir = file_wd_isdir(zName);
334
+ if( isDir==1 ){
335
+ vfile_scan(&name, nRoot-1, scanFlags, pIgnore1, pIgnore2);
336
+ }else if( isDir==0 ){
337
+ fossil_warning("not found: %s", zName);
338
+ }else if( file_access(zName, R_OK) ){
339
+ fossil_fatal("cannot open %s", zName);
340
+ }else{
341
+ db_multi_exec(
342
+ "INSERT OR IGNORE INTO sfile(x) VALUES(%Q)",
343
+ &zName[nRoot]
344
+ );
345
+ }
346
+ blob_reset(&name);
347
+ }
348
+ }
349
+}
302350
303351
/*
304352
** COMMAND: extras
305353
** Usage: %fossil extras ?OPTIONS? ?PATH1 ...?
306354
**
@@ -327,13 +375,11 @@
327375
** directory.
328376
**
329377
** See also: changes, clean, status
330378
*/
331379
void extra_cmd(void){
332
- Blob path;
333380
Stmt q;
334
- int n, i;
335381
const char *zIgnoreFlag = find_option("ignore",0,1);
336382
unsigned scanFlags = find_option("dotfiles",0,0)!=0 ? SCAN_ALL : 0;
337383
int cwdRelative = 0;
338384
Glob *pIgnore;
339385
Blob rewrittenPathname;
@@ -341,45 +387,15 @@
341387
342388
if( find_option("temp",0,0)!=0 ) scanFlags |= SCAN_TEMP;
343389
capture_case_sensitive_option();
344390
db_must_be_within_tree();
345391
cwdRelative = determine_cwd_relative_option();
346
- db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)",
347
- filename_collation());
348
- n = strlen(g.zLocalRoot);
349
- blob_init(&path, g.zLocalRoot, n-1);
350392
if( zIgnoreFlag==0 ){
351393
zIgnoreFlag = db_get("ignore-glob", 0);
352394
}
353395
pIgnore = glob_create(zIgnoreFlag);
354
-
355
- /* Load the names of all files that are candidates to be listed into sfile temp table */
356
- if( g.argc < 3 ){
357
- vfile_scan(&path, blob_size(&path), scanFlags, pIgnore);
358
- }
359
- for( i=2; i<g.argc; i++ ){
360
- char *zName;
361
- int isDir;
362
- Blob fullName;
363
-
364
- file_canonical_name(g.argv[i], &fullName, 0);
365
- zName = blob_str(&fullName);
366
- isDir = file_wd_isdir(zName);
367
- if( isDir==1 ){
368
- vfile_scan(&fullName, n-1, scanFlags, pIgnore);
369
- }else if( isDir==0 ){
370
- fossil_warning("not found: %s", zName);
371
- }else if( file_access(zName, R_OK) ){
372
- fossil_fatal("cannot open %s", zName);
373
- }else{
374
- db_multi_exec(
375
- "INSERT OR IGNORE INTO sfile(x) VALUES(%Q)",
376
- &zName[n]
377
- );
378
- }
379
- blob_reset(&fullName);
380
- }
396
+ locate_unmanaged_files(g.argc-2, g.argv+2, scanFlags, pIgnore, 0);
381397
glob_free(pIgnore);
382398
db_prepare(&q,
383399
"SELECT x FROM sfile"
384400
" WHERE x NOT IN (%s)"
385401
" ORDER BY 1",
@@ -445,14 +461,14 @@
445461
*/
446462
void clean_cmd(void){
447463
int allFlag, dryRunFlag, verboseFlag;
448464
unsigned scanFlags = 0;
449465
const char *zIgnoreFlag, *zKeepFlag, *zCleanFlag;
450
- Blob path, repo;
466
+ Blob repo;
451467
Stmt q;
452
- int n, i;
453468
Glob *pIgnore, *pKeep, *pClean;
469
+ int nRoot;
454470
455471
dryRunFlag = find_option("dry-run","n",0)!=0;
456472
if( !dryRunFlag ){
457473
dryRunFlag = find_option("test",0,0)!=0; /* deprecated */
458474
}
@@ -473,44 +489,14 @@
473489
}
474490
if( zCleanFlag==0 ){
475491
zCleanFlag = db_get("clean-glob", 0);
476492
}
477493
verify_all_options();
478
- db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)",
479
- filename_collation());
480
- n = strlen(g.zLocalRoot);
481
- blob_init(&path, g.zLocalRoot, n-1);
482494
pIgnore = glob_create(zIgnoreFlag);
483495
pKeep = glob_create(zKeepFlag);
484496
pClean = glob_create(zCleanFlag);
485
-
486
- /* Load the names of all files that are candidates to be cleaned into sfile temp table */
487
- if( g.argc < 3 ){
488
- vfile_scan2(&path, blob_size(&path), scanFlags, pIgnore, pKeep);
489
- }
490
- for( i=2; i<g.argc; i++ ){
491
- char *zName;
492
- int isDir;
493
- Blob fullName;
494
-
495
- file_canonical_name(g.argv[i], &fullName, 0);
496
- zName = blob_str(&fullName);
497
- isDir = file_wd_isdir(zName);
498
- if( isDir==1 ){
499
- vfile_scan2(&fullName, n-1, scanFlags, pIgnore, pKeep);
500
- }else if( isDir==0 ){
501
- fossil_warning("not found: %s", zName);
502
- }else if( file_access(zName, R_OK) ){
503
- fossil_fatal("cannot open %s", zName);
504
- }else{
505
- db_multi_exec(
506
- "INSERT OR IGNORE INTO sfile(x) VALUES(%Q)",
507
- &zName[n]
508
- );
509
- }
510
- blob_reset(&fullName);
511
- }
497
+ locate_unmanaged_files(g.argc-2, g.argv+2, scanFlags, pIgnore, pKeep);
512498
glob_free(pKeep);
513499
glob_free(pIgnore);
514500
db_prepare(&q,
515501
"SELECT %Q || x FROM sfile"
516502
" WHERE x NOT IN (%s)"
@@ -519,17 +505,18 @@
519505
);
520506
if( file_tree_name(g.zRepositoryName, &repo, 0) ){
521507
db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo);
522508
}
523509
db_multi_exec("DELETE FROM sfile WHERE x IN (SELECT pathname FROM vfile)");
510
+ nRoot = (int)strlen(g.zLocalRoot);
524511
while( db_step(&q)==SQLITE_ROW ){
525512
const char *zName = db_column_text(&q, 0);
526
- if( !allFlag && !dryRunFlag && !glob_match(pClean, zName+n) ){
513
+ if( !allFlag && !dryRunFlag && !glob_match(pClean, zName+nRoot) ){
527514
Blob ans;
528515
char cReply;
529516
char *prompt = mprintf("Remove unmanaged file \"%s\" (a=all/y/N)? ",
530
- zName+n);
517
+ zName+nRoot);
531518
blob_zero(&ans);
532519
prompt_user(prompt, &ans);
533520
cReply = blob_str(&ans)[0];
534521
if( cReply=='a' || cReply=='A' ){
535522
allFlag = 1;
@@ -538,11 +525,11 @@
538525
continue;
539526
}
540527
blob_reset(&ans);
541528
}
542529
if( verboseFlag || dryRunFlag ){
543
- fossil_print("Removed unmanaged file: %s\n", zName+n);
530
+ fossil_print("Removed unmanaged file: %s\n", zName+nRoot);
544531
}
545532
if( !dryRunFlag ){
546533
file_delete(zName);
547534
}
548535
}
549536
--- src/checkin.c
+++ src/checkin.c
@@ -297,10 +297,58 @@
297 }
298 free(zFullName);
299 }
300 db_finalize(&q);
301 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
302
303 /*
304 ** COMMAND: extras
305 ** Usage: %fossil extras ?OPTIONS? ?PATH1 ...?
306 **
@@ -327,13 +375,11 @@
327 ** directory.
328 **
329 ** See also: changes, clean, status
330 */
331 void extra_cmd(void){
332 Blob path;
333 Stmt q;
334 int n, i;
335 const char *zIgnoreFlag = find_option("ignore",0,1);
336 unsigned scanFlags = find_option("dotfiles",0,0)!=0 ? SCAN_ALL : 0;
337 int cwdRelative = 0;
338 Glob *pIgnore;
339 Blob rewrittenPathname;
@@ -341,45 +387,15 @@
341
342 if( find_option("temp",0,0)!=0 ) scanFlags |= SCAN_TEMP;
343 capture_case_sensitive_option();
344 db_must_be_within_tree();
345 cwdRelative = determine_cwd_relative_option();
346 db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)",
347 filename_collation());
348 n = strlen(g.zLocalRoot);
349 blob_init(&path, g.zLocalRoot, n-1);
350 if( zIgnoreFlag==0 ){
351 zIgnoreFlag = db_get("ignore-glob", 0);
352 }
353 pIgnore = glob_create(zIgnoreFlag);
354
355 /* Load the names of all files that are candidates to be listed into sfile temp table */
356 if( g.argc < 3 ){
357 vfile_scan(&path, blob_size(&path), scanFlags, pIgnore);
358 }
359 for( i=2; i<g.argc; i++ ){
360 char *zName;
361 int isDir;
362 Blob fullName;
363
364 file_canonical_name(g.argv[i], &fullName, 0);
365 zName = blob_str(&fullName);
366 isDir = file_wd_isdir(zName);
367 if( isDir==1 ){
368 vfile_scan(&fullName, n-1, scanFlags, pIgnore);
369 }else if( isDir==0 ){
370 fossil_warning("not found: %s", zName);
371 }else if( file_access(zName, R_OK) ){
372 fossil_fatal("cannot open %s", zName);
373 }else{
374 db_multi_exec(
375 "INSERT OR IGNORE INTO sfile(x) VALUES(%Q)",
376 &zName[n]
377 );
378 }
379 blob_reset(&fullName);
380 }
381 glob_free(pIgnore);
382 db_prepare(&q,
383 "SELECT x FROM sfile"
384 " WHERE x NOT IN (%s)"
385 " ORDER BY 1",
@@ -445,14 +461,14 @@
445 */
446 void clean_cmd(void){
447 int allFlag, dryRunFlag, verboseFlag;
448 unsigned scanFlags = 0;
449 const char *zIgnoreFlag, *zKeepFlag, *zCleanFlag;
450 Blob path, repo;
451 Stmt q;
452 int n, i;
453 Glob *pIgnore, *pKeep, *pClean;
 
454
455 dryRunFlag = find_option("dry-run","n",0)!=0;
456 if( !dryRunFlag ){
457 dryRunFlag = find_option("test",0,0)!=0; /* deprecated */
458 }
@@ -473,44 +489,14 @@
473 }
474 if( zCleanFlag==0 ){
475 zCleanFlag = db_get("clean-glob", 0);
476 }
477 verify_all_options();
478 db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)",
479 filename_collation());
480 n = strlen(g.zLocalRoot);
481 blob_init(&path, g.zLocalRoot, n-1);
482 pIgnore = glob_create(zIgnoreFlag);
483 pKeep = glob_create(zKeepFlag);
484 pClean = glob_create(zCleanFlag);
485
486 /* Load the names of all files that are candidates to be cleaned into sfile temp table */
487 if( g.argc < 3 ){
488 vfile_scan2(&path, blob_size(&path), scanFlags, pIgnore, pKeep);
489 }
490 for( i=2; i<g.argc; i++ ){
491 char *zName;
492 int isDir;
493 Blob fullName;
494
495 file_canonical_name(g.argv[i], &fullName, 0);
496 zName = blob_str(&fullName);
497 isDir = file_wd_isdir(zName);
498 if( isDir==1 ){
499 vfile_scan2(&fullName, n-1, scanFlags, pIgnore, pKeep);
500 }else if( isDir==0 ){
501 fossil_warning("not found: %s", zName);
502 }else if( file_access(zName, R_OK) ){
503 fossil_fatal("cannot open %s", zName);
504 }else{
505 db_multi_exec(
506 "INSERT OR IGNORE INTO sfile(x) VALUES(%Q)",
507 &zName[n]
508 );
509 }
510 blob_reset(&fullName);
511 }
512 glob_free(pKeep);
513 glob_free(pIgnore);
514 db_prepare(&q,
515 "SELECT %Q || x FROM sfile"
516 " WHERE x NOT IN (%s)"
@@ -519,17 +505,18 @@
519 );
520 if( file_tree_name(g.zRepositoryName, &repo, 0) ){
521 db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo);
522 }
523 db_multi_exec("DELETE FROM sfile WHERE x IN (SELECT pathname FROM vfile)");
 
524 while( db_step(&q)==SQLITE_ROW ){
525 const char *zName = db_column_text(&q, 0);
526 if( !allFlag && !dryRunFlag && !glob_match(pClean, zName+n) ){
527 Blob ans;
528 char cReply;
529 char *prompt = mprintf("Remove unmanaged file \"%s\" (a=all/y/N)? ",
530 zName+n);
531 blob_zero(&ans);
532 prompt_user(prompt, &ans);
533 cReply = blob_str(&ans)[0];
534 if( cReply=='a' || cReply=='A' ){
535 allFlag = 1;
@@ -538,11 +525,11 @@
538 continue;
539 }
540 blob_reset(&ans);
541 }
542 if( verboseFlag || dryRunFlag ){
543 fossil_print("Removed unmanaged file: %s\n", zName+n);
544 }
545 if( !dryRunFlag ){
546 file_delete(zName);
547 }
548 }
549
--- src/checkin.c
+++ src/checkin.c
@@ -297,10 +297,58 @@
297 }
298 free(zFullName);
299 }
300 db_finalize(&q);
301 }
302
303 /*
304 ** Create a TEMP table named SFILE and add all unmanaged files named on the command-line
305 ** to that table. If directories are named, then add all unmanged files contained
306 ** underneath those directories. If there are no files or directories named on the
307 ** command-line, then add all unmanaged files anywhere in the checkout.
308 */
309 static void locate_unmanaged_files(
310 int argc, /* Number of command-line arguments to examine */
311 char **argv, /* values of command-line arguments */
312 unsigned scanFlags, /* Zero or more SCAN_xxx flags */
313 Glob *pIgnore1, /* Do not add files that match this GLOB */
314 Glob *pIgnore2 /* Omit files matching this GLOB too */
315 ){
316 Blob name; /* Name of a candidate file or directory */
317 char *zName; /* Name of a candidate file or directory */
318 int isDir; /* 1 for a directory, 0 if doesn't exist, 2 for anything else */
319 int i; /* Loop counter */
320 int nRoot; /* length of g.zLocalRoot */
321
322 db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)",
323 filename_collation());
324 nRoot = (int)strlen(g.zLocalRoot);
325 if( argc==0 ){
326 blob_init(&name, g.zLocalRoot, nRoot - 1);
327 vfile_scan(&name, blob_size(&name), scanFlags, pIgnore1, pIgnore2);
328 blob_reset(&name);
329 }else{
330 for(i=0; i<argc; i++){
331 file_canonical_name(argv[i], &name, 0);
332 zName = blob_str(&name);
333 isDir = file_wd_isdir(zName);
334 if( isDir==1 ){
335 vfile_scan(&name, nRoot-1, scanFlags, pIgnore1, pIgnore2);
336 }else if( isDir==0 ){
337 fossil_warning("not found: %s", zName);
338 }else if( file_access(zName, R_OK) ){
339 fossil_fatal("cannot open %s", zName);
340 }else{
341 db_multi_exec(
342 "INSERT OR IGNORE INTO sfile(x) VALUES(%Q)",
343 &zName[nRoot]
344 );
345 }
346 blob_reset(&name);
347 }
348 }
349 }
350
351 /*
352 ** COMMAND: extras
353 ** Usage: %fossil extras ?OPTIONS? ?PATH1 ...?
354 **
@@ -327,13 +375,11 @@
375 ** directory.
376 **
377 ** See also: changes, clean, status
378 */
379 void extra_cmd(void){
 
380 Stmt q;
 
381 const char *zIgnoreFlag = find_option("ignore",0,1);
382 unsigned scanFlags = find_option("dotfiles",0,0)!=0 ? SCAN_ALL : 0;
383 int cwdRelative = 0;
384 Glob *pIgnore;
385 Blob rewrittenPathname;
@@ -341,45 +387,15 @@
387
388 if( find_option("temp",0,0)!=0 ) scanFlags |= SCAN_TEMP;
389 capture_case_sensitive_option();
390 db_must_be_within_tree();
391 cwdRelative = determine_cwd_relative_option();
 
 
 
 
392 if( zIgnoreFlag==0 ){
393 zIgnoreFlag = db_get("ignore-glob", 0);
394 }
395 pIgnore = glob_create(zIgnoreFlag);
396 locate_unmanaged_files(g.argc-2, g.argv+2, scanFlags, pIgnore, 0);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
397 glob_free(pIgnore);
398 db_prepare(&q,
399 "SELECT x FROM sfile"
400 " WHERE x NOT IN (%s)"
401 " ORDER BY 1",
@@ -445,14 +461,14 @@
461 */
462 void clean_cmd(void){
463 int allFlag, dryRunFlag, verboseFlag;
464 unsigned scanFlags = 0;
465 const char *zIgnoreFlag, *zKeepFlag, *zCleanFlag;
466 Blob repo;
467 Stmt q;
 
468 Glob *pIgnore, *pKeep, *pClean;
469 int nRoot;
470
471 dryRunFlag = find_option("dry-run","n",0)!=0;
472 if( !dryRunFlag ){
473 dryRunFlag = find_option("test",0,0)!=0; /* deprecated */
474 }
@@ -473,44 +489,14 @@
489 }
490 if( zCleanFlag==0 ){
491 zCleanFlag = db_get("clean-glob", 0);
492 }
493 verify_all_options();
 
 
 
 
494 pIgnore = glob_create(zIgnoreFlag);
495 pKeep = glob_create(zKeepFlag);
496 pClean = glob_create(zCleanFlag);
497 locate_unmanaged_files(g.argc-2, g.argv+2, scanFlags, pIgnore, pKeep);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
498 glob_free(pKeep);
499 glob_free(pIgnore);
500 db_prepare(&q,
501 "SELECT %Q || x FROM sfile"
502 " WHERE x NOT IN (%s)"
@@ -519,17 +505,18 @@
505 );
506 if( file_tree_name(g.zRepositoryName, &repo, 0) ){
507 db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo);
508 }
509 db_multi_exec("DELETE FROM sfile WHERE x IN (SELECT pathname FROM vfile)");
510 nRoot = (int)strlen(g.zLocalRoot);
511 while( db_step(&q)==SQLITE_ROW ){
512 const char *zName = db_column_text(&q, 0);
513 if( !allFlag && !dryRunFlag && !glob_match(pClean, zName+nRoot) ){
514 Blob ans;
515 char cReply;
516 char *prompt = mprintf("Remove unmanaged file \"%s\" (a=all/y/N)? ",
517 zName+nRoot);
518 blob_zero(&ans);
519 prompt_user(prompt, &ans);
520 cReply = blob_str(&ans)[0];
521 if( cReply=='a' || cReply=='A' ){
522 allFlag = 1;
@@ -538,11 +525,11 @@
525 continue;
526 }
527 blob_reset(&ans);
528 }
529 if( verboseFlag || dryRunFlag ){
530 fossil_print("Removed unmanaged file: %s\n", zName+nRoot);
531 }
532 if( !dryRunFlag ){
533 file_delete(zName);
534 }
535 }
536
+7 -11
--- src/vfile.c
+++ src/vfile.c
@@ -432,20 +432,16 @@
432432
**
433433
** Any files or directories that match the glob pattern pIgnore are
434434
** excluded from the scan. Name matching occurs after the first
435435
** nPrefix characters are elided from the filename.
436436
*/
437
-void vfile_scan(Blob *pPath, int nPrefix, unsigned scanFlags, Glob *pIgnore){
438
- vfile_scan2(pPath, nPrefix, scanFlags, pIgnore, 0);
439
-}
440
-
441
-void vfile_scan2(
442
- Blob *pPath,
443
- int nPrefix,
444
- unsigned scanFlags,
445
- Glob *pIgnore1,
446
- Glob *pIgnore2
437
+void vfile_scan(
438
+ Blob *pPath, /* Directory to be scanned */
439
+ int nPrefix, /* Number of bytes in directory name */
440
+ unsigned scanFlags, /* Zero or more SCAN_xxx flags */
441
+ Glob *pIgnore1, /* Do not add files that match this GLOB */
442
+ Glob *pIgnore2 /* Omit files matching this GLOB too */
447443
){
448444
DIR *d;
449445
int origSize;
450446
const char *zDir;
451447
struct dirent *pEntry;
@@ -490,11 +486,11 @@
490486
if( glob_match(pIgnore1, &zPath[nPrefix+1]) ||
491487
glob_match(pIgnore2, &zPath[nPrefix+1]) ){
492488
/* do nothing */
493489
}else if( file_wd_isdir(zPath)==1 ){
494490
if( !vfile_top_of_checkout(zPath) ){
495
- vfile_scan2(pPath, nPrefix, scanFlags, pIgnore1, pIgnore2);
491
+ vfile_scan(pPath, nPrefix, scanFlags, pIgnore1, pIgnore2);
496492
}
497493
}else if( file_wd_isfile_or_link(zPath) ){
498494
if( (scanFlags & SCAN_TEMP)==0 || is_temporary_file(zUtf8) ){
499495
db_bind_text(&ins, ":file", &zPath[nPrefix+1]);
500496
db_step(&ins);
501497
--- src/vfile.c
+++ src/vfile.c
@@ -432,20 +432,16 @@
432 **
433 ** Any files or directories that match the glob pattern pIgnore are
434 ** excluded from the scan. Name matching occurs after the first
435 ** nPrefix characters are elided from the filename.
436 */
437 void vfile_scan(Blob *pPath, int nPrefix, unsigned scanFlags, Glob *pIgnore){
438 vfile_scan2(pPath, nPrefix, scanFlags, pIgnore, 0);
439 }
440
441 void vfile_scan2(
442 Blob *pPath,
443 int nPrefix,
444 unsigned scanFlags,
445 Glob *pIgnore1,
446 Glob *pIgnore2
447 ){
448 DIR *d;
449 int origSize;
450 const char *zDir;
451 struct dirent *pEntry;
@@ -490,11 +486,11 @@
490 if( glob_match(pIgnore1, &zPath[nPrefix+1]) ||
491 glob_match(pIgnore2, &zPath[nPrefix+1]) ){
492 /* do nothing */
493 }else if( file_wd_isdir(zPath)==1 ){
494 if( !vfile_top_of_checkout(zPath) ){
495 vfile_scan2(pPath, nPrefix, scanFlags, pIgnore1, pIgnore2);
496 }
497 }else if( file_wd_isfile_or_link(zPath) ){
498 if( (scanFlags & SCAN_TEMP)==0 || is_temporary_file(zUtf8) ){
499 db_bind_text(&ins, ":file", &zPath[nPrefix+1]);
500 db_step(&ins);
501
--- src/vfile.c
+++ src/vfile.c
@@ -432,20 +432,16 @@
432 **
433 ** Any files or directories that match the glob pattern pIgnore are
434 ** excluded from the scan. Name matching occurs after the first
435 ** nPrefix characters are elided from the filename.
436 */
437 void vfile_scan(
438 Blob *pPath, /* Directory to be scanned */
439 int nPrefix, /* Number of bytes in directory name */
440 unsigned scanFlags, /* Zero or more SCAN_xxx flags */
441 Glob *pIgnore1, /* Do not add files that match this GLOB */
442 Glob *pIgnore2 /* Omit files matching this GLOB too */
 
 
 
 
443 ){
444 DIR *d;
445 int origSize;
446 const char *zDir;
447 struct dirent *pEntry;
@@ -490,11 +486,11 @@
486 if( glob_match(pIgnore1, &zPath[nPrefix+1]) ||
487 glob_match(pIgnore2, &zPath[nPrefix+1]) ){
488 /* do nothing */
489 }else if( file_wd_isdir(zPath)==1 ){
490 if( !vfile_top_of_checkout(zPath) ){
491 vfile_scan(pPath, nPrefix, scanFlags, pIgnore1, pIgnore2);
492 }
493 }else if( file_wd_isfile_or_link(zPath) ){
494 if( (scanFlags & SCAN_TEMP)==0 || is_temporary_file(zUtf8) ){
495 db_bind_text(&ins, ":file", &zPath[nPrefix+1]);
496 db_step(&ins);
497

Keyboard Shortcuts

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