Fossil SCM
Get the --ignore option and ignore-glob setting working for the "clean" command. Ticket [0bc90d7235404d16].
Commit
f12a6962a77aa4c26d21a152a0b216e39f8bdc10
Parent
a9e05e23e9f085b…
1 file changed
+16
-3
+16
-3
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -262,10 +262,14 @@ | ||
| 262 | 262 | ** Print a list of all files in the source tree that are not part of |
| 263 | 263 | ** the current checkout. See also the "clean" command. |
| 264 | 264 | ** |
| 265 | 265 | ** Files and subdirectories whose names begin with "." are normally |
| 266 | 266 | ** ignored but can be included by adding the --dotfiles option. |
| 267 | +** | |
| 268 | +** The GLOBPATTERN is a comma-separated list of GLOB expressions for | |
| 269 | +** files that are ignored. The GLOBPATTERN specified by the "ignore-glob" | |
| 270 | +** is used if the --ignore option is omitted. | |
| 267 | 271 | */ |
| 268 | 272 | void extra_cmd(void){ |
| 269 | 273 | Blob path; |
| 270 | 274 | Blob repo; |
| 271 | 275 | Stmt q; |
| @@ -300,11 +304,11 @@ | ||
| 300 | 304 | db_finalize(&q); |
| 301 | 305 | } |
| 302 | 306 | |
| 303 | 307 | /* |
| 304 | 308 | ** COMMAND: clean |
| 305 | -** Usage: %fossil clean ?--force? ?--dotfiles? | |
| 309 | +** Usage: %fossil clean ?--force? ?--dotfiles? ?--ignore GLOBPATTERN? | |
| 306 | 310 | ** |
| 307 | 311 | ** Delete all "extra" files in the source tree. "Extra" files are |
| 308 | 312 | ** files that are not officially part of the checkout. See also |
| 309 | 313 | ** the "extra" command. This operation cannot be undone. |
| 310 | 314 | ** |
| @@ -313,29 +317,38 @@ | ||
| 313 | 317 | ** optional --force flag and no prompts will be issued. |
| 314 | 318 | ** |
| 315 | 319 | ** Files and subdirectories whose names begin with "." are |
| 316 | 320 | ** normally ignored. They are included if the "--dotfiles" option |
| 317 | 321 | ** is used. |
| 322 | +** | |
| 323 | +** The GLOBPATTERN is a comma-separated list of GLOB expressions for | |
| 324 | +** files that are ignored. The GLOBPATTERN specified by the "ignore-glob" | |
| 325 | +** is used if the --ignore option is omitted. | |
| 318 | 326 | */ |
| 319 | 327 | void clean_cmd(void){ |
| 320 | 328 | int allFlag; |
| 321 | 329 | int dotfilesFlag; |
| 330 | + const char *zIgnoreFlag; | |
| 322 | 331 | Blob path, repo; |
| 323 | 332 | Stmt q; |
| 324 | 333 | int n; |
| 325 | 334 | allFlag = find_option("force","f",0)!=0; |
| 326 | 335 | dotfilesFlag = find_option("dotfiles",0,0)!=0; |
| 336 | + zIgnoreFlag = find_option("ignore",0,1); | |
| 327 | 337 | db_must_be_within_tree(); |
| 338 | + if( zIgnoreFlag==0 ){ | |
| 339 | + zIgnoreFlag = db_get("ignore-glob", 0); | |
| 340 | + } | |
| 328 | 341 | db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); |
| 329 | 342 | n = strlen(g.zLocalRoot); |
| 330 | 343 | blob_init(&path, g.zLocalRoot, n-1); |
| 331 | 344 | vfile_scan(0, &path, blob_size(&path), dotfilesFlag); |
| 332 | 345 | db_prepare(&q, |
| 333 | 346 | "SELECT %Q || x FROM sfile" |
| 334 | - " WHERE x NOT IN (%s)" | |
| 347 | + " WHERE x NOT IN (%s) AND NOT %s" | |
| 335 | 348 | " ORDER BY 1", |
| 336 | - g.zLocalRoot, fossil_all_reserved_names() | |
| 349 | + g.zLocalRoot, fossil_all_reserved_names(), glob_expr("x",zIgnoreFlag) | |
| 337 | 350 | ); |
| 338 | 351 | if( file_tree_name(g.zRepositoryName, &repo, 0) ){ |
| 339 | 352 | db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo); |
| 340 | 353 | } |
| 341 | 354 | while( db_step(&q)==SQLITE_ROW ){ |
| 342 | 355 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -262,10 +262,14 @@ | |
| 262 | ** Print a list of all files in the source tree that are not part of |
| 263 | ** the current checkout. See also the "clean" command. |
| 264 | ** |
| 265 | ** Files and subdirectories whose names begin with "." are normally |
| 266 | ** ignored but can be included by adding the --dotfiles option. |
| 267 | */ |
| 268 | void extra_cmd(void){ |
| 269 | Blob path; |
| 270 | Blob repo; |
| 271 | Stmt q; |
| @@ -300,11 +304,11 @@ | |
| 300 | db_finalize(&q); |
| 301 | } |
| 302 | |
| 303 | /* |
| 304 | ** COMMAND: clean |
| 305 | ** Usage: %fossil clean ?--force? ?--dotfiles? |
| 306 | ** |
| 307 | ** Delete all "extra" files in the source tree. "Extra" files are |
| 308 | ** files that are not officially part of the checkout. See also |
| 309 | ** the "extra" command. This operation cannot be undone. |
| 310 | ** |
| @@ -313,29 +317,38 @@ | |
| 313 | ** optional --force flag and no prompts will be issued. |
| 314 | ** |
| 315 | ** Files and subdirectories whose names begin with "." are |
| 316 | ** normally ignored. They are included if the "--dotfiles" option |
| 317 | ** is used. |
| 318 | */ |
| 319 | void clean_cmd(void){ |
| 320 | int allFlag; |
| 321 | int dotfilesFlag; |
| 322 | Blob path, repo; |
| 323 | Stmt q; |
| 324 | int n; |
| 325 | allFlag = find_option("force","f",0)!=0; |
| 326 | dotfilesFlag = find_option("dotfiles",0,0)!=0; |
| 327 | db_must_be_within_tree(); |
| 328 | db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); |
| 329 | n = strlen(g.zLocalRoot); |
| 330 | blob_init(&path, g.zLocalRoot, n-1); |
| 331 | vfile_scan(0, &path, blob_size(&path), dotfilesFlag); |
| 332 | db_prepare(&q, |
| 333 | "SELECT %Q || x FROM sfile" |
| 334 | " WHERE x NOT IN (%s)" |
| 335 | " ORDER BY 1", |
| 336 | g.zLocalRoot, fossil_all_reserved_names() |
| 337 | ); |
| 338 | if( file_tree_name(g.zRepositoryName, &repo, 0) ){ |
| 339 | db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo); |
| 340 | } |
| 341 | while( db_step(&q)==SQLITE_ROW ){ |
| 342 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -262,10 +262,14 @@ | |
| 262 | ** Print a list of all files in the source tree that are not part of |
| 263 | ** the current checkout. See also the "clean" command. |
| 264 | ** |
| 265 | ** Files and subdirectories whose names begin with "." are normally |
| 266 | ** ignored but can be included by adding the --dotfiles option. |
| 267 | ** |
| 268 | ** The GLOBPATTERN is a comma-separated list of GLOB expressions for |
| 269 | ** files that are ignored. The GLOBPATTERN specified by the "ignore-glob" |
| 270 | ** is used if the --ignore option is omitted. |
| 271 | */ |
| 272 | void extra_cmd(void){ |
| 273 | Blob path; |
| 274 | Blob repo; |
| 275 | Stmt q; |
| @@ -300,11 +304,11 @@ | |
| 304 | db_finalize(&q); |
| 305 | } |
| 306 | |
| 307 | /* |
| 308 | ** COMMAND: clean |
| 309 | ** Usage: %fossil clean ?--force? ?--dotfiles? ?--ignore GLOBPATTERN? |
| 310 | ** |
| 311 | ** Delete all "extra" files in the source tree. "Extra" files are |
| 312 | ** files that are not officially part of the checkout. See also |
| 313 | ** the "extra" command. This operation cannot be undone. |
| 314 | ** |
| @@ -313,29 +317,38 @@ | |
| 317 | ** optional --force flag and no prompts will be issued. |
| 318 | ** |
| 319 | ** Files and subdirectories whose names begin with "." are |
| 320 | ** normally ignored. They are included if the "--dotfiles" option |
| 321 | ** is used. |
| 322 | ** |
| 323 | ** The GLOBPATTERN is a comma-separated list of GLOB expressions for |
| 324 | ** files that are ignored. The GLOBPATTERN specified by the "ignore-glob" |
| 325 | ** is used if the --ignore option is omitted. |
| 326 | */ |
| 327 | void clean_cmd(void){ |
| 328 | int allFlag; |
| 329 | int dotfilesFlag; |
| 330 | const char *zIgnoreFlag; |
| 331 | Blob path, repo; |
| 332 | Stmt q; |
| 333 | int n; |
| 334 | allFlag = find_option("force","f",0)!=0; |
| 335 | dotfilesFlag = find_option("dotfiles",0,0)!=0; |
| 336 | zIgnoreFlag = find_option("ignore",0,1); |
| 337 | db_must_be_within_tree(); |
| 338 | if( zIgnoreFlag==0 ){ |
| 339 | zIgnoreFlag = db_get("ignore-glob", 0); |
| 340 | } |
| 341 | db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); |
| 342 | n = strlen(g.zLocalRoot); |
| 343 | blob_init(&path, g.zLocalRoot, n-1); |
| 344 | vfile_scan(0, &path, blob_size(&path), dotfilesFlag); |
| 345 | db_prepare(&q, |
| 346 | "SELECT %Q || x FROM sfile" |
| 347 | " WHERE x NOT IN (%s) AND NOT %s" |
| 348 | " ORDER BY 1", |
| 349 | g.zLocalRoot, fossil_all_reserved_names(), glob_expr("x",zIgnoreFlag) |
| 350 | ); |
| 351 | if( file_tree_name(g.zRepositoryName, &repo, 0) ){ |
| 352 | db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo); |
| 353 | } |
| 354 | while( db_step(&q)==SQLITE_ROW ){ |
| 355 |