Fossil SCM
rebase
Commit
7f0507c04da883bb64b74d7dd3f2630cda91fdcc
Parent
4e573871bcef919…
2 files changed
+13
-6
+13
-6
+13
-6
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -236,11 +236,11 @@ | ||
| 236 | 236 | int verboseFlag; |
| 237 | 237 | int showAge; |
| 238 | 238 | char *zOrderBy = "pathname"; |
| 239 | 239 | |
| 240 | 240 | verboseFlag = find_option("verbose","v", 0)!=0; |
| 241 | - if(!verboseFlag){ | |
| 241 | + if( !verboseFlag ){ | |
| 242 | 242 | verboseFlag = find_option("l","l", 0)!=0; /* deprecated */ |
| 243 | 243 | } |
| 244 | 244 | showAge = find_option("age",0,0)!=0; |
| 245 | 245 | db_must_be_within_tree(); |
| 246 | 246 | vid = db_lget_int("checkout", 0); |
| @@ -381,11 +381,13 @@ | ||
| 381 | 381 | ** COMMAND: clean |
| 382 | 382 | ** Usage: %fossil clean ?OPTIONS? |
| 383 | 383 | ** |
| 384 | 384 | ** Delete all "extra" files in the source tree. "Extra" files are |
| 385 | 385 | ** files that are not officially part of the checkout. This operation |
| 386 | -** cannot be undone. | |
| 386 | +** cannot be undone. Normally, only files unknown to fossil are | |
| 387 | +** removed, but if the -x option is specified, ignored files are | |
| 388 | +** removed as well. | |
| 387 | 389 | ** |
| 388 | 390 | ** You will be prompted before removing each eligible file unless the |
| 389 | 391 | ** --force flag is in use or it matches the --clean option. The |
| 390 | 392 | ** GLOBPATTERN specified by the "ignore-glob" setting is used if the |
| 391 | 393 | ** --ignore option is omitted, the same with "clean-glob" and --clean |
| @@ -410,23 +412,27 @@ | ||
| 410 | 412 | ** --keep <CSG> keep files matching this comma separated |
| 411 | 413 | ** list of glob patterns. |
| 412 | 414 | ** -n|--dry-run If given, display instead of run actions |
| 413 | 415 | ** --temp Remove only Fossil-generated temporary files |
| 414 | 416 | ** -v|--verbose Show all files as they are removed |
| 417 | +** -x Remove everything unkown to fossil, | |
| 418 | +** including files matching --ignore. | |
| 419 | +** Compatibile with "git clean -x". | |
| 415 | 420 | ** |
| 416 | 421 | ** See also: addremove, extra, status |
| 417 | 422 | */ |
| 418 | 423 | void clean_cmd(void){ |
| 419 | - int allFlag, dryRunFlag, verboseFlag; | |
| 424 | + int allFlag, dryRunFlag, verboseFlag, xFlag; | |
| 420 | 425 | unsigned scanFlags = 0; |
| 421 | 426 | const char *zIgnoreFlag, *zKeepFlag, *zCleanFlag; |
| 422 | 427 | Blob path, repo; |
| 423 | 428 | Stmt q; |
| 424 | 429 | int n; |
| 425 | 430 | Glob *pIgnore, *pKeep, *pClean; |
| 426 | 431 | |
| 427 | 432 | dryRunFlag = find_option("dry-run","n",0)!=0; |
| 433 | + xFlag = find_option("x","x",0)!=0; | |
| 428 | 434 | if( !dryRunFlag ){ |
| 429 | 435 | dryRunFlag = find_option("test",0,0)!=0; /* deprecated */ |
| 430 | 436 | } |
| 431 | 437 | allFlag = find_option("force","f",0)!=0 || dryRunFlag; |
| 432 | 438 | if( find_option("dotfiles",0,0)!=0 ) scanFlags |= SCAN_ALL; |
| @@ -452,13 +458,12 @@ | ||
| 452 | 458 | n = strlen(g.zLocalRoot); |
| 453 | 459 | blob_init(&path, g.zLocalRoot, n-1); |
| 454 | 460 | pIgnore = glob_create(zIgnoreFlag); |
| 455 | 461 | pKeep = glob_create(zKeepFlag); |
| 456 | 462 | pClean = glob_create(zCleanFlag); |
| 457 | - vfile_scan2(&path, blob_size(&path), scanFlags, pIgnore, pKeep); | |
| 463 | + vfile_scan2(&path, blob_size(&path), scanFlags, xFlag?0:pIgnore, pKeep); | |
| 458 | 464 | glob_free(pKeep); |
| 459 | - glob_free(pIgnore); | |
| 460 | 465 | db_prepare(&q, |
| 461 | 466 | "SELECT %Q || x FROM sfile" |
| 462 | 467 | " WHERE x NOT IN (%s)" |
| 463 | 468 | " ORDER BY 1", |
| 464 | 469 | g.zLocalRoot, fossil_all_reserved_names(0) |
| @@ -467,11 +472,12 @@ | ||
| 467 | 472 | db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo); |
| 468 | 473 | } |
| 469 | 474 | db_multi_exec("DELETE FROM sfile WHERE x IN (SELECT pathname FROM vfile)"); |
| 470 | 475 | while( db_step(&q)==SQLITE_ROW ){ |
| 471 | 476 | const char *zName = db_column_text(&q, 0); |
| 472 | - if( !allFlag && !glob_match(pClean, zName+n) ){ | |
| 477 | + if( !allFlag && !glob_match(pClean, zName+n) | |
| 478 | + && (!xFlag || !glob_match(pIgnore, zName+n))){ | |
| 473 | 479 | Blob ans; |
| 474 | 480 | char cReply; |
| 475 | 481 | char *prompt = mprintf("remove unmanaged file \"%s\" (a=all/y/N)? ", |
| 476 | 482 | zName+n); |
| 477 | 483 | blob_zero(&ans); |
| @@ -488,10 +494,11 @@ | ||
| 488 | 494 | } |
| 489 | 495 | if( !dryRunFlag ){ |
| 490 | 496 | file_delete(zName); |
| 491 | 497 | } |
| 492 | 498 | } |
| 499 | + glob_free(pIgnore); | |
| 493 | 500 | glob_free(pClean); |
| 494 | 501 | db_finalize(&q); |
| 495 | 502 | } |
| 496 | 503 | |
| 497 | 504 | /* |
| 498 | 505 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -236,11 +236,11 @@ | |
| 236 | int verboseFlag; |
| 237 | int showAge; |
| 238 | char *zOrderBy = "pathname"; |
| 239 | |
| 240 | verboseFlag = find_option("verbose","v", 0)!=0; |
| 241 | if(!verboseFlag){ |
| 242 | verboseFlag = find_option("l","l", 0)!=0; /* deprecated */ |
| 243 | } |
| 244 | showAge = find_option("age",0,0)!=0; |
| 245 | db_must_be_within_tree(); |
| 246 | vid = db_lget_int("checkout", 0); |
| @@ -381,11 +381,13 @@ | |
| 381 | ** COMMAND: clean |
| 382 | ** Usage: %fossil clean ?OPTIONS? |
| 383 | ** |
| 384 | ** Delete all "extra" files in the source tree. "Extra" files are |
| 385 | ** files that are not officially part of the checkout. This operation |
| 386 | ** cannot be undone. |
| 387 | ** |
| 388 | ** You will be prompted before removing each eligible file unless the |
| 389 | ** --force flag is in use or it matches the --clean option. The |
| 390 | ** GLOBPATTERN specified by the "ignore-glob" setting is used if the |
| 391 | ** --ignore option is omitted, the same with "clean-glob" and --clean |
| @@ -410,23 +412,27 @@ | |
| 410 | ** --keep <CSG> keep files matching this comma separated |
| 411 | ** list of glob patterns. |
| 412 | ** -n|--dry-run If given, display instead of run actions |
| 413 | ** --temp Remove only Fossil-generated temporary files |
| 414 | ** -v|--verbose Show all files as they are removed |
| 415 | ** |
| 416 | ** See also: addremove, extra, status |
| 417 | */ |
| 418 | void clean_cmd(void){ |
| 419 | int allFlag, dryRunFlag, verboseFlag; |
| 420 | unsigned scanFlags = 0; |
| 421 | const char *zIgnoreFlag, *zKeepFlag, *zCleanFlag; |
| 422 | Blob path, repo; |
| 423 | Stmt q; |
| 424 | int n; |
| 425 | Glob *pIgnore, *pKeep, *pClean; |
| 426 | |
| 427 | dryRunFlag = find_option("dry-run","n",0)!=0; |
| 428 | if( !dryRunFlag ){ |
| 429 | dryRunFlag = find_option("test",0,0)!=0; /* deprecated */ |
| 430 | } |
| 431 | allFlag = find_option("force","f",0)!=0 || dryRunFlag; |
| 432 | if( find_option("dotfiles",0,0)!=0 ) scanFlags |= SCAN_ALL; |
| @@ -452,13 +458,12 @@ | |
| 452 | n = strlen(g.zLocalRoot); |
| 453 | blob_init(&path, g.zLocalRoot, n-1); |
| 454 | pIgnore = glob_create(zIgnoreFlag); |
| 455 | pKeep = glob_create(zKeepFlag); |
| 456 | pClean = glob_create(zCleanFlag); |
| 457 | vfile_scan2(&path, blob_size(&path), scanFlags, pIgnore, pKeep); |
| 458 | glob_free(pKeep); |
| 459 | glob_free(pIgnore); |
| 460 | db_prepare(&q, |
| 461 | "SELECT %Q || x FROM sfile" |
| 462 | " WHERE x NOT IN (%s)" |
| 463 | " ORDER BY 1", |
| 464 | g.zLocalRoot, fossil_all_reserved_names(0) |
| @@ -467,11 +472,12 @@ | |
| 467 | db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo); |
| 468 | } |
| 469 | db_multi_exec("DELETE FROM sfile WHERE x IN (SELECT pathname FROM vfile)"); |
| 470 | while( db_step(&q)==SQLITE_ROW ){ |
| 471 | const char *zName = db_column_text(&q, 0); |
| 472 | if( !allFlag && !glob_match(pClean, zName+n) ){ |
| 473 | Blob ans; |
| 474 | char cReply; |
| 475 | char *prompt = mprintf("remove unmanaged file \"%s\" (a=all/y/N)? ", |
| 476 | zName+n); |
| 477 | blob_zero(&ans); |
| @@ -488,10 +494,11 @@ | |
| 488 | } |
| 489 | if( !dryRunFlag ){ |
| 490 | file_delete(zName); |
| 491 | } |
| 492 | } |
| 493 | glob_free(pClean); |
| 494 | db_finalize(&q); |
| 495 | } |
| 496 | |
| 497 | /* |
| 498 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -236,11 +236,11 @@ | |
| 236 | int verboseFlag; |
| 237 | int showAge; |
| 238 | char *zOrderBy = "pathname"; |
| 239 | |
| 240 | verboseFlag = find_option("verbose","v", 0)!=0; |
| 241 | if( !verboseFlag ){ |
| 242 | verboseFlag = find_option("l","l", 0)!=0; /* deprecated */ |
| 243 | } |
| 244 | showAge = find_option("age",0,0)!=0; |
| 245 | db_must_be_within_tree(); |
| 246 | vid = db_lget_int("checkout", 0); |
| @@ -381,11 +381,13 @@ | |
| 381 | ** COMMAND: clean |
| 382 | ** Usage: %fossil clean ?OPTIONS? |
| 383 | ** |
| 384 | ** Delete all "extra" files in the source tree. "Extra" files are |
| 385 | ** files that are not officially part of the checkout. This operation |
| 386 | ** cannot be undone. Normally, only files unknown to fossil are |
| 387 | ** removed, but if the -x option is specified, ignored files are |
| 388 | ** removed as well. |
| 389 | ** |
| 390 | ** You will be prompted before removing each eligible file unless the |
| 391 | ** --force flag is in use or it matches the --clean option. The |
| 392 | ** GLOBPATTERN specified by the "ignore-glob" setting is used if the |
| 393 | ** --ignore option is omitted, the same with "clean-glob" and --clean |
| @@ -410,23 +412,27 @@ | |
| 412 | ** --keep <CSG> keep files matching this comma separated |
| 413 | ** list of glob patterns. |
| 414 | ** -n|--dry-run If given, display instead of run actions |
| 415 | ** --temp Remove only Fossil-generated temporary files |
| 416 | ** -v|--verbose Show all files as they are removed |
| 417 | ** -x Remove everything unkown to fossil, |
| 418 | ** including files matching --ignore. |
| 419 | ** Compatibile with "git clean -x". |
| 420 | ** |
| 421 | ** See also: addremove, extra, status |
| 422 | */ |
| 423 | void clean_cmd(void){ |
| 424 | int allFlag, dryRunFlag, verboseFlag, xFlag; |
| 425 | unsigned scanFlags = 0; |
| 426 | const char *zIgnoreFlag, *zKeepFlag, *zCleanFlag; |
| 427 | Blob path, repo; |
| 428 | Stmt q; |
| 429 | int n; |
| 430 | Glob *pIgnore, *pKeep, *pClean; |
| 431 | |
| 432 | dryRunFlag = find_option("dry-run","n",0)!=0; |
| 433 | xFlag = find_option("x","x",0)!=0; |
| 434 | if( !dryRunFlag ){ |
| 435 | dryRunFlag = find_option("test",0,0)!=0; /* deprecated */ |
| 436 | } |
| 437 | allFlag = find_option("force","f",0)!=0 || dryRunFlag; |
| 438 | if( find_option("dotfiles",0,0)!=0 ) scanFlags |= SCAN_ALL; |
| @@ -452,13 +458,12 @@ | |
| 458 | n = strlen(g.zLocalRoot); |
| 459 | blob_init(&path, g.zLocalRoot, n-1); |
| 460 | pIgnore = glob_create(zIgnoreFlag); |
| 461 | pKeep = glob_create(zKeepFlag); |
| 462 | pClean = glob_create(zCleanFlag); |
| 463 | vfile_scan2(&path, blob_size(&path), scanFlags, xFlag?0:pIgnore, pKeep); |
| 464 | glob_free(pKeep); |
| 465 | db_prepare(&q, |
| 466 | "SELECT %Q || x FROM sfile" |
| 467 | " WHERE x NOT IN (%s)" |
| 468 | " ORDER BY 1", |
| 469 | g.zLocalRoot, fossil_all_reserved_names(0) |
| @@ -467,11 +472,12 @@ | |
| 472 | db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo); |
| 473 | } |
| 474 | db_multi_exec("DELETE FROM sfile WHERE x IN (SELECT pathname FROM vfile)"); |
| 475 | while( db_step(&q)==SQLITE_ROW ){ |
| 476 | const char *zName = db_column_text(&q, 0); |
| 477 | if( !allFlag && !glob_match(pClean, zName+n) |
| 478 | && (!xFlag || !glob_match(pIgnore, zName+n))){ |
| 479 | Blob ans; |
| 480 | char cReply; |
| 481 | char *prompt = mprintf("remove unmanaged file \"%s\" (a=all/y/N)? ", |
| 482 | zName+n); |
| 483 | blob_zero(&ans); |
| @@ -488,10 +494,11 @@ | |
| 494 | } |
| 495 | if( !dryRunFlag ){ |
| 496 | file_delete(zName); |
| 497 | } |
| 498 | } |
| 499 | glob_free(pIgnore); |
| 500 | glob_free(pClean); |
| 501 | db_finalize(&q); |
| 502 | } |
| 503 | |
| 504 | /* |
| 505 |
+13
-6
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -236,11 +236,11 @@ | ||
| 236 | 236 | int verboseFlag; |
| 237 | 237 | int showAge; |
| 238 | 238 | char *zOrderBy = "pathname"; |
| 239 | 239 | |
| 240 | 240 | verboseFlag = find_option("verbose","v", 0)!=0; |
| 241 | - if(!verboseFlag){ | |
| 241 | + if( !verboseFlag ){ | |
| 242 | 242 | verboseFlag = find_option("l","l", 0)!=0; /* deprecated */ |
| 243 | 243 | } |
| 244 | 244 | showAge = find_option("age",0,0)!=0; |
| 245 | 245 | db_must_be_within_tree(); |
| 246 | 246 | vid = db_lget_int("checkout", 0); |
| @@ -381,11 +381,13 @@ | ||
| 381 | 381 | ** COMMAND: clean |
| 382 | 382 | ** Usage: %fossil clean ?OPTIONS? |
| 383 | 383 | ** |
| 384 | 384 | ** Delete all "extra" files in the source tree. "Extra" files are |
| 385 | 385 | ** files that are not officially part of the checkout. This operation |
| 386 | -** cannot be undone. | |
| 386 | +** cannot be undone. Normally, only files unknown to fossil are | |
| 387 | +** removed, but if the -x option is specified, ignored files are | |
| 388 | +** removed as well. | |
| 387 | 389 | ** |
| 388 | 390 | ** You will be prompted before removing each eligible file unless the |
| 389 | 391 | ** --force flag is in use or it matches the --clean option. The |
| 390 | 392 | ** GLOBPATTERN specified by the "ignore-glob" setting is used if the |
| 391 | 393 | ** --ignore option is omitted, the same with "clean-glob" and --clean |
| @@ -410,23 +412,27 @@ | ||
| 410 | 412 | ** --keep <CSG> keep files matching this comma separated |
| 411 | 413 | ** list of glob patterns. |
| 412 | 414 | ** -n|--dry-run If given, display instead of run actions |
| 413 | 415 | ** --temp Remove only Fossil-generated temporary files |
| 414 | 416 | ** -v|--verbose Show all files as they are removed |
| 417 | +** -x Remove everything unkown to fossil, | |
| 418 | +** including files matching --ignore. | |
| 419 | +** Compatibile with "git clean -x". | |
| 415 | 420 | ** |
| 416 | 421 | ** See also: addremove, extra, status |
| 417 | 422 | */ |
| 418 | 423 | void clean_cmd(void){ |
| 419 | - int allFlag, dryRunFlag, verboseFlag; | |
| 424 | + int allFlag, dryRunFlag, verboseFlag, xFlag; | |
| 420 | 425 | unsigned scanFlags = 0; |
| 421 | 426 | const char *zIgnoreFlag, *zKeepFlag, *zCleanFlag; |
| 422 | 427 | Blob path, repo; |
| 423 | 428 | Stmt q; |
| 424 | 429 | int n; |
| 425 | 430 | Glob *pIgnore, *pKeep, *pClean; |
| 426 | 431 | |
| 427 | 432 | dryRunFlag = find_option("dry-run","n",0)!=0; |
| 433 | + xFlag = find_option("x","x",0)!=0; | |
| 428 | 434 | if( !dryRunFlag ){ |
| 429 | 435 | dryRunFlag = find_option("test",0,0)!=0; /* deprecated */ |
| 430 | 436 | } |
| 431 | 437 | allFlag = find_option("force","f",0)!=0 || dryRunFlag; |
| 432 | 438 | if( find_option("dotfiles",0,0)!=0 ) scanFlags |= SCAN_ALL; |
| @@ -452,13 +458,12 @@ | ||
| 452 | 458 | n = strlen(g.zLocalRoot); |
| 453 | 459 | blob_init(&path, g.zLocalRoot, n-1); |
| 454 | 460 | pIgnore = glob_create(zIgnoreFlag); |
| 455 | 461 | pKeep = glob_create(zKeepFlag); |
| 456 | 462 | pClean = glob_create(zCleanFlag); |
| 457 | - vfile_scan2(&path, blob_size(&path), scanFlags, pIgnore, pKeep); | |
| 463 | + vfile_scan2(&path, blob_size(&path), scanFlags, xFlag?0:pIgnore, pKeep); | |
| 458 | 464 | glob_free(pKeep); |
| 459 | - glob_free(pIgnore); | |
| 460 | 465 | db_prepare(&q, |
| 461 | 466 | "SELECT %Q || x FROM sfile" |
| 462 | 467 | " WHERE x NOT IN (%s)" |
| 463 | 468 | " ORDER BY 1", |
| 464 | 469 | g.zLocalRoot, fossil_all_reserved_names(0) |
| @@ -467,11 +472,12 @@ | ||
| 467 | 472 | db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo); |
| 468 | 473 | } |
| 469 | 474 | db_multi_exec("DELETE FROM sfile WHERE x IN (SELECT pathname FROM vfile)"); |
| 470 | 475 | while( db_step(&q)==SQLITE_ROW ){ |
| 471 | 476 | const char *zName = db_column_text(&q, 0); |
| 472 | - if( !allFlag && !glob_match(pClean, zName+n) ){ | |
| 477 | + if( !allFlag && !glob_match(pClean, zName+n) | |
| 478 | + && (!xFlag || !glob_match(pIgnore, zName+n))){ | |
| 473 | 479 | Blob ans; |
| 474 | 480 | char cReply; |
| 475 | 481 | char *prompt = mprintf("remove unmanaged file \"%s\" (a=all/y/N)? ", |
| 476 | 482 | zName+n); |
| 477 | 483 | blob_zero(&ans); |
| @@ -488,10 +494,11 @@ | ||
| 488 | 494 | } |
| 489 | 495 | if( !dryRunFlag ){ |
| 490 | 496 | file_delete(zName); |
| 491 | 497 | } |
| 492 | 498 | } |
| 499 | + glob_free(pIgnore); | |
| 493 | 500 | glob_free(pClean); |
| 494 | 501 | db_finalize(&q); |
| 495 | 502 | } |
| 496 | 503 | |
| 497 | 504 | /* |
| 498 | 505 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -236,11 +236,11 @@ | |
| 236 | int verboseFlag; |
| 237 | int showAge; |
| 238 | char *zOrderBy = "pathname"; |
| 239 | |
| 240 | verboseFlag = find_option("verbose","v", 0)!=0; |
| 241 | if(!verboseFlag){ |
| 242 | verboseFlag = find_option("l","l", 0)!=0; /* deprecated */ |
| 243 | } |
| 244 | showAge = find_option("age",0,0)!=0; |
| 245 | db_must_be_within_tree(); |
| 246 | vid = db_lget_int("checkout", 0); |
| @@ -381,11 +381,13 @@ | |
| 381 | ** COMMAND: clean |
| 382 | ** Usage: %fossil clean ?OPTIONS? |
| 383 | ** |
| 384 | ** Delete all "extra" files in the source tree. "Extra" files are |
| 385 | ** files that are not officially part of the checkout. This operation |
| 386 | ** cannot be undone. |
| 387 | ** |
| 388 | ** You will be prompted before removing each eligible file unless the |
| 389 | ** --force flag is in use or it matches the --clean option. The |
| 390 | ** GLOBPATTERN specified by the "ignore-glob" setting is used if the |
| 391 | ** --ignore option is omitted, the same with "clean-glob" and --clean |
| @@ -410,23 +412,27 @@ | |
| 410 | ** --keep <CSG> keep files matching this comma separated |
| 411 | ** list of glob patterns. |
| 412 | ** -n|--dry-run If given, display instead of run actions |
| 413 | ** --temp Remove only Fossil-generated temporary files |
| 414 | ** -v|--verbose Show all files as they are removed |
| 415 | ** |
| 416 | ** See also: addremove, extra, status |
| 417 | */ |
| 418 | void clean_cmd(void){ |
| 419 | int allFlag, dryRunFlag, verboseFlag; |
| 420 | unsigned scanFlags = 0; |
| 421 | const char *zIgnoreFlag, *zKeepFlag, *zCleanFlag; |
| 422 | Blob path, repo; |
| 423 | Stmt q; |
| 424 | int n; |
| 425 | Glob *pIgnore, *pKeep, *pClean; |
| 426 | |
| 427 | dryRunFlag = find_option("dry-run","n",0)!=0; |
| 428 | if( !dryRunFlag ){ |
| 429 | dryRunFlag = find_option("test",0,0)!=0; /* deprecated */ |
| 430 | } |
| 431 | allFlag = find_option("force","f",0)!=0 || dryRunFlag; |
| 432 | if( find_option("dotfiles",0,0)!=0 ) scanFlags |= SCAN_ALL; |
| @@ -452,13 +458,12 @@ | |
| 452 | n = strlen(g.zLocalRoot); |
| 453 | blob_init(&path, g.zLocalRoot, n-1); |
| 454 | pIgnore = glob_create(zIgnoreFlag); |
| 455 | pKeep = glob_create(zKeepFlag); |
| 456 | pClean = glob_create(zCleanFlag); |
| 457 | vfile_scan2(&path, blob_size(&path), scanFlags, pIgnore, pKeep); |
| 458 | glob_free(pKeep); |
| 459 | glob_free(pIgnore); |
| 460 | db_prepare(&q, |
| 461 | "SELECT %Q || x FROM sfile" |
| 462 | " WHERE x NOT IN (%s)" |
| 463 | " ORDER BY 1", |
| 464 | g.zLocalRoot, fossil_all_reserved_names(0) |
| @@ -467,11 +472,12 @@ | |
| 467 | db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo); |
| 468 | } |
| 469 | db_multi_exec("DELETE FROM sfile WHERE x IN (SELECT pathname FROM vfile)"); |
| 470 | while( db_step(&q)==SQLITE_ROW ){ |
| 471 | const char *zName = db_column_text(&q, 0); |
| 472 | if( !allFlag && !glob_match(pClean, zName+n) ){ |
| 473 | Blob ans; |
| 474 | char cReply; |
| 475 | char *prompt = mprintf("remove unmanaged file \"%s\" (a=all/y/N)? ", |
| 476 | zName+n); |
| 477 | blob_zero(&ans); |
| @@ -488,10 +494,11 @@ | |
| 488 | } |
| 489 | if( !dryRunFlag ){ |
| 490 | file_delete(zName); |
| 491 | } |
| 492 | } |
| 493 | glob_free(pClean); |
| 494 | db_finalize(&q); |
| 495 | } |
| 496 | |
| 497 | /* |
| 498 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -236,11 +236,11 @@ | |
| 236 | int verboseFlag; |
| 237 | int showAge; |
| 238 | char *zOrderBy = "pathname"; |
| 239 | |
| 240 | verboseFlag = find_option("verbose","v", 0)!=0; |
| 241 | if( !verboseFlag ){ |
| 242 | verboseFlag = find_option("l","l", 0)!=0; /* deprecated */ |
| 243 | } |
| 244 | showAge = find_option("age",0,0)!=0; |
| 245 | db_must_be_within_tree(); |
| 246 | vid = db_lget_int("checkout", 0); |
| @@ -381,11 +381,13 @@ | |
| 381 | ** COMMAND: clean |
| 382 | ** Usage: %fossil clean ?OPTIONS? |
| 383 | ** |
| 384 | ** Delete all "extra" files in the source tree. "Extra" files are |
| 385 | ** files that are not officially part of the checkout. This operation |
| 386 | ** cannot be undone. Normally, only files unknown to fossil are |
| 387 | ** removed, but if the -x option is specified, ignored files are |
| 388 | ** removed as well. |
| 389 | ** |
| 390 | ** You will be prompted before removing each eligible file unless the |
| 391 | ** --force flag is in use or it matches the --clean option. The |
| 392 | ** GLOBPATTERN specified by the "ignore-glob" setting is used if the |
| 393 | ** --ignore option is omitted, the same with "clean-glob" and --clean |
| @@ -410,23 +412,27 @@ | |
| 412 | ** --keep <CSG> keep files matching this comma separated |
| 413 | ** list of glob patterns. |
| 414 | ** -n|--dry-run If given, display instead of run actions |
| 415 | ** --temp Remove only Fossil-generated temporary files |
| 416 | ** -v|--verbose Show all files as they are removed |
| 417 | ** -x Remove everything unkown to fossil, |
| 418 | ** including files matching --ignore. |
| 419 | ** Compatibile with "git clean -x". |
| 420 | ** |
| 421 | ** See also: addremove, extra, status |
| 422 | */ |
| 423 | void clean_cmd(void){ |
| 424 | int allFlag, dryRunFlag, verboseFlag, xFlag; |
| 425 | unsigned scanFlags = 0; |
| 426 | const char *zIgnoreFlag, *zKeepFlag, *zCleanFlag; |
| 427 | Blob path, repo; |
| 428 | Stmt q; |
| 429 | int n; |
| 430 | Glob *pIgnore, *pKeep, *pClean; |
| 431 | |
| 432 | dryRunFlag = find_option("dry-run","n",0)!=0; |
| 433 | xFlag = find_option("x","x",0)!=0; |
| 434 | if( !dryRunFlag ){ |
| 435 | dryRunFlag = find_option("test",0,0)!=0; /* deprecated */ |
| 436 | } |
| 437 | allFlag = find_option("force","f",0)!=0 || dryRunFlag; |
| 438 | if( find_option("dotfiles",0,0)!=0 ) scanFlags |= SCAN_ALL; |
| @@ -452,13 +458,12 @@ | |
| 458 | n = strlen(g.zLocalRoot); |
| 459 | blob_init(&path, g.zLocalRoot, n-1); |
| 460 | pIgnore = glob_create(zIgnoreFlag); |
| 461 | pKeep = glob_create(zKeepFlag); |
| 462 | pClean = glob_create(zCleanFlag); |
| 463 | vfile_scan2(&path, blob_size(&path), scanFlags, xFlag?0:pIgnore, pKeep); |
| 464 | glob_free(pKeep); |
| 465 | db_prepare(&q, |
| 466 | "SELECT %Q || x FROM sfile" |
| 467 | " WHERE x NOT IN (%s)" |
| 468 | " ORDER BY 1", |
| 469 | g.zLocalRoot, fossil_all_reserved_names(0) |
| @@ -467,11 +472,12 @@ | |
| 472 | db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo); |
| 473 | } |
| 474 | db_multi_exec("DELETE FROM sfile WHERE x IN (SELECT pathname FROM vfile)"); |
| 475 | while( db_step(&q)==SQLITE_ROW ){ |
| 476 | const char *zName = db_column_text(&q, 0); |
| 477 | if( !allFlag && !glob_match(pClean, zName+n) |
| 478 | && (!xFlag || !glob_match(pIgnore, zName+n))){ |
| 479 | Blob ans; |
| 480 | char cReply; |
| 481 | char *prompt = mprintf("remove unmanaged file \"%s\" (a=all/y/N)? ", |
| 482 | zName+n); |
| 483 | blob_zero(&ans); |
| @@ -488,10 +494,11 @@ | |
| 494 | } |
| 495 | if( !dryRunFlag ){ |
| 496 | file_delete(zName); |
| 497 | } |
| 498 | } |
| 499 | glob_free(pIgnore); |
| 500 | glob_free(pClean); |
| 501 | db_finalize(&q); |
| 502 | } |
| 503 | |
| 504 | /* |
| 505 |