Fossil

Changes On Branch prevent-adding-ignored-files
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Changes In Branch prevent-adding-ignored-files Excluding Merge-Ins

This is equivalent to a diff from 0681b39b82 to 78862afd3c

2014-02-20
08:51
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 check-in: 6ec21b58a2 user: jan.nijtmans tags: trunk
2014-02-11
04:53
Update the built-in SQLite to the version 3.8.3.1 release candidate. check-in: 34aef781b5 user: drh tags: trunk
04:36
Used the wrong sqlite3.c source file. Was: Update the built-in SQLite to the 3.8.3.1 release candidate. This is moving backwards, slightly. But it is important for testing SQLite. Closed-Leaf check-in: 2324f4754f user: drh tags: mistake
2014-02-09
17:14
merge trunk Closed-Leaf check-in: 78862afd3c user: jan.nijtmans tags: prevent-adding-ignored-files
2014-02-08
08:54
Fix harmless compiler warning check-in: 0681b39b82 user: jan.nijtmans tags: trunk
2014-02-07
15:52
fossil server: Output "Listening...port [p]" message when iPort==mnPort. check-in: 70218670ff user: joel tags: trunk
2013-06-19
07:06
rebase check-in: f836a1cdca user: jan.nijtmans tags: prevent-adding-ignored-files

Changes to src/add.c.
219
220
221
222
223
224
225




226
227
228
229
230
231
232
233
234

235
236
237
238
239
240
241
242
243
244
245
246
247
248
249

250
251
252

253
254
255
256
257
258
259
** the "--dotfiles" option to the command-line.
**
** The --ignore and --clean options are comma-separate lists of glob patterns
** for files to be excluded.  Example:  '*.o,*.obj,*.exe'  If the --ignore
** option does not appear on the command line then the "ignore-glob" setting
** is used.  If the --clean option does not appear on the command line then
** the "clean-glob" setting is used.




**
** The --case-sensitive option determines whether or not filenames should
** be treated case sensitive or not. If the option is not given, the default
** depends on the global setting, or the operating system default, if not set.
**
** Options:
**
**    --case-sensitive <BOOL> override case-sensitive setting
**    --dotfiles              include files beginning with a dot (".")   

**    --ignore <CSG>          ignore files matching patterns from the 
**                            comma separated list of glob patterns.
**    --clean <CSG>           also ignore files matching patterns from
**                            the comma separated list of glob patterns.
** 
** See also: addremove, rm
*/
void add_cmd(void){
  int i;                     /* Loop counter */
  int vid;                   /* Currently checked out version */
  int nRoot;                 /* Full path characters in g.zLocalRoot */
  const char *zCleanFlag;    /* The --clean option or clean-glob setting */
  const char *zIgnoreFlag;   /* The --ignore option or ignore-glob setting */
  Glob *pIgnore, *pClean;    /* Ignore everything matching the glob patterns */
  unsigned scanFlags = 0;    /* Flags passed to vfile_scan() */


  zCleanFlag = find_option("clean",0,1);
  zIgnoreFlag = find_option("ignore",0,1);

  if( find_option("dotfiles",0,0)!=0 ) scanFlags |= SCAN_ALL;
  capture_case_sensitive_option();
  db_must_be_within_tree();
  if( zCleanFlag==0 ){
    zCleanFlag = db_get("clean-glob", 0);
  }
  if( zIgnoreFlag==0 ){







>
>
>
>









>















>



>







219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
** the "--dotfiles" option to the command-line.
**
** The --ignore and --clean options are comma-separate lists of glob patterns
** for files to be excluded.  Example:  '*.o,*.obj,*.exe'  If the --ignore
** option does not appear on the command line then the "ignore-glob" setting
** is used.  If the --clean option does not appear on the command line then
** the "clean-glob" setting is used.
**
** If files are attempted to be added explicitly on the command line which
** match either --ignore or --clean, a confirmation is asked first. This
** can be prevented using -f|--force.
**
** The --case-sensitive option determines whether or not filenames should
** be treated case sensitive or not. If the option is not given, the default
** depends on the global setting, or the operating system default, if not set.
**
** Options:
**
**    --case-sensitive <BOOL> override case-sensitive setting
**    --dotfiles              include files beginning with a dot (".")   
**    -f|--force              Add files without prompting
**    --ignore <CSG>          ignore files matching patterns from the 
**                            comma separated list of glob patterns.
**    --clean <CSG>           also ignore files matching patterns from
**                            the comma separated list of glob patterns.
** 
** See also: addremove, rm
*/
void add_cmd(void){
  int i;                     /* Loop counter */
  int vid;                   /* Currently checked out version */
  int nRoot;                 /* Full path characters in g.zLocalRoot */
  const char *zCleanFlag;    /* The --clean option or clean-glob setting */
  const char *zIgnoreFlag;   /* The --ignore option or ignore-glob setting */
  Glob *pIgnore, *pClean;    /* Ignore everything matching the glob patterns */
  unsigned scanFlags = 0;    /* Flags passed to vfile_scan() */
  int forceFlag;

  zCleanFlag = find_option("clean",0,1);
  zIgnoreFlag = find_option("ignore",0,1);
  forceFlag = find_option("force","f",0)!=0;
  if( find_option("dotfiles",0,0)!=0 ) scanFlags |= SCAN_ALL;
  capture_case_sensitive_option();
  db_must_be_within_tree();
  if( zCleanFlag==0 ){
    zCleanFlag = db_get("clean-glob", 0);
  }
  if( zIgnoreFlag==0 ){
285
286
287
288
289
290
291


















292
293
294
295
296
297
298
      vfile_scan(&fullName, nRoot-1, scanFlags, pClean, pIgnore);
    }else if( isDir==0 ){
      fossil_warning("not found: %s", zName);
    }else if( file_access(zName, R_OK) ){
      fossil_fatal("cannot open %s", zName);
    }else{
      char *zTreeName = &zName[nRoot];


















      db_multi_exec(
         "INSERT OR IGNORE INTO sfile(x) VALUES(%Q)",
         zTreeName
      );
    }
    blob_reset(&fullName);
  }







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
      vfile_scan(&fullName, nRoot-1, scanFlags, pClean, pIgnore);
    }else if( isDir==0 ){
      fossil_warning("not found: %s", zName);
    }else if( file_access(zName, R_OK) ){
      fossil_fatal("cannot open %s", zName);
    }else{
      char *zTreeName = &zName[nRoot];
      if( !forceFlag ){
        if( glob_match(pIgnore, zTreeName)||glob_match(pClean, zTreeName) ){
          Blob ans;
          char cReply;
          char *prompt = mprintf("file \"%s\" should be ignored.  "
                                 "Add it (a=all/y/N)? ", zTreeName);
          blob_zero(&ans);
          prompt_user(prompt, &ans);
          cReply = blob_str(&ans)[0];
          blob_reset(&ans);
          if( cReply=='a' || cReply=='A' ){
            forceFlag = 1;
          }else if( cReply!='y' && cReply!='Y' ){
            blob_reset(&fullName);
            continue;
          }
        }
      }
      db_multi_exec(
         "INSERT OR IGNORE INTO sfile(x) VALUES(%Q)",
         zTreeName
      );
    }
    blob_reset(&fullName);
  }