Fossil SCM
When doing "fossil add foo.*" but the user forgets there is a foo.o besides the foo.c and foo.h, and "ignore-glob" contains the "*.o" pattern, fossil will properly warn for this situation and ask what to do. (for Fossil itself this is no issue, as the *.o files are kept in a separate directory, but not all projects do that). Example: /Localdata/workspace/tcl8.6/unix $ touch foo.c foo.h foo.o /Localdata/workspace/tcl8.6/unix $ fossil add foo.* file "foo.o" matches "ignore-glob". Add it (a=all/y/N)? n ADDED foo.c ADDED foo.h
Commit
6ec21b58a2c28e9f939b10d2768fe4164eeda854
Parent
328be9da5761d1c…
2 files changed
+23
+23
+23
| --- src/add.c | ||
| +++ src/add.c | ||
| @@ -221,19 +221,24 @@ | ||
| 221 | 221 | ** The --ignore and --clean options are comma-separate lists of glob patterns |
| 222 | 222 | ** for files to be excluded. Example: '*.o,*.obj,*.exe' If the --ignore |
| 223 | 223 | ** option does not appear on the command line then the "ignore-glob" setting |
| 224 | 224 | ** is used. If the --clean option does not appear on the command line then |
| 225 | 225 | ** the "clean-glob" setting is used. |
| 226 | +** | |
| 227 | +** If files are attempted to be added explicitly on the command line which | |
| 228 | +** match "ignore-glob", a confirmation is asked first. This can be prevented | |
| 229 | +** using the -f|--force option. | |
| 226 | 230 | ** |
| 227 | 231 | ** The --case-sensitive option determines whether or not filenames should |
| 228 | 232 | ** be treated case sensitive or not. If the option is not given, the default |
| 229 | 233 | ** depends on the global setting, or the operating system default, if not set. |
| 230 | 234 | ** |
| 231 | 235 | ** Options: |
| 232 | 236 | ** |
| 233 | 237 | ** --case-sensitive <BOOL> override case-sensitive setting |
| 234 | 238 | ** --dotfiles include files beginning with a dot (".") |
| 239 | +** -f|--force Add files without prompting | |
| 235 | 240 | ** --ignore <CSG> ignore files matching patterns from the |
| 236 | 241 | ** comma separated list of glob patterns. |
| 237 | 242 | ** --clean <CSG> also ignore files matching patterns from |
| 238 | 243 | ** the comma separated list of glob patterns. |
| 239 | 244 | ** |
| @@ -245,13 +250,15 @@ | ||
| 245 | 250 | int nRoot; /* Full path characters in g.zLocalRoot */ |
| 246 | 251 | const char *zCleanFlag; /* The --clean option or clean-glob setting */ |
| 247 | 252 | const char *zIgnoreFlag; /* The --ignore option or ignore-glob setting */ |
| 248 | 253 | Glob *pIgnore, *pClean; /* Ignore everything matching the glob patterns */ |
| 249 | 254 | unsigned scanFlags = 0; /* Flags passed to vfile_scan() */ |
| 255 | + int forceFlag; | |
| 250 | 256 | |
| 251 | 257 | zCleanFlag = find_option("clean",0,1); |
| 252 | 258 | zIgnoreFlag = find_option("ignore",0,1); |
| 259 | + forceFlag = find_option("force","f",0)!=0; | |
| 253 | 260 | if( find_option("dotfiles",0,0)!=0 ) scanFlags |= SCAN_ALL; |
| 254 | 261 | capture_case_sensitive_option(); |
| 255 | 262 | db_must_be_within_tree(); |
| 256 | 263 | if( zCleanFlag==0 ){ |
| 257 | 264 | zCleanFlag = db_get("clean-glob", 0); |
| @@ -287,10 +294,26 @@ | ||
| 287 | 294 | fossil_warning("not found: %s", zName); |
| 288 | 295 | }else if( file_access(zName, R_OK) ){ |
| 289 | 296 | fossil_fatal("cannot open %s", zName); |
| 290 | 297 | }else{ |
| 291 | 298 | char *zTreeName = &zName[nRoot]; |
| 299 | + if( !forceFlag && glob_match(pIgnore, zTreeName) ){ | |
| 300 | + Blob ans; | |
| 301 | + char cReply; | |
| 302 | + char *prompt = mprintf("file \"%s\" matches \"ignore-glob\". " | |
| 303 | + "Add it (a=all/y/N)? ", zTreeName); | |
| 304 | + blob_zero(&ans); | |
| 305 | + prompt_user(prompt, &ans); | |
| 306 | + cReply = blob_str(&ans)[0]; | |
| 307 | + blob_reset(&ans); | |
| 308 | + if( cReply=='a' || cReply=='A' ){ | |
| 309 | + forceFlag = 1; | |
| 310 | + }else if( cReply!='y' && cReply!='Y' ){ | |
| 311 | + blob_reset(&fullName); | |
| 312 | + continue; | |
| 313 | + } | |
| 314 | + } | |
| 292 | 315 | db_multi_exec( |
| 293 | 316 | "INSERT OR IGNORE INTO sfile(x) VALUES(%Q)", |
| 294 | 317 | zTreeName |
| 295 | 318 | ); |
| 296 | 319 | } |
| 297 | 320 |
| --- src/add.c | |
| +++ src/add.c | |
| @@ -221,19 +221,24 @@ | |
| 221 | ** The --ignore and --clean options are comma-separate lists of glob patterns |
| 222 | ** for files to be excluded. Example: '*.o,*.obj,*.exe' If the --ignore |
| 223 | ** option does not appear on the command line then the "ignore-glob" setting |
| 224 | ** is used. If the --clean option does not appear on the command line then |
| 225 | ** the "clean-glob" setting is used. |
| 226 | ** |
| 227 | ** The --case-sensitive option determines whether or not filenames should |
| 228 | ** be treated case sensitive or not. If the option is not given, the default |
| 229 | ** depends on the global setting, or the operating system default, if not set. |
| 230 | ** |
| 231 | ** Options: |
| 232 | ** |
| 233 | ** --case-sensitive <BOOL> override case-sensitive setting |
| 234 | ** --dotfiles include files beginning with a dot (".") |
| 235 | ** --ignore <CSG> ignore files matching patterns from the |
| 236 | ** comma separated list of glob patterns. |
| 237 | ** --clean <CSG> also ignore files matching patterns from |
| 238 | ** the comma separated list of glob patterns. |
| 239 | ** |
| @@ -245,13 +250,15 @@ | |
| 245 | int nRoot; /* Full path characters in g.zLocalRoot */ |
| 246 | const char *zCleanFlag; /* The --clean option or clean-glob setting */ |
| 247 | const char *zIgnoreFlag; /* The --ignore option or ignore-glob setting */ |
| 248 | Glob *pIgnore, *pClean; /* Ignore everything matching the glob patterns */ |
| 249 | unsigned scanFlags = 0; /* Flags passed to vfile_scan() */ |
| 250 | |
| 251 | zCleanFlag = find_option("clean",0,1); |
| 252 | zIgnoreFlag = find_option("ignore",0,1); |
| 253 | if( find_option("dotfiles",0,0)!=0 ) scanFlags |= SCAN_ALL; |
| 254 | capture_case_sensitive_option(); |
| 255 | db_must_be_within_tree(); |
| 256 | if( zCleanFlag==0 ){ |
| 257 | zCleanFlag = db_get("clean-glob", 0); |
| @@ -287,10 +294,26 @@ | |
| 287 | fossil_warning("not found: %s", zName); |
| 288 | }else if( file_access(zName, R_OK) ){ |
| 289 | fossil_fatal("cannot open %s", zName); |
| 290 | }else{ |
| 291 | char *zTreeName = &zName[nRoot]; |
| 292 | db_multi_exec( |
| 293 | "INSERT OR IGNORE INTO sfile(x) VALUES(%Q)", |
| 294 | zTreeName |
| 295 | ); |
| 296 | } |
| 297 |
| --- src/add.c | |
| +++ src/add.c | |
| @@ -221,19 +221,24 @@ | |
| 221 | ** The --ignore and --clean options are comma-separate lists of glob patterns |
| 222 | ** for files to be excluded. Example: '*.o,*.obj,*.exe' If the --ignore |
| 223 | ** option does not appear on the command line then the "ignore-glob" setting |
| 224 | ** is used. If the --clean option does not appear on the command line then |
| 225 | ** the "clean-glob" setting is used. |
| 226 | ** |
| 227 | ** If files are attempted to be added explicitly on the command line which |
| 228 | ** match "ignore-glob", a confirmation is asked first. This can be prevented |
| 229 | ** using the -f|--force option. |
| 230 | ** |
| 231 | ** The --case-sensitive option determines whether or not filenames should |
| 232 | ** be treated case sensitive or not. If the option is not given, the default |
| 233 | ** depends on the global setting, or the operating system default, if not set. |
| 234 | ** |
| 235 | ** Options: |
| 236 | ** |
| 237 | ** --case-sensitive <BOOL> override case-sensitive setting |
| 238 | ** --dotfiles include files beginning with a dot (".") |
| 239 | ** -f|--force Add files without prompting |
| 240 | ** --ignore <CSG> ignore files matching patterns from the |
| 241 | ** comma separated list of glob patterns. |
| 242 | ** --clean <CSG> also ignore files matching patterns from |
| 243 | ** the comma separated list of glob patterns. |
| 244 | ** |
| @@ -245,13 +250,15 @@ | |
| 250 | int nRoot; /* Full path characters in g.zLocalRoot */ |
| 251 | const char *zCleanFlag; /* The --clean option or clean-glob setting */ |
| 252 | const char *zIgnoreFlag; /* The --ignore option or ignore-glob setting */ |
| 253 | Glob *pIgnore, *pClean; /* Ignore everything matching the glob patterns */ |
| 254 | unsigned scanFlags = 0; /* Flags passed to vfile_scan() */ |
| 255 | int forceFlag; |
| 256 | |
| 257 | zCleanFlag = find_option("clean",0,1); |
| 258 | zIgnoreFlag = find_option("ignore",0,1); |
| 259 | forceFlag = find_option("force","f",0)!=0; |
| 260 | if( find_option("dotfiles",0,0)!=0 ) scanFlags |= SCAN_ALL; |
| 261 | capture_case_sensitive_option(); |
| 262 | db_must_be_within_tree(); |
| 263 | if( zCleanFlag==0 ){ |
| 264 | zCleanFlag = db_get("clean-glob", 0); |
| @@ -287,10 +294,26 @@ | |
| 294 | fossil_warning("not found: %s", zName); |
| 295 | }else if( file_access(zName, R_OK) ){ |
| 296 | fossil_fatal("cannot open %s", zName); |
| 297 | }else{ |
| 298 | char *zTreeName = &zName[nRoot]; |
| 299 | if( !forceFlag && glob_match(pIgnore, zTreeName) ){ |
| 300 | Blob ans; |
| 301 | char cReply; |
| 302 | char *prompt = mprintf("file \"%s\" matches \"ignore-glob\". " |
| 303 | "Add it (a=all/y/N)? ", zTreeName); |
| 304 | blob_zero(&ans); |
| 305 | prompt_user(prompt, &ans); |
| 306 | cReply = blob_str(&ans)[0]; |
| 307 | blob_reset(&ans); |
| 308 | if( cReply=='a' || cReply=='A' ){ |
| 309 | forceFlag = 1; |
| 310 | }else if( cReply!='y' && cReply!='Y' ){ |
| 311 | blob_reset(&fullName); |
| 312 | continue; |
| 313 | } |
| 314 | } |
| 315 | db_multi_exec( |
| 316 | "INSERT OR IGNORE INTO sfile(x) VALUES(%Q)", |
| 317 | zTreeName |
| 318 | ); |
| 319 | } |
| 320 |
+23
| --- src/add.c | ||
| +++ src/add.c | ||
| @@ -221,19 +221,24 @@ | ||
| 221 | 221 | ** The --ignore and --clean options are comma-separate lists of glob patterns |
| 222 | 222 | ** for files to be excluded. Example: '*.o,*.obj,*.exe' If the --ignore |
| 223 | 223 | ** option does not appear on the command line then the "ignore-glob" setting |
| 224 | 224 | ** is used. If the --clean option does not appear on the command line then |
| 225 | 225 | ** the "clean-glob" setting is used. |
| 226 | +** | |
| 227 | +** If files are attempted to be added explicitly on the command line which | |
| 228 | +** match "ignore-glob", a confirmation is asked first. This can be prevented | |
| 229 | +** using the -f|--force option. | |
| 226 | 230 | ** |
| 227 | 231 | ** The --case-sensitive option determines whether or not filenames should |
| 228 | 232 | ** be treated case sensitive or not. If the option is not given, the default |
| 229 | 233 | ** depends on the global setting, or the operating system default, if not set. |
| 230 | 234 | ** |
| 231 | 235 | ** Options: |
| 232 | 236 | ** |
| 233 | 237 | ** --case-sensitive <BOOL> override case-sensitive setting |
| 234 | 238 | ** --dotfiles include files beginning with a dot (".") |
| 239 | +** -f|--force Add files without prompting | |
| 235 | 240 | ** --ignore <CSG> ignore files matching patterns from the |
| 236 | 241 | ** comma separated list of glob patterns. |
| 237 | 242 | ** --clean <CSG> also ignore files matching patterns from |
| 238 | 243 | ** the comma separated list of glob patterns. |
| 239 | 244 | ** |
| @@ -245,13 +250,15 @@ | ||
| 245 | 250 | int nRoot; /* Full path characters in g.zLocalRoot */ |
| 246 | 251 | const char *zCleanFlag; /* The --clean option or clean-glob setting */ |
| 247 | 252 | const char *zIgnoreFlag; /* The --ignore option or ignore-glob setting */ |
| 248 | 253 | Glob *pIgnore, *pClean; /* Ignore everything matching the glob patterns */ |
| 249 | 254 | unsigned scanFlags = 0; /* Flags passed to vfile_scan() */ |
| 255 | + int forceFlag; | |
| 250 | 256 | |
| 251 | 257 | zCleanFlag = find_option("clean",0,1); |
| 252 | 258 | zIgnoreFlag = find_option("ignore",0,1); |
| 259 | + forceFlag = find_option("force","f",0)!=0; | |
| 253 | 260 | if( find_option("dotfiles",0,0)!=0 ) scanFlags |= SCAN_ALL; |
| 254 | 261 | capture_case_sensitive_option(); |
| 255 | 262 | db_must_be_within_tree(); |
| 256 | 263 | if( zCleanFlag==0 ){ |
| 257 | 264 | zCleanFlag = db_get("clean-glob", 0); |
| @@ -287,10 +294,26 @@ | ||
| 287 | 294 | fossil_warning("not found: %s", zName); |
| 288 | 295 | }else if( file_access(zName, R_OK) ){ |
| 289 | 296 | fossil_fatal("cannot open %s", zName); |
| 290 | 297 | }else{ |
| 291 | 298 | char *zTreeName = &zName[nRoot]; |
| 299 | + if( !forceFlag && glob_match(pIgnore, zTreeName) ){ | |
| 300 | + Blob ans; | |
| 301 | + char cReply; | |
| 302 | + char *prompt = mprintf("file \"%s\" matches \"ignore-glob\". " | |
| 303 | + "Add it (a=all/y/N)? ", zTreeName); | |
| 304 | + blob_zero(&ans); | |
| 305 | + prompt_user(prompt, &ans); | |
| 306 | + cReply = blob_str(&ans)[0]; | |
| 307 | + blob_reset(&ans); | |
| 308 | + if( cReply=='a' || cReply=='A' ){ | |
| 309 | + forceFlag = 1; | |
| 310 | + }else if( cReply!='y' && cReply!='Y' ){ | |
| 311 | + blob_reset(&fullName); | |
| 312 | + continue; | |
| 313 | + } | |
| 314 | + } | |
| 292 | 315 | db_multi_exec( |
| 293 | 316 | "INSERT OR IGNORE INTO sfile(x) VALUES(%Q)", |
| 294 | 317 | zTreeName |
| 295 | 318 | ); |
| 296 | 319 | } |
| 297 | 320 |
| --- src/add.c | |
| +++ src/add.c | |
| @@ -221,19 +221,24 @@ | |
| 221 | ** The --ignore and --clean options are comma-separate lists of glob patterns |
| 222 | ** for files to be excluded. Example: '*.o,*.obj,*.exe' If the --ignore |
| 223 | ** option does not appear on the command line then the "ignore-glob" setting |
| 224 | ** is used. If the --clean option does not appear on the command line then |
| 225 | ** the "clean-glob" setting is used. |
| 226 | ** |
| 227 | ** The --case-sensitive option determines whether or not filenames should |
| 228 | ** be treated case sensitive or not. If the option is not given, the default |
| 229 | ** depends on the global setting, or the operating system default, if not set. |
| 230 | ** |
| 231 | ** Options: |
| 232 | ** |
| 233 | ** --case-sensitive <BOOL> override case-sensitive setting |
| 234 | ** --dotfiles include files beginning with a dot (".") |
| 235 | ** --ignore <CSG> ignore files matching patterns from the |
| 236 | ** comma separated list of glob patterns. |
| 237 | ** --clean <CSG> also ignore files matching patterns from |
| 238 | ** the comma separated list of glob patterns. |
| 239 | ** |
| @@ -245,13 +250,15 @@ | |
| 245 | int nRoot; /* Full path characters in g.zLocalRoot */ |
| 246 | const char *zCleanFlag; /* The --clean option or clean-glob setting */ |
| 247 | const char *zIgnoreFlag; /* The --ignore option or ignore-glob setting */ |
| 248 | Glob *pIgnore, *pClean; /* Ignore everything matching the glob patterns */ |
| 249 | unsigned scanFlags = 0; /* Flags passed to vfile_scan() */ |
| 250 | |
| 251 | zCleanFlag = find_option("clean",0,1); |
| 252 | zIgnoreFlag = find_option("ignore",0,1); |
| 253 | if( find_option("dotfiles",0,0)!=0 ) scanFlags |= SCAN_ALL; |
| 254 | capture_case_sensitive_option(); |
| 255 | db_must_be_within_tree(); |
| 256 | if( zCleanFlag==0 ){ |
| 257 | zCleanFlag = db_get("clean-glob", 0); |
| @@ -287,10 +294,26 @@ | |
| 287 | fossil_warning("not found: %s", zName); |
| 288 | }else if( file_access(zName, R_OK) ){ |
| 289 | fossil_fatal("cannot open %s", zName); |
| 290 | }else{ |
| 291 | char *zTreeName = &zName[nRoot]; |
| 292 | db_multi_exec( |
| 293 | "INSERT OR IGNORE INTO sfile(x) VALUES(%Q)", |
| 294 | zTreeName |
| 295 | ); |
| 296 | } |
| 297 |
| --- src/add.c | |
| +++ src/add.c | |
| @@ -221,19 +221,24 @@ | |
| 221 | ** The --ignore and --clean options are comma-separate lists of glob patterns |
| 222 | ** for files to be excluded. Example: '*.o,*.obj,*.exe' If the --ignore |
| 223 | ** option does not appear on the command line then the "ignore-glob" setting |
| 224 | ** is used. If the --clean option does not appear on the command line then |
| 225 | ** the "clean-glob" setting is used. |
| 226 | ** |
| 227 | ** If files are attempted to be added explicitly on the command line which |
| 228 | ** match "ignore-glob", a confirmation is asked first. This can be prevented |
| 229 | ** using the -f|--force option. |
| 230 | ** |
| 231 | ** The --case-sensitive option determines whether or not filenames should |
| 232 | ** be treated case sensitive or not. If the option is not given, the default |
| 233 | ** depends on the global setting, or the operating system default, if not set. |
| 234 | ** |
| 235 | ** Options: |
| 236 | ** |
| 237 | ** --case-sensitive <BOOL> override case-sensitive setting |
| 238 | ** --dotfiles include files beginning with a dot (".") |
| 239 | ** -f|--force Add files without prompting |
| 240 | ** --ignore <CSG> ignore files matching patterns from the |
| 241 | ** comma separated list of glob patterns. |
| 242 | ** --clean <CSG> also ignore files matching patterns from |
| 243 | ** the comma separated list of glob patterns. |
| 244 | ** |
| @@ -245,13 +250,15 @@ | |
| 250 | int nRoot; /* Full path characters in g.zLocalRoot */ |
| 251 | const char *zCleanFlag; /* The --clean option or clean-glob setting */ |
| 252 | const char *zIgnoreFlag; /* The --ignore option or ignore-glob setting */ |
| 253 | Glob *pIgnore, *pClean; /* Ignore everything matching the glob patterns */ |
| 254 | unsigned scanFlags = 0; /* Flags passed to vfile_scan() */ |
| 255 | int forceFlag; |
| 256 | |
| 257 | zCleanFlag = find_option("clean",0,1); |
| 258 | zIgnoreFlag = find_option("ignore",0,1); |
| 259 | forceFlag = find_option("force","f",0)!=0; |
| 260 | if( find_option("dotfiles",0,0)!=0 ) scanFlags |= SCAN_ALL; |
| 261 | capture_case_sensitive_option(); |
| 262 | db_must_be_within_tree(); |
| 263 | if( zCleanFlag==0 ){ |
| 264 | zCleanFlag = db_get("clean-glob", 0); |
| @@ -287,10 +294,26 @@ | |
| 294 | fossil_warning("not found: %s", zName); |
| 295 | }else if( file_access(zName, R_OK) ){ |
| 296 | fossil_fatal("cannot open %s", zName); |
| 297 | }else{ |
| 298 | char *zTreeName = &zName[nRoot]; |
| 299 | if( !forceFlag && glob_match(pIgnore, zTreeName) ){ |
| 300 | Blob ans; |
| 301 | char cReply; |
| 302 | char *prompt = mprintf("file \"%s\" matches \"ignore-glob\". " |
| 303 | "Add it (a=all/y/N)? ", zTreeName); |
| 304 | blob_zero(&ans); |
| 305 | prompt_user(prompt, &ans); |
| 306 | cReply = blob_str(&ans)[0]; |
| 307 | blob_reset(&ans); |
| 308 | if( cReply=='a' || cReply=='A' ){ |
| 309 | forceFlag = 1; |
| 310 | }else if( cReply!='y' && cReply!='Y' ){ |
| 311 | blob_reset(&fullName); |
| 312 | continue; |
| 313 | } |
| 314 | } |
| 315 | db_multi_exec( |
| 316 | "INSERT OR IGNORE INTO sfile(x) VALUES(%Q)", |
| 317 | zTreeName |
| 318 | ); |
| 319 | } |
| 320 |