Fossil SCM

Add option --keep to "fossil clean", and matching versionable setting "keep-glob". Now you can specify which files should be kept without confirmation and which files can be removed (--ignore, "ignore-glob") without confirmation. If you want the old behavior, specify "keep-glob" to have the same value as "ignore-glob". Add versioned settings "ignore-glob" and "keep-glob" to the fossil repository.

jan.nijtmans 2013-05-06 10:13 trunk merge
Commit 982f9ec738fb181a89a8ef85c1f0d45cf26a4a04
--- a/.fossil-settings/ignore-glob
+++ b/.fossil-settings/ignore-glob
@@ -0,0 +1,6 @@
1
+*.a
2
+*.lib
3
+*.o
4
+
5
+autoconfig.h
6
+co
--- a/.fossil-settings/ignore-glob
+++ b/.fossil-settings/ignore-glob
@@ -0,0 +1,6 @@
 
 
 
 
 
 
--- a/.fossil-settings/ignore-glob
+++ b/.fossil-settings/ignore-glob
@@ -0,0 +1,6 @@
1 *.a
2 *.lib
3 *.o
4
5 autoconfig.h
6 co
--- a/.fossil-settings/keep-glob
+++ b/.fossil-settings/keep-glob
@@ -0,0 +1,2 @@
1
+fossil
2
+fossil.exe
--- a/.fossil-settings/keep-glob
+++ b/.fossil-settings/keep-glob
@@ -0,0 +1,2 @@
 
 
--- a/.fossil-settings/keep-glob
+++ b/.fossil-settings/keep-glob
@@ -0,0 +1,2 @@
1 fossil
2 fossil.exe
+24 -14
--- src/checkin.c
+++ src/checkin.c
@@ -380,41 +380,44 @@
380380
**
381381
** Delete all "extra" files in the source tree. "Extra" files are
382382
** files that are not officially part of the checkout. This operation
383383
** cannot be undone.
384384
**
385
-** You will be prompted before removing each file. If you are
386
-** sure you wish to remove all "extra" files you can specify the
387
-** optional --force flag and no prompts will be issued.
385
+** You will be prompted before removing each file, except for files
386
+** matching the patterns specified with --ignore and --keep. The GLOBPATTERN
387
+** specified by the "ignore-glob" setting is used if the --ignore
388
+** option is omitted, the same with "keep-glob" and --keep. If you are
389
+** sure you wish to remove all "extra" files except the ones specified
390
+** with --keep, you can specify the optional -f|--force flag and no prompts
391
+** will be issued. If any file matches both --keep and --ignore, --keep
392
+** takes precedence.
388393
**
389394
** Files and subdirectories whose names begin with "." are
390
-** normally ignored. They are included if the "--dotfiles" option
395
+** normally kept. They are handled if the "--dotfiles" option
391396
** is used.
392397
**
393
-** The GLOBPATTERN is a comma-separated list of GLOB expressions for
394
-** files that are ignored. The GLOBPATTERN specified by the "ignore-glob"
395
-** is used if the --ignore option is omitted.
396
-**
397398
** Options:
398399
** --case-sensitive <BOOL> override case-sensitive setting
399400
** --dotfiles include files beginning with a dot (".")
400401
** -f|--force Remove files without prompting
401
-** --ignore <CSG> ignore files matching patterns from the
402
+** --ignore <CSG> don't prompt for files matching this
402403
** comma separated list of glob patterns.
404
+** --keep <CSG> keep files matching this comma separated
405
+** list of glob patterns.
403406
** -n|--dry-run If given, display instead of run actions
404407
** --temp Remove only Fossil-generated temporary files
405408
**
406409
** See also: addremove, extra, status
407410
*/
408411
void clean_cmd(void){
409412
int allFlag;
410413
unsigned scanFlags = 0;
411
- const char *zIgnoreFlag;
414
+ const char *zIgnoreFlag, *zKeepFlag;
412415
Blob path, repo;
413416
Stmt q;
414417
int n;
415
- Glob *pIgnore;
418
+ Glob *pIgnore, *pKeep;
416419
int dryRunFlag = 0;
417420
418421
allFlag = find_option("force","f",0)!=0;
419422
if( find_option("dotfiles",0,0)!=0 ) scanFlags |= SCAN_ALL;
420423
if( find_option("temp",0,0)!=0 ) scanFlags |= SCAN_TEMP;
@@ -421,22 +424,27 @@
421424
zIgnoreFlag = find_option("ignore",0,1);
422425
dryRunFlag = find_option("dry-run","n",0)!=0;
423426
if( !dryRunFlag ){
424427
dryRunFlag = find_option("test",0,0)!=0; /* deprecated */
425428
}
429
+ zKeepFlag = find_option("keep",0,1);
426430
capture_case_sensitive_option();
427431
db_must_be_within_tree();
428432
if( zIgnoreFlag==0 ){
429433
zIgnoreFlag = db_get("ignore-glob", 0);
430434
}
435
+ if( zKeepFlag==0 ){
436
+ zKeepFlag = db_get("keep-glob", 0);
437
+ }
431438
db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)",
432439
filename_collation());
433440
n = strlen(g.zLocalRoot);
434441
blob_init(&path, g.zLocalRoot, n-1);
435442
pIgnore = glob_create(zIgnoreFlag);
436
- vfile_scan(&path, blob_size(&path), scanFlags, pIgnore);
437
- glob_free(pIgnore);
443
+ pKeep = glob_create(zKeepFlag);
444
+ vfile_scan(&path, blob_size(&path), scanFlags, pKeep);
445
+ glob_free(pKeep);
438446
db_prepare(&q,
439447
"SELECT %Q || x FROM sfile"
440448
" WHERE x NOT IN (%s)"
441449
" ORDER BY 1",
442450
g.zLocalRoot, fossil_all_reserved_names(0)
@@ -447,11 +455,11 @@
447455
db_multi_exec("DELETE FROM sfile WHERE x IN (SELECT pathname FROM vfile)");
448456
while( db_step(&q)==SQLITE_ROW ){
449457
if( dryRunFlag ){
450458
fossil_print("%s\n", db_column_text(&q,0));
451459
continue;
452
- }else if( !allFlag ){
460
+ }else if( !allFlag && !glob_match(pIgnore, db_column_text(&q, 0)+n) ){
453461
Blob ans;
454462
char cReply;
455463
char *prompt = mprintf("remove unmanaged file \"%s\" (a=all/y/N)? ",
456464
db_column_text(&q, 0));
457465
blob_zero(&ans);
@@ -461,12 +469,14 @@
461469
allFlag = 1;
462470
}else if( cReply!='y' && cReply!='Y' ){
463471
continue;
464472
}
465473
}
474
+ fossil_print("removed unmanaged file \"%s\"\n", db_column_text(&q,0));
466475
file_delete(db_column_text(&q, 0));
467476
}
477
+ glob_free(pIgnore);
468478
db_finalize(&q);
469479
}
470480
471481
/*
472482
** Prompt the user for a check-in or stash comment (given in pPrompt),
473483
--- src/checkin.c
+++ src/checkin.c
@@ -380,41 +380,44 @@
380 **
381 ** Delete all "extra" files in the source tree. "Extra" files are
382 ** files that are not officially part of the checkout. This operation
383 ** cannot be undone.
384 **
385 ** You will be prompted before removing each file. If you are
386 ** sure you wish to remove all "extra" files you can specify the
387 ** optional --force flag and no prompts will be issued.
 
 
 
 
 
388 **
389 ** Files and subdirectories whose names begin with "." are
390 ** normally ignored. They are included if the "--dotfiles" option
391 ** is used.
392 **
393 ** The GLOBPATTERN is a comma-separated list of GLOB expressions for
394 ** files that are ignored. The GLOBPATTERN specified by the "ignore-glob"
395 ** is used if the --ignore option is omitted.
396 **
397 ** Options:
398 ** --case-sensitive <BOOL> override case-sensitive setting
399 ** --dotfiles include files beginning with a dot (".")
400 ** -f|--force Remove files without prompting
401 ** --ignore <CSG> ignore files matching patterns from the
402 ** comma separated list of glob patterns.
 
 
403 ** -n|--dry-run If given, display instead of run actions
404 ** --temp Remove only Fossil-generated temporary files
405 **
406 ** See also: addremove, extra, status
407 */
408 void clean_cmd(void){
409 int allFlag;
410 unsigned scanFlags = 0;
411 const char *zIgnoreFlag;
412 Blob path, repo;
413 Stmt q;
414 int n;
415 Glob *pIgnore;
416 int dryRunFlag = 0;
417
418 allFlag = find_option("force","f",0)!=0;
419 if( find_option("dotfiles",0,0)!=0 ) scanFlags |= SCAN_ALL;
420 if( find_option("temp",0,0)!=0 ) scanFlags |= SCAN_TEMP;
@@ -421,22 +424,27 @@
421 zIgnoreFlag = find_option("ignore",0,1);
422 dryRunFlag = find_option("dry-run","n",0)!=0;
423 if( !dryRunFlag ){
424 dryRunFlag = find_option("test",0,0)!=0; /* deprecated */
425 }
 
426 capture_case_sensitive_option();
427 db_must_be_within_tree();
428 if( zIgnoreFlag==0 ){
429 zIgnoreFlag = db_get("ignore-glob", 0);
430 }
 
 
 
431 db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)",
432 filename_collation());
433 n = strlen(g.zLocalRoot);
434 blob_init(&path, g.zLocalRoot, n-1);
435 pIgnore = glob_create(zIgnoreFlag);
436 vfile_scan(&path, blob_size(&path), scanFlags, pIgnore);
437 glob_free(pIgnore);
 
438 db_prepare(&q,
439 "SELECT %Q || x FROM sfile"
440 " WHERE x NOT IN (%s)"
441 " ORDER BY 1",
442 g.zLocalRoot, fossil_all_reserved_names(0)
@@ -447,11 +455,11 @@
447 db_multi_exec("DELETE FROM sfile WHERE x IN (SELECT pathname FROM vfile)");
448 while( db_step(&q)==SQLITE_ROW ){
449 if( dryRunFlag ){
450 fossil_print("%s\n", db_column_text(&q,0));
451 continue;
452 }else if( !allFlag ){
453 Blob ans;
454 char cReply;
455 char *prompt = mprintf("remove unmanaged file \"%s\" (a=all/y/N)? ",
456 db_column_text(&q, 0));
457 blob_zero(&ans);
@@ -461,12 +469,14 @@
461 allFlag = 1;
462 }else if( cReply!='y' && cReply!='Y' ){
463 continue;
464 }
465 }
 
466 file_delete(db_column_text(&q, 0));
467 }
 
468 db_finalize(&q);
469 }
470
471 /*
472 ** Prompt the user for a check-in or stash comment (given in pPrompt),
473
--- src/checkin.c
+++ src/checkin.c
@@ -380,41 +380,44 @@
380 **
381 ** Delete all "extra" files in the source tree. "Extra" files are
382 ** files that are not officially part of the checkout. This operation
383 ** cannot be undone.
384 **
385 ** You will be prompted before removing each file, except for files
386 ** matching the patterns specified with --ignore and --keep. The GLOBPATTERN
387 ** specified by the "ignore-glob" setting is used if the --ignore
388 ** option is omitted, the same with "keep-glob" and --keep. If you are
389 ** sure you wish to remove all "extra" files except the ones specified
390 ** with --keep, you can specify the optional -f|--force flag and no prompts
391 ** will be issued. If any file matches both --keep and --ignore, --keep
392 ** takes precedence.
393 **
394 ** Files and subdirectories whose names begin with "." are
395 ** normally kept. They are handled if the "--dotfiles" option
396 ** is used.
397 **
 
 
 
 
398 ** Options:
399 ** --case-sensitive <BOOL> override case-sensitive setting
400 ** --dotfiles include files beginning with a dot (".")
401 ** -f|--force Remove files without prompting
402 ** --ignore <CSG> don't prompt for files matching this
403 ** comma separated list of glob patterns.
404 ** --keep <CSG> keep files matching this comma separated
405 ** list of glob patterns.
406 ** -n|--dry-run If given, display instead of run actions
407 ** --temp Remove only Fossil-generated temporary files
408 **
409 ** See also: addremove, extra, status
410 */
411 void clean_cmd(void){
412 int allFlag;
413 unsigned scanFlags = 0;
414 const char *zIgnoreFlag, *zKeepFlag;
415 Blob path, repo;
416 Stmt q;
417 int n;
418 Glob *pIgnore, *pKeep;
419 int dryRunFlag = 0;
420
421 allFlag = find_option("force","f",0)!=0;
422 if( find_option("dotfiles",0,0)!=0 ) scanFlags |= SCAN_ALL;
423 if( find_option("temp",0,0)!=0 ) scanFlags |= SCAN_TEMP;
@@ -421,22 +424,27 @@
424 zIgnoreFlag = find_option("ignore",0,1);
425 dryRunFlag = find_option("dry-run","n",0)!=0;
426 if( !dryRunFlag ){
427 dryRunFlag = find_option("test",0,0)!=0; /* deprecated */
428 }
429 zKeepFlag = find_option("keep",0,1);
430 capture_case_sensitive_option();
431 db_must_be_within_tree();
432 if( zIgnoreFlag==0 ){
433 zIgnoreFlag = db_get("ignore-glob", 0);
434 }
435 if( zKeepFlag==0 ){
436 zKeepFlag = db_get("keep-glob", 0);
437 }
438 db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)",
439 filename_collation());
440 n = strlen(g.zLocalRoot);
441 blob_init(&path, g.zLocalRoot, n-1);
442 pIgnore = glob_create(zIgnoreFlag);
443 pKeep = glob_create(zKeepFlag);
444 vfile_scan(&path, blob_size(&path), scanFlags, pKeep);
445 glob_free(pKeep);
446 db_prepare(&q,
447 "SELECT %Q || x FROM sfile"
448 " WHERE x NOT IN (%s)"
449 " ORDER BY 1",
450 g.zLocalRoot, fossil_all_reserved_names(0)
@@ -447,11 +455,11 @@
455 db_multi_exec("DELETE FROM sfile WHERE x IN (SELECT pathname FROM vfile)");
456 while( db_step(&q)==SQLITE_ROW ){
457 if( dryRunFlag ){
458 fossil_print("%s\n", db_column_text(&q,0));
459 continue;
460 }else if( !allFlag && !glob_match(pIgnore, db_column_text(&q, 0)+n) ){
461 Blob ans;
462 char cReply;
463 char *prompt = mprintf("remove unmanaged file \"%s\" (a=all/y/N)? ",
464 db_column_text(&q, 0));
465 blob_zero(&ans);
@@ -461,12 +469,14 @@
469 allFlag = 1;
470 }else if( cReply!='y' && cReply!='Y' ){
471 continue;
472 }
473 }
474 fossil_print("removed unmanaged file \"%s\"\n", db_column_text(&q,0));
475 file_delete(db_column_text(&q, 0));
476 }
477 glob_free(pIgnore);
478 db_finalize(&q);
479 }
480
481 /*
482 ** Prompt the user for a check-in or stash comment (given in pPrompt),
483
+24 -14
--- src/checkin.c
+++ src/checkin.c
@@ -380,41 +380,44 @@
380380
**
381381
** Delete all "extra" files in the source tree. "Extra" files are
382382
** files that are not officially part of the checkout. This operation
383383
** cannot be undone.
384384
**
385
-** You will be prompted before removing each file. If you are
386
-** sure you wish to remove all "extra" files you can specify the
387
-** optional --force flag and no prompts will be issued.
385
+** You will be prompted before removing each file, except for files
386
+** matching the patterns specified with --ignore and --keep. The GLOBPATTERN
387
+** specified by the "ignore-glob" setting is used if the --ignore
388
+** option is omitted, the same with "keep-glob" and --keep. If you are
389
+** sure you wish to remove all "extra" files except the ones specified
390
+** with --keep, you can specify the optional -f|--force flag and no prompts
391
+** will be issued. If any file matches both --keep and --ignore, --keep
392
+** takes precedence.
388393
**
389394
** Files and subdirectories whose names begin with "." are
390
-** normally ignored. They are included if the "--dotfiles" option
395
+** normally kept. They are handled if the "--dotfiles" option
391396
** is used.
392397
**
393
-** The GLOBPATTERN is a comma-separated list of GLOB expressions for
394
-** files that are ignored. The GLOBPATTERN specified by the "ignore-glob"
395
-** is used if the --ignore option is omitted.
396
-**
397398
** Options:
398399
** --case-sensitive <BOOL> override case-sensitive setting
399400
** --dotfiles include files beginning with a dot (".")
400401
** -f|--force Remove files without prompting
401
-** --ignore <CSG> ignore files matching patterns from the
402
+** --ignore <CSG> don't prompt for files matching this
402403
** comma separated list of glob patterns.
404
+** --keep <CSG> keep files matching this comma separated
405
+** list of glob patterns.
403406
** -n|--dry-run If given, display instead of run actions
404407
** --temp Remove only Fossil-generated temporary files
405408
**
406409
** See also: addremove, extra, status
407410
*/
408411
void clean_cmd(void){
409412
int allFlag;
410413
unsigned scanFlags = 0;
411
- const char *zIgnoreFlag;
414
+ const char *zIgnoreFlag, *zKeepFlag;
412415
Blob path, repo;
413416
Stmt q;
414417
int n;
415
- Glob *pIgnore;
418
+ Glob *pIgnore, *pKeep;
416419
int dryRunFlag = 0;
417420
418421
allFlag = find_option("force","f",0)!=0;
419422
if( find_option("dotfiles",0,0)!=0 ) scanFlags |= SCAN_ALL;
420423
if( find_option("temp",0,0)!=0 ) scanFlags |= SCAN_TEMP;
@@ -421,22 +424,27 @@
421424
zIgnoreFlag = find_option("ignore",0,1);
422425
dryRunFlag = find_option("dry-run","n",0)!=0;
423426
if( !dryRunFlag ){
424427
dryRunFlag = find_option("test",0,0)!=0; /* deprecated */
425428
}
429
+ zKeepFlag = find_option("keep",0,1);
426430
capture_case_sensitive_option();
427431
db_must_be_within_tree();
428432
if( zIgnoreFlag==0 ){
429433
zIgnoreFlag = db_get("ignore-glob", 0);
430434
}
435
+ if( zKeepFlag==0 ){
436
+ zKeepFlag = db_get("keep-glob", 0);
437
+ }
431438
db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)",
432439
filename_collation());
433440
n = strlen(g.zLocalRoot);
434441
blob_init(&path, g.zLocalRoot, n-1);
435442
pIgnore = glob_create(zIgnoreFlag);
436
- vfile_scan(&path, blob_size(&path), scanFlags, pIgnore);
437
- glob_free(pIgnore);
443
+ pKeep = glob_create(zKeepFlag);
444
+ vfile_scan(&path, blob_size(&path), scanFlags, pKeep);
445
+ glob_free(pKeep);
438446
db_prepare(&q,
439447
"SELECT %Q || x FROM sfile"
440448
" WHERE x NOT IN (%s)"
441449
" ORDER BY 1",
442450
g.zLocalRoot, fossil_all_reserved_names(0)
@@ -447,11 +455,11 @@
447455
db_multi_exec("DELETE FROM sfile WHERE x IN (SELECT pathname FROM vfile)");
448456
while( db_step(&q)==SQLITE_ROW ){
449457
if( dryRunFlag ){
450458
fossil_print("%s\n", db_column_text(&q,0));
451459
continue;
452
- }else if( !allFlag ){
460
+ }else if( !allFlag && !glob_match(pIgnore, db_column_text(&q, 0)+n) ){
453461
Blob ans;
454462
char cReply;
455463
char *prompt = mprintf("remove unmanaged file \"%s\" (a=all/y/N)? ",
456464
db_column_text(&q, 0));
457465
blob_zero(&ans);
@@ -461,12 +469,14 @@
461469
allFlag = 1;
462470
}else if( cReply!='y' && cReply!='Y' ){
463471
continue;
464472
}
465473
}
474
+ fossil_print("removed unmanaged file \"%s\"\n", db_column_text(&q,0));
466475
file_delete(db_column_text(&q, 0));
467476
}
477
+ glob_free(pIgnore);
468478
db_finalize(&q);
469479
}
470480
471481
/*
472482
** Prompt the user for a check-in or stash comment (given in pPrompt),
473483
--- src/checkin.c
+++ src/checkin.c
@@ -380,41 +380,44 @@
380 **
381 ** Delete all "extra" files in the source tree. "Extra" files are
382 ** files that are not officially part of the checkout. This operation
383 ** cannot be undone.
384 **
385 ** You will be prompted before removing each file. If you are
386 ** sure you wish to remove all "extra" files you can specify the
387 ** optional --force flag and no prompts will be issued.
 
 
 
 
 
388 **
389 ** Files and subdirectories whose names begin with "." are
390 ** normally ignored. They are included if the "--dotfiles" option
391 ** is used.
392 **
393 ** The GLOBPATTERN is a comma-separated list of GLOB expressions for
394 ** files that are ignored. The GLOBPATTERN specified by the "ignore-glob"
395 ** is used if the --ignore option is omitted.
396 **
397 ** Options:
398 ** --case-sensitive <BOOL> override case-sensitive setting
399 ** --dotfiles include files beginning with a dot (".")
400 ** -f|--force Remove files without prompting
401 ** --ignore <CSG> ignore files matching patterns from the
402 ** comma separated list of glob patterns.
 
 
403 ** -n|--dry-run If given, display instead of run actions
404 ** --temp Remove only Fossil-generated temporary files
405 **
406 ** See also: addremove, extra, status
407 */
408 void clean_cmd(void){
409 int allFlag;
410 unsigned scanFlags = 0;
411 const char *zIgnoreFlag;
412 Blob path, repo;
413 Stmt q;
414 int n;
415 Glob *pIgnore;
416 int dryRunFlag = 0;
417
418 allFlag = find_option("force","f",0)!=0;
419 if( find_option("dotfiles",0,0)!=0 ) scanFlags |= SCAN_ALL;
420 if( find_option("temp",0,0)!=0 ) scanFlags |= SCAN_TEMP;
@@ -421,22 +424,27 @@
421 zIgnoreFlag = find_option("ignore",0,1);
422 dryRunFlag = find_option("dry-run","n",0)!=0;
423 if( !dryRunFlag ){
424 dryRunFlag = find_option("test",0,0)!=0; /* deprecated */
425 }
 
426 capture_case_sensitive_option();
427 db_must_be_within_tree();
428 if( zIgnoreFlag==0 ){
429 zIgnoreFlag = db_get("ignore-glob", 0);
430 }
 
 
 
431 db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)",
432 filename_collation());
433 n = strlen(g.zLocalRoot);
434 blob_init(&path, g.zLocalRoot, n-1);
435 pIgnore = glob_create(zIgnoreFlag);
436 vfile_scan(&path, blob_size(&path), scanFlags, pIgnore);
437 glob_free(pIgnore);
 
438 db_prepare(&q,
439 "SELECT %Q || x FROM sfile"
440 " WHERE x NOT IN (%s)"
441 " ORDER BY 1",
442 g.zLocalRoot, fossil_all_reserved_names(0)
@@ -447,11 +455,11 @@
447 db_multi_exec("DELETE FROM sfile WHERE x IN (SELECT pathname FROM vfile)");
448 while( db_step(&q)==SQLITE_ROW ){
449 if( dryRunFlag ){
450 fossil_print("%s\n", db_column_text(&q,0));
451 continue;
452 }else if( !allFlag ){
453 Blob ans;
454 char cReply;
455 char *prompt = mprintf("remove unmanaged file \"%s\" (a=all/y/N)? ",
456 db_column_text(&q, 0));
457 blob_zero(&ans);
@@ -461,12 +469,14 @@
461 allFlag = 1;
462 }else if( cReply!='y' && cReply!='Y' ){
463 continue;
464 }
465 }
 
466 file_delete(db_column_text(&q, 0));
467 }
 
468 db_finalize(&q);
469 }
470
471 /*
472 ** Prompt the user for a check-in or stash comment (given in pPrompt),
473
--- src/checkin.c
+++ src/checkin.c
@@ -380,41 +380,44 @@
380 **
381 ** Delete all "extra" files in the source tree. "Extra" files are
382 ** files that are not officially part of the checkout. This operation
383 ** cannot be undone.
384 **
385 ** You will be prompted before removing each file, except for files
386 ** matching the patterns specified with --ignore and --keep. The GLOBPATTERN
387 ** specified by the "ignore-glob" setting is used if the --ignore
388 ** option is omitted, the same with "keep-glob" and --keep. If you are
389 ** sure you wish to remove all "extra" files except the ones specified
390 ** with --keep, you can specify the optional -f|--force flag and no prompts
391 ** will be issued. If any file matches both --keep and --ignore, --keep
392 ** takes precedence.
393 **
394 ** Files and subdirectories whose names begin with "." are
395 ** normally kept. They are handled if the "--dotfiles" option
396 ** is used.
397 **
 
 
 
 
398 ** Options:
399 ** --case-sensitive <BOOL> override case-sensitive setting
400 ** --dotfiles include files beginning with a dot (".")
401 ** -f|--force Remove files without prompting
402 ** --ignore <CSG> don't prompt for files matching this
403 ** comma separated list of glob patterns.
404 ** --keep <CSG> keep files matching this comma separated
405 ** list of glob patterns.
406 ** -n|--dry-run If given, display instead of run actions
407 ** --temp Remove only Fossil-generated temporary files
408 **
409 ** See also: addremove, extra, status
410 */
411 void clean_cmd(void){
412 int allFlag;
413 unsigned scanFlags = 0;
414 const char *zIgnoreFlag, *zKeepFlag;
415 Blob path, repo;
416 Stmt q;
417 int n;
418 Glob *pIgnore, *pKeep;
419 int dryRunFlag = 0;
420
421 allFlag = find_option("force","f",0)!=0;
422 if( find_option("dotfiles",0,0)!=0 ) scanFlags |= SCAN_ALL;
423 if( find_option("temp",0,0)!=0 ) scanFlags |= SCAN_TEMP;
@@ -421,22 +424,27 @@
424 zIgnoreFlag = find_option("ignore",0,1);
425 dryRunFlag = find_option("dry-run","n",0)!=0;
426 if( !dryRunFlag ){
427 dryRunFlag = find_option("test",0,0)!=0; /* deprecated */
428 }
429 zKeepFlag = find_option("keep",0,1);
430 capture_case_sensitive_option();
431 db_must_be_within_tree();
432 if( zIgnoreFlag==0 ){
433 zIgnoreFlag = db_get("ignore-glob", 0);
434 }
435 if( zKeepFlag==0 ){
436 zKeepFlag = db_get("keep-glob", 0);
437 }
438 db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)",
439 filename_collation());
440 n = strlen(g.zLocalRoot);
441 blob_init(&path, g.zLocalRoot, n-1);
442 pIgnore = glob_create(zIgnoreFlag);
443 pKeep = glob_create(zKeepFlag);
444 vfile_scan(&path, blob_size(&path), scanFlags, pKeep);
445 glob_free(pKeep);
446 db_prepare(&q,
447 "SELECT %Q || x FROM sfile"
448 " WHERE x NOT IN (%s)"
449 " ORDER BY 1",
450 g.zLocalRoot, fossil_all_reserved_names(0)
@@ -447,11 +455,11 @@
455 db_multi_exec("DELETE FROM sfile WHERE x IN (SELECT pathname FROM vfile)");
456 while( db_step(&q)==SQLITE_ROW ){
457 if( dryRunFlag ){
458 fossil_print("%s\n", db_column_text(&q,0));
459 continue;
460 }else if( !allFlag && !glob_match(pIgnore, db_column_text(&q, 0)+n) ){
461 Blob ans;
462 char cReply;
463 char *prompt = mprintf("remove unmanaged file \"%s\" (a=all/y/N)? ",
464 db_column_text(&q, 0));
465 blob_zero(&ans);
@@ -461,12 +469,14 @@
469 allFlag = 1;
470 }else if( cReply!='y' && cReply!='Y' ){
471 continue;
472 }
473 }
474 fossil_print("removed unmanaged file \"%s\"\n", db_column_text(&q,0));
475 file_delete(db_column_text(&q, 0));
476 }
477 glob_free(pIgnore);
478 db_finalize(&q);
479 }
480
481 /*
482 ** Prompt the user for a check-in or stash comment (given in pPrompt),
483
--- src/configure.c
+++ src/configure.c
@@ -102,10 +102,11 @@
102102
{ "project-name", CONFIGSET_PROJ },
103103
{ "project-description", CONFIGSET_PROJ },
104104
{ "manifest", CONFIGSET_PROJ },
105105
{ "binary-glob", CONFIGSET_PROJ },
106106
{ "ignore-glob", CONFIGSET_PROJ },
107
+ { "keep-glob", CONFIGSET_PROJ },
107108
{ "crnl-glob", CONFIGSET_PROJ },
108109
{ "encoding-glob", CONFIGSET_PROJ },
109110
{ "empty-dirs", CONFIGSET_PROJ },
110111
{ "allow-symlinks", CONFIGSET_PROJ },
111112
112113
--- src/configure.c
+++ src/configure.c
@@ -102,10 +102,11 @@
102 { "project-name", CONFIGSET_PROJ },
103 { "project-description", CONFIGSET_PROJ },
104 { "manifest", CONFIGSET_PROJ },
105 { "binary-glob", CONFIGSET_PROJ },
106 { "ignore-glob", CONFIGSET_PROJ },
 
107 { "crnl-glob", CONFIGSET_PROJ },
108 { "encoding-glob", CONFIGSET_PROJ },
109 { "empty-dirs", CONFIGSET_PROJ },
110 { "allow-symlinks", CONFIGSET_PROJ },
111
112
--- src/configure.c
+++ src/configure.c
@@ -102,10 +102,11 @@
102 { "project-name", CONFIGSET_PROJ },
103 { "project-description", CONFIGSET_PROJ },
104 { "manifest", CONFIGSET_PROJ },
105 { "binary-glob", CONFIGSET_PROJ },
106 { "ignore-glob", CONFIGSET_PROJ },
107 { "keep-glob", CONFIGSET_PROJ },
108 { "crnl-glob", CONFIGSET_PROJ },
109 { "encoding-glob", CONFIGSET_PROJ },
110 { "empty-dirs", CONFIGSET_PROJ },
111 { "allow-symlinks", CONFIGSET_PROJ },
112
113
+5
--- src/db.c
+++ src/db.c
@@ -2109,10 +2109,11 @@
21092109
{ "gdiff-command", 0, 40, 0, "gdiff" },
21102110
{ "gmerge-command",0, 40, 0, "" },
21112111
{ "http-port", 0, 16, 0, "8080" },
21122112
{ "https-login", 0, 0, 0, "off" },
21132113
{ "ignore-glob", 0, 40, 1, "" },
2114
+ { "keep-glob", 0, 40, 1, "" },
21142115
{ "localauth", 0, 0, 0, "off" },
21152116
{ "main-branch", 0, 40, 0, "trunk" },
21162117
{ "manifest", 0, 0, 1, "off" },
21172118
{ "max-upload", 0, 25, 0, "250000" },
21182119
{ "mtime-changes", 0, 0, 0, "on" },
@@ -2239,10 +2240,14 @@
22392240
** even if the login page request came via HTTP.
22402241
**
22412242
** ignore-glob The VALUE is a comma or newline-separated list of GLOB
22422243
** (versionable) patterns specifying files that the "extra" command will
22432244
** ignore. Example: *.o,*.obj,*.exe
2245
+**
2246
+** keep-glob The VALUE is a comma or newline-separated list of GLOB
2247
+** (versionable) patterns specifying files that the "clean" command will
2248
+** keep. Example: *.log
22442249
**
22452250
** localauth If enabled, require that HTTP connections from
22462251
** 127.0.0.1 be authenticated by password. If
22472252
** false, all HTTP requests from localhost have
22482253
** unrestricted access to the repository.
22492254
--- src/db.c
+++ src/db.c
@@ -2109,10 +2109,11 @@
2109 { "gdiff-command", 0, 40, 0, "gdiff" },
2110 { "gmerge-command",0, 40, 0, "" },
2111 { "http-port", 0, 16, 0, "8080" },
2112 { "https-login", 0, 0, 0, "off" },
2113 { "ignore-glob", 0, 40, 1, "" },
 
2114 { "localauth", 0, 0, 0, "off" },
2115 { "main-branch", 0, 40, 0, "trunk" },
2116 { "manifest", 0, 0, 1, "off" },
2117 { "max-upload", 0, 25, 0, "250000" },
2118 { "mtime-changes", 0, 0, 0, "on" },
@@ -2239,10 +2240,14 @@
2239 ** even if the login page request came via HTTP.
2240 **
2241 ** ignore-glob The VALUE is a comma or newline-separated list of GLOB
2242 ** (versionable) patterns specifying files that the "extra" command will
2243 ** ignore. Example: *.o,*.obj,*.exe
 
 
 
 
2244 **
2245 ** localauth If enabled, require that HTTP connections from
2246 ** 127.0.0.1 be authenticated by password. If
2247 ** false, all HTTP requests from localhost have
2248 ** unrestricted access to the repository.
2249
--- src/db.c
+++ src/db.c
@@ -2109,10 +2109,11 @@
2109 { "gdiff-command", 0, 40, 0, "gdiff" },
2110 { "gmerge-command",0, 40, 0, "" },
2111 { "http-port", 0, 16, 0, "8080" },
2112 { "https-login", 0, 0, 0, "off" },
2113 { "ignore-glob", 0, 40, 1, "" },
2114 { "keep-glob", 0, 40, 1, "" },
2115 { "localauth", 0, 0, 0, "off" },
2116 { "main-branch", 0, 40, 0, "trunk" },
2117 { "manifest", 0, 0, 1, "off" },
2118 { "max-upload", 0, 25, 0, "250000" },
2119 { "mtime-changes", 0, 0, 0, "on" },
@@ -2239,10 +2240,14 @@
2240 ** even if the login page request came via HTTP.
2241 **
2242 ** ignore-glob The VALUE is a comma or newline-separated list of GLOB
2243 ** (versionable) patterns specifying files that the "extra" command will
2244 ** ignore. Example: *.o,*.obj,*.exe
2245 **
2246 ** keep-glob The VALUE is a comma or newline-separated list of GLOB
2247 ** (versionable) patterns specifying files that the "clean" command will
2248 ** keep. Example: *.log
2249 **
2250 ** localauth If enabled, require that HTTP connections from
2251 ** 127.0.0.1 be authenticated by password. If
2252 ** false, all HTTP requests from localhost have
2253 ** unrestricted access to the repository.
2254
--- src/json_config.c
+++ src/json_config.c
@@ -64,10 +64,11 @@
6464
6565
{ "project-name", CONFIGSET_PROJ },
6666
{ "project-description", CONFIGSET_PROJ },
6767
{ "manifest", CONFIGSET_PROJ },
6868
{ "ignore-glob", CONFIGSET_PROJ },
69
+{ "keep-glob", CONFIGSET_PROJ },
6970
{ "crnl-glob", CONFIGSET_PROJ },
7071
{ "empty-dirs", CONFIGSET_PROJ },
7172
{ "allow-symlinks", CONFIGSET_PROJ },
7273
7374
{ "ticket-table", CONFIGSET_TKT },
7475
--- src/json_config.c
+++ src/json_config.c
@@ -64,10 +64,11 @@
64
65 { "project-name", CONFIGSET_PROJ },
66 { "project-description", CONFIGSET_PROJ },
67 { "manifest", CONFIGSET_PROJ },
68 { "ignore-glob", CONFIGSET_PROJ },
 
69 { "crnl-glob", CONFIGSET_PROJ },
70 { "empty-dirs", CONFIGSET_PROJ },
71 { "allow-symlinks", CONFIGSET_PROJ },
72
73 { "ticket-table", CONFIGSET_TKT },
74
--- src/json_config.c
+++ src/json_config.c
@@ -64,10 +64,11 @@
64
65 { "project-name", CONFIGSET_PROJ },
66 { "project-description", CONFIGSET_PROJ },
67 { "manifest", CONFIGSET_PROJ },
68 { "ignore-glob", CONFIGSET_PROJ },
69 { "keep-glob", CONFIGSET_PROJ },
70 { "crnl-glob", CONFIGSET_PROJ },
71 { "empty-dirs", CONFIGSET_PROJ },
72 { "allow-symlinks", CONFIGSET_PROJ },
73
74 { "ticket-table", CONFIGSET_TKT },
75
--- www/settings.wiki
+++ www/settings.wiki
@@ -18,11 +18,11 @@
1818
1919
<h3>"Versionable" settings</h3>
2020
2121
Most of the settings control the behaviour of fossil on your local machine, largely acting to reflect your preference on how you want to use Fossil, how you communicate with the server, or options for hosting a repository on the web.
2222
23
-However, for historical reasons, some settings affect how you work with versioned files. These are <tt>allow-symlinks</tt>, <tt>binary-glob</tt>, <tt>crnl-glob</tt>, <tt>empty-dirs</tt>, <tt>encoding-glob</tt>, <tt>ignore-glob</tt> and <tt>manifest</tt>. The most important is <tt>ignore-glob</tt> which specifies which files should be ignored when looking for unmanaged files with the <tt>extras</tt> command.
23
+However, for historical reasons, some settings affect how you work with versioned files. These are <tt>allow-symlinks</tt>, <tt>binary-glob</tt>, <tt>crnl-glob</tt>, <tt>empty-dirs</tt>, <tt>encoding-glob</tt>, <tt>ignore-glob</tt>, <tt>keep-glob</tt> and <tt>manifest</tt>. The most important is <tt>ignore-glob</tt> which specifies which files should be ignored when looking for unmanaged files with the <tt>extras</tt> command.
2424
2525
Because these options can change over time, and the inconvenience of replicating changes, these settings are "versionable". As well as being able to be set using the <tt>settings</tt> command or the web interface, you can created versioned files in the <tt>.fossil-settings</tt> directory named with the setting name. The contents of the file is the value of the setting, and these files are checked in, committed, merged, and so on, as with any other file.
2626
2727
Where a setting is a list of values, such as <tt>ignore-glob</tt>, you can use a newline as a separator as well as a comma.
2828
2929
--- www/settings.wiki
+++ www/settings.wiki
@@ -18,11 +18,11 @@
18
19 <h3>"Versionable" settings</h3>
20
21 Most of the settings control the behaviour of fossil on your local machine, largely acting to reflect your preference on how you want to use Fossil, how you communicate with the server, or options for hosting a repository on the web.
22
23 However, for historical reasons, some settings affect how you work with versioned files. These are <tt>allow-symlinks</tt>, <tt>binary-glob</tt>, <tt>crnl-glob</tt>, <tt>empty-dirs</tt>, <tt>encoding-glob</tt>, <tt>ignore-glob</tt> and <tt>manifest</tt>. The most important is <tt>ignore-glob</tt> which specifies which files should be ignored when looking for unmanaged files with the <tt>extras</tt> command.
24
25 Because these options can change over time, and the inconvenience of replicating changes, these settings are "versionable". As well as being able to be set using the <tt>settings</tt> command or the web interface, you can created versioned files in the <tt>.fossil-settings</tt> directory named with the setting name. The contents of the file is the value of the setting, and these files are checked in, committed, merged, and so on, as with any other file.
26
27 Where a setting is a list of values, such as <tt>ignore-glob</tt>, you can use a newline as a separator as well as a comma.
28
29
--- www/settings.wiki
+++ www/settings.wiki
@@ -18,11 +18,11 @@
18
19 <h3>"Versionable" settings</h3>
20
21 Most of the settings control the behaviour of fossil on your local machine, largely acting to reflect your preference on how you want to use Fossil, how you communicate with the server, or options for hosting a repository on the web.
22
23 However, for historical reasons, some settings affect how you work with versioned files. These are <tt>allow-symlinks</tt>, <tt>binary-glob</tt>, <tt>crnl-glob</tt>, <tt>empty-dirs</tt>, <tt>encoding-glob</tt>, <tt>ignore-glob</tt>, <tt>keep-glob</tt> and <tt>manifest</tt>. The most important is <tt>ignore-glob</tt> which specifies which files should be ignored when looking for unmanaged files with the <tt>extras</tt> command.
24
25 Because these options can change over time, and the inconvenience of replicating changes, these settings are "versionable". As well as being able to be set using the <tt>settings</tt> command or the web interface, you can created versioned files in the <tt>.fossil-settings</tt> directory named with the setting name. The contents of the file is the value of the setting, and these files are checked in, committed, merged, and so on, as with any other file.
26
27 Where a setting is a list of values, such as <tt>ignore-glob</tt>, you can use a newline as a separator as well as a comma.
28
29

Keyboard Shortcuts

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