| | @@ -381,10 +381,48 @@ |
| 381 | 381 | fossil_free(zFile); |
| 382 | 382 | } |
| 383 | 383 | return fileFound; |
| 384 | 384 | } |
| 385 | 385 | |
| 386 | +/* |
| 387 | +** Return TRUE if zFile is a temporary file. Return FALSE if not. |
| 388 | +*/ |
| 389 | +static int is_temporary_file(const char *zName){ |
| 390 | + static const char *azTemp[] = { |
| 391 | + "baseline", |
| 392 | + "merge", |
| 393 | + "original", |
| 394 | + "output", |
| 395 | + }; |
| 396 | + int i, j, n; |
| 397 | + |
| 398 | + if( strglob("ci-comment-????????????.txt", zName) ) return 1; |
| 399 | + for(; zName[0]!=0; zName++){ |
| 400 | + if( zName[0]=='/' && strglob("/ci-comment-????????????.txt", zName) ){ |
| 401 | + return 1; |
| 402 | + } |
| 403 | + if( zName[0]!='-' ) continue; |
| 404 | + for(i=0; i<sizeof(azTemp)/sizeof(azTemp[0]); i++){ |
| 405 | + n = (int)strlen(azTemp[i]); |
| 406 | + if( memcmp(azTemp[i], zName+1, n) ) continue; |
| 407 | + if( zName[n+1]==0 ) return 1; |
| 408 | + if( zName[n+1]=='-' ){ |
| 409 | + for(j=n+2; zName[j] && fossil_isdigit(zName[j]); j++){} |
| 410 | + if( zName[j]==0 ) return 1; |
| 411 | + } |
| 412 | + } |
| 413 | + } |
| 414 | + return 0; |
| 415 | +} |
| 416 | + |
| 417 | +#if INTERFACE |
| 418 | +/* |
| 419 | +** Values for the scanFlags parameter to vfile_scan(). |
| 420 | +*/ |
| 421 | +#define SCAN_ALL 0x001 /* Includes files that begin with "." */ |
| 422 | +#define SCAN_TEMP 0x002 /* Only Fossil-generated files like *-baseline */ |
| 423 | +#endif /* INTERFACE */ |
| 386 | 424 | |
| 387 | 425 | /* |
| 388 | 426 | ** Load into table SFILE the name of every ordinary file in |
| 389 | 427 | ** the directory pPath. Omit the first nPrefix characters of |
| 390 | 428 | ** of pPath when inserting into the SFILE table. |
| | @@ -396,11 +434,11 @@ |
| 396 | 434 | ** |
| 397 | 435 | ** Any files or directories that match the glob pattern pIgnore are |
| 398 | 436 | ** excluded from the scan. Name matching occurs after the first |
| 399 | 437 | ** nPrefix characters are elided from the filename. |
| 400 | 438 | */ |
| 401 | | -void vfile_scan(Blob *pPath, int nPrefix, int allFlag, Glob *pIgnore){ |
| 439 | +void vfile_scan(Blob *pPath, int nPrefix, unsigned scanFlags, Glob *pIgnore){ |
| 402 | 440 | DIR *d; |
| 403 | 441 | int origSize; |
| 404 | 442 | const char *zDir; |
| 405 | 443 | struct dirent *pEntry; |
| 406 | 444 | int skipAll = 0; |
| | @@ -430,11 +468,11 @@ |
| 430 | 468 | if( d ){ |
| 431 | 469 | while( (pEntry=readdir(d))!=0 ){ |
| 432 | 470 | char *zPath; |
| 433 | 471 | char *zUtf8; |
| 434 | 472 | if( pEntry->d_name[0]=='.' ){ |
| 435 | | - if( !allFlag ) continue; |
| 473 | + if( (scanFlags & SCAN_ALL)==0 ) continue; |
| 436 | 474 | if( pEntry->d_name[1]==0 ) continue; |
| 437 | 475 | if( pEntry->d_name[1]=='.' && pEntry->d_name[2]==0 ) continue; |
| 438 | 476 | } |
| 439 | 477 | zUtf8 = fossil_unicode_to_utf8(pEntry->d_name); |
| 440 | 478 | blob_appendf(pPath, "/%s", zUtf8); |
| | @@ -442,16 +480,18 @@ |
| 442 | 480 | zPath = blob_str(pPath); |
| 443 | 481 | if( glob_match(pIgnore, &zPath[nPrefix+1]) ){ |
| 444 | 482 | /* do nothing */ |
| 445 | 483 | }else if( file_wd_isdir(zPath)==1 ){ |
| 446 | 484 | if( !vfile_top_of_checkout(zPath) ){ |
| 447 | | - vfile_scan(pPath, nPrefix, allFlag, pIgnore); |
| 485 | + vfile_scan(pPath, nPrefix, scanFlags, pIgnore); |
| 448 | 486 | } |
| 449 | 487 | }else if( file_wd_isfile_or_link(zPath) ){ |
| 450 | | - db_bind_text(&ins, ":file", &zPath[nPrefix+1]); |
| 451 | | - db_step(&ins); |
| 452 | | - db_reset(&ins); |
| 488 | + if( (scanFlags & SCAN_TEMP)==0 || is_temporary_file(pEntry->d_name) ){ |
| 489 | + db_bind_text(&ins, ":file", &zPath[nPrefix+1]); |
| 490 | + db_step(&ins); |
| 491 | + db_reset(&ins); |
| 492 | + } |
| 453 | 493 | } |
| 454 | 494 | blob_resize(pPath, origSize); |
| 455 | 495 | } |
| 456 | 496 | closedir(d); |
| 457 | 497 | } |
| 458 | 498 | |