| | @@ -399,11 +399,11 @@ |
| 399 | 399 | const char *zFile2, /* On disk content to compare to */ |
| 400 | 400 | const char *zName, /* Display name of the file */ |
| 401 | 401 | const char *zDiffCmd, /* Command for comparison */ |
| 402 | 402 | const char *zBinGlob, /* Treat file names matching this as binary */ |
| 403 | 403 | int fIncludeBinary, /* Include binary files for external diff */ |
| 404 | | - u64 diffFlags, /* Flags to control the diff */ |
| 404 | + DiffConfig *pCfg, /* Flags to control the diff */ |
| 405 | 405 | int fSwapDiff, /* Diff from Zfile2 to Pfile1 */ |
| 406 | 406 | Blob *diffBlob /* Blob to store diff output */ |
| 407 | 407 | ){ |
| 408 | 408 | if( zDiffCmd==0 ){ |
| 409 | 409 | Blob out; /* Diff output text */ |
| | @@ -418,36 +418,34 @@ |
| 418 | 418 | blob_read_from_file(&file2, zFile2, ExtFILE); |
| 419 | 419 | zName2 = zName; |
| 420 | 420 | } |
| 421 | 421 | |
| 422 | 422 | /* Compute and output the differences */ |
| 423 | | - if( diffFlags & DIFF_BRIEF ){ |
| 423 | + if( pCfg->diffFlags & DIFF_BRIEF ){ |
| 424 | 424 | if( blob_compare(pFile1, &file2) ){ |
| 425 | 425 | fossil_print("CHANGED %s\n", zName); |
| 426 | 426 | } |
| 427 | 427 | }else{ |
| 428 | | - DiffConfig DCfg; |
| 429 | | - diff_config_init(&DCfg, diffFlags); |
| 430 | 428 | blob_zero(&out); |
| 431 | 429 | if( fSwapDiff ){ |
| 432 | | - text_diff(&file2, pFile1, &out, 0, &DCfg); |
| 430 | + text_diff(&file2, pFile1, &out, 0, pCfg); |
| 433 | 431 | }else{ |
| 434 | | - text_diff(pFile1, &file2, &out, 0, &DCfg); |
| 432 | + text_diff(pFile1, &file2, &out, 0, pCfg); |
| 435 | 433 | } |
| 436 | 434 | if( blob_size(&out) ){ |
| 437 | | - if( diffFlags & DIFF_NUMSTAT ){ |
| 435 | + if( pCfg->diffFlags & DIFF_NUMSTAT ){ |
| 438 | 436 | if( !diffBlob ){ |
| 439 | 437 | fossil_print("%s %s\n", blob_str(&out), zName); |
| 440 | 438 | }else{ |
| 441 | 439 | blob_appendf(diffBlob, "%s %s\n", blob_str(&out), zName); |
| 442 | 440 | } |
| 443 | 441 | }else{ |
| 444 | 442 | if( !diffBlob ){ |
| 445 | | - diff_print_filenames(zName, zName2, diffFlags, 0); |
| 443 | + diff_print_filenames(zName, zName2, pCfg->diffFlags, 0); |
| 446 | 444 | fossil_print("%s\n", blob_str(&out)); |
| 447 | 445 | }else{ |
| 448 | | - diff_print_filenames(zName, zName2, diffFlags, diffBlob); |
| 446 | + diff_print_filenames(zName, zName2, pCfg->diffFlags, diffBlob); |
| 449 | 447 | blob_appendf(diffBlob, "%s\n", blob_str(&out)); |
| 450 | 448 | } |
| 451 | 449 | } |
| 452 | 450 | } |
| 453 | 451 | blob_reset(&out); |
| | @@ -532,24 +530,22 @@ |
| 532 | 530 | int isBin2, /* Does the 'to' content appear to be binary */ |
| 533 | 531 | const char *zName, /* Display name of the file */ |
| 534 | 532 | const char *zDiffCmd, /* Command for comparison */ |
| 535 | 533 | const char *zBinGlob, /* Treat file names matching this as binary */ |
| 536 | 534 | int fIncludeBinary, /* Include binary files for external diff */ |
| 537 | | - u64 diffFlags /* Diff flags */ |
| 535 | + DiffConfig *pCfg /* Diff flags */ |
| 538 | 536 | ){ |
| 539 | | - if( diffFlags & DIFF_BRIEF ) return; |
| 537 | + if( pCfg->diffFlags & DIFF_BRIEF ) return; |
| 540 | 538 | if( zDiffCmd==0 ){ |
| 541 | 539 | Blob out; /* Diff output text */ |
| 542 | | - DiffConfig DCfg; |
| 543 | 540 | |
| 544 | | - diff_config_init(&DCfg, diffFlags); |
| 545 | 541 | blob_zero(&out); |
| 546 | | - text_diff(pFile1, pFile2, &out, 0, &DCfg); |
| 547 | | - if( diffFlags & DIFF_NUMSTAT ){ |
| 542 | + text_diff(pFile1, pFile2, &out, 0, pCfg); |
| 543 | + if( pCfg->diffFlags & DIFF_NUMSTAT ){ |
| 548 | 544 | fossil_print("%s %s\n", blob_str(&out), zName); |
| 549 | 545 | }else{ |
| 550 | | - diff_print_filenames(zName, zName, diffFlags, 0); |
| 546 | + diff_print_filenames(zName, zName, pCfg->diffFlags, 0); |
| 551 | 547 | fossil_print("%s\n", blob_str(&out)); |
| 552 | 548 | } |
| 553 | 549 | |
| 554 | 550 | /* Release memory resources */ |
| 555 | 551 | blob_reset(&out); |
| | @@ -614,22 +610,22 @@ |
| 614 | 610 | void diff_against_disk( |
| 615 | 611 | const char *zFrom, /* Version to difference from */ |
| 616 | 612 | const char *zDiffCmd, /* Use this diff command. NULL for built-in */ |
| 617 | 613 | const char *zBinGlob, /* Treat file names matching this as binary */ |
| 618 | 614 | int fIncludeBinary, /* Treat file names matching this as binary */ |
| 619 | | - u64 diffFlags, /* Flags controlling diff output */ |
| 615 | + DiffConfig *pCfg, /* Flags controlling diff output */ |
| 620 | 616 | FileDirList *pFileDir, /* Which files to diff */ |
| 621 | 617 | Blob *diffBlob /* Blob to output diff instead of stdout */ |
| 622 | 618 | ){ |
| 623 | 619 | int vid; |
| 624 | 620 | Blob sql; |
| 625 | 621 | Stmt q; |
| 626 | 622 | int asNewFile; /* Treat non-existant files as empty files */ |
| 627 | 623 | int isNumStat; /* True for --numstat */ |
| 628 | 624 | |
| 629 | | - asNewFile = (diffFlags & (DIFF_VERBOSE|DIFF_NUMSTAT|DIFF_HTML))!=0; |
| 630 | | - isNumStat = (diffFlags & (DIFF_NUMSTAT|DIFF_TCL|DIFF_HTML))!=0; |
| 625 | + asNewFile = (pCfg->diffFlags & (DIFF_VERBOSE|DIFF_NUMSTAT|DIFF_HTML))!=0; |
| 626 | + isNumStat = (pCfg->diffFlags & (DIFF_NUMSTAT|DIFF_TCL|DIFF_HTML))!=0; |
| 631 | 627 | vid = db_lget_int("checkout", 0); |
| 632 | 628 | vfile_check_signature(vid, CKSIG_ENOTFILE); |
| 633 | 629 | blob_zero(&sql); |
| 634 | 630 | db_begin_transaction(); |
| 635 | 631 | if( zFrom ){ |
| | @@ -711,24 +707,24 @@ |
| 711 | 707 | } |
| 712 | 708 | if( showDiff ){ |
| 713 | 709 | Blob content; |
| 714 | 710 | int isBin; |
| 715 | 711 | if( !isLink != !file_islink(zFullName) ){ |
| 716 | | - diff_print_index(zPathname, diffFlags, 0); |
| 717 | | - diff_print_filenames(zPathname, zPathname, diffFlags, 0); |
| 712 | + diff_print_index(zPathname, pCfg->diffFlags, 0); |
| 713 | + diff_print_filenames(zPathname, zPathname, pCfg->diffFlags, 0); |
| 718 | 714 | fossil_print("%s",DIFF_CANNOT_COMPUTE_SYMLINK); |
| 719 | 715 | continue; |
| 720 | 716 | } |
| 721 | 717 | if( srcid>0 ){ |
| 722 | 718 | content_get(srcid, &content); |
| 723 | 719 | }else{ |
| 724 | 720 | blob_zero(&content); |
| 725 | 721 | } |
| 726 | 722 | isBin = fIncludeBinary ? 0 : looks_like_binary(&content); |
| 727 | | - diff_print_index(zPathname, diffFlags, diffBlob); |
| 723 | + diff_print_index(zPathname, pCfg->diffFlags, diffBlob); |
| 728 | 724 | diff_file(&content, isBin, zFullName, zPathname, zDiffCmd, |
| 729 | | - zBinGlob, fIncludeBinary, diffFlags, 0, diffBlob); |
| 725 | + zBinGlob, fIncludeBinary, pCfg, 0, diffBlob); |
| 730 | 726 | blob_reset(&content); |
| 731 | 727 | } |
| 732 | 728 | blob_reset(&fname); |
| 733 | 729 | } |
| 734 | 730 | db_finalize(&q); |
| | @@ -747,11 +743,11 @@ |
| 747 | 743 | */ |
| 748 | 744 | static void diff_against_undo( |
| 749 | 745 | const char *zDiffCmd, /* Use this diff command. NULL for built-in */ |
| 750 | 746 | const char *zBinGlob, /* Treat file names matching this as binary */ |
| 751 | 747 | int fIncludeBinary, /* Treat file names matching this as binary */ |
| 752 | | - u64 diffFlags, /* Flags controlling diff output */ |
| 748 | + DiffConfig *pCfg, /* Flags controlling diff output */ |
| 753 | 749 | FileDirList *pFileDir /* List of files and directories to diff */ |
| 754 | 750 | ){ |
| 755 | 751 | Stmt q; |
| 756 | 752 | Blob content; |
| 757 | 753 | db_prepare(&q, "SELECT pathname, content FROM undo"); |
| | @@ -761,11 +757,11 @@ |
| 761 | 757 | const char *zFile = (const char*)db_column_text(&q, 0); |
| 762 | 758 | if( !file_dir_match(pFileDir, zFile) ) continue; |
| 763 | 759 | zFullName = mprintf("%s%s", g.zLocalRoot, zFile); |
| 764 | 760 | db_column_blob(&q, 1, &content); |
| 765 | 761 | diff_file(&content, 0, zFullName, zFile, |
| 766 | | - zDiffCmd, zBinGlob, fIncludeBinary, diffFlags, 0, 0); |
| 762 | + zDiffCmd, zBinGlob, fIncludeBinary, pCfg, 0, 0); |
| 767 | 763 | fossil_free(zFullName); |
| 768 | 764 | blob_reset(&content); |
| 769 | 765 | } |
| 770 | 766 | db_finalize(&q); |
| 771 | 767 | } |
| | @@ -785,11 +781,11 @@ |
| 785 | 781 | struct ManifestFile *pFrom, |
| 786 | 782 | struct ManifestFile *pTo, |
| 787 | 783 | const char *zDiffCmd, |
| 788 | 784 | const char *zBinGlob, |
| 789 | 785 | int fIncludeBinary, |
| 790 | | - u64 diffFlags |
| 786 | + DiffConfig *pCfg |
| 791 | 787 | ){ |
| 792 | 788 | Blob f1, f2; |
| 793 | 789 | int isBin1, isBin2; |
| 794 | 790 | int rid; |
| 795 | 791 | const char *zName; |
| | @@ -798,12 +794,12 @@ |
| 798 | 794 | }else if( pTo ){ |
| 799 | 795 | zName = pTo->zName; |
| 800 | 796 | }else{ |
| 801 | 797 | zName = DIFF_NO_NAME; |
| 802 | 798 | } |
| 803 | | - if( diffFlags & DIFF_BRIEF ) return; |
| 804 | | - diff_print_index(zName, diffFlags, 0); |
| 799 | + if( pCfg->diffFlags & DIFF_BRIEF ) return; |
| 800 | + diff_print_index(zName, pCfg->diffFlags, 0); |
| 805 | 801 | if( pFrom ){ |
| 806 | 802 | rid = uuid_to_rid(pFrom->zUuid, 0); |
| 807 | 803 | content_get(rid, &f1); |
| 808 | 804 | }else{ |
| 809 | 805 | blob_zero(&f1); |
| | @@ -815,11 +811,11 @@ |
| 815 | 811 | blob_zero(&f2); |
| 816 | 812 | } |
| 817 | 813 | isBin1 = fIncludeBinary ? 0 : looks_like_binary(&f1); |
| 818 | 814 | isBin2 = fIncludeBinary ? 0 : looks_like_binary(&f2); |
| 819 | 815 | diff_file_mem(&f1, &f2, isBin1, isBin2, zName, zDiffCmd, |
| 820 | | - zBinGlob, fIncludeBinary, diffFlags); |
| 816 | + zBinGlob, fIncludeBinary, pCfg); |
| 821 | 817 | blob_reset(&f1); |
| 822 | 818 | blob_reset(&f2); |
| 823 | 819 | } |
| 824 | 820 | |
| 825 | 821 | /* |
| | @@ -836,16 +832,16 @@ |
| 836 | 832 | const char *zFrom, |
| 837 | 833 | const char *zTo, |
| 838 | 834 | const char *zDiffCmd, |
| 839 | 835 | const char *zBinGlob, |
| 840 | 836 | int fIncludeBinary, |
| 841 | | - u64 diffFlags, |
| 837 | + DiffConfig *pCfg, |
| 842 | 838 | FileDirList *pFileDir |
| 843 | 839 | ){ |
| 844 | 840 | Manifest *pFrom, *pTo; |
| 845 | 841 | ManifestFile *pFromFile, *pToFile; |
| 846 | | - int asNewFlag = (diffFlags & (DIFF_VERBOSE|DIFF_NUMSTAT))!=0 ? 1 : 0; |
| 842 | + int asNewFlag = (pCfg->diffFlags & (DIFF_VERBOSE|DIFF_NUMSTAT))!=0 ? 1 : 0; |
| 847 | 843 | |
| 848 | 844 | pFrom = manifest_get_by_name(zFrom, 0); |
| 849 | 845 | manifest_file_rewind(pFrom); |
| 850 | 846 | pFromFile = manifest_file_next(pFrom,0); |
| 851 | 847 | pTo = manifest_get_by_name(zTo, 0); |
| | @@ -861,27 +857,28 @@ |
| 861 | 857 | }else{ |
| 862 | 858 | cmp = fossil_strcmp(pFromFile->zName, pToFile->zName); |
| 863 | 859 | } |
| 864 | 860 | if( cmp<0 ){ |
| 865 | 861 | if( file_dir_match(pFileDir, pFromFile->zName) ){ |
| 866 | | - if( (diffFlags & (DIFF_NUMSTAT|DIFF_HTML))==0 ){ |
| 862 | + if( (pCfg->diffFlags & (DIFF_NUMSTAT|DIFF_HTML))==0 ){ |
| 867 | 863 | fossil_print("DELETED %s\n", pFromFile->zName); |
| 868 | 864 | } |
| 869 | 865 | if( asNewFlag ){ |
| 870 | 866 | diff_manifest_entry(pFromFile, 0, zDiffCmd, zBinGlob, |
| 871 | | - fIncludeBinary, diffFlags); |
| 867 | + fIncludeBinary, pCfg); |
| 872 | 868 | } |
| 873 | 869 | } |
| 874 | 870 | pFromFile = manifest_file_next(pFrom,0); |
| 875 | 871 | }else if( cmp>0 ){ |
| 876 | 872 | if( file_dir_match(pFileDir, pToFile->zName) ){ |
| 877 | | - if( (diffFlags & (DIFF_NUMSTAT|DIFF_HTML|DIFF_TCL|DIFF_JSON))==0 ){ |
| 873 | + if( (pCfg->diffFlags & |
| 874 | + (DIFF_NUMSTAT|DIFF_HTML|DIFF_TCL|DIFF_JSON))==0 ){ |
| 878 | 875 | fossil_print("ADDED %s\n", pToFile->zName); |
| 879 | 876 | } |
| 880 | 877 | if( asNewFlag ){ |
| 881 | 878 | diff_manifest_entry(0, pToFile, zDiffCmd, zBinGlob, |
| 882 | | - fIncludeBinary, diffFlags); |
| 879 | + fIncludeBinary, pCfg); |
| 883 | 880 | } |
| 884 | 881 | } |
| 885 | 882 | pToFile = manifest_file_next(pTo,0); |
| 886 | 883 | }else if( fossil_strcmp(pFromFile->zUuid, pToFile->zUuid)==0 ){ |
| 887 | 884 | /* No changes */ |
| | @@ -888,15 +885,15 @@ |
| 888 | 885 | (void)file_dir_match(pFileDir, pFromFile->zName); /* Record name usage */ |
| 889 | 886 | pFromFile = manifest_file_next(pFrom,0); |
| 890 | 887 | pToFile = manifest_file_next(pTo,0); |
| 891 | 888 | }else{ |
| 892 | 889 | if( file_dir_match(pFileDir, pToFile->zName) ){ |
| 893 | | - if( diffFlags & DIFF_BRIEF ){ |
| 890 | + if( pCfg->diffFlags & DIFF_BRIEF ){ |
| 894 | 891 | fossil_print("CHANGED %s\n", pFromFile->zName); |
| 895 | 892 | }else{ |
| 896 | 893 | diff_manifest_entry(pFromFile, pToFile, zDiffCmd, zBinGlob, |
| 897 | | - fIncludeBinary, diffFlags); |
| 894 | + fIncludeBinary, pCfg); |
| 898 | 895 | } |
| 899 | 896 | } |
| 900 | 897 | pFromFile = manifest_file_next(pFrom,0); |
| 901 | 898 | pToFile = manifest_file_next(pTo,0); |
| 902 | 899 | } |
| | @@ -1200,17 +1197,17 @@ |
| 1200 | 1197 | if( db_lget_int("undo_available",0)==0 ){ |
| 1201 | 1198 | fossil_print("No undo or redo is available\n"); |
| 1202 | 1199 | return; |
| 1203 | 1200 | } |
| 1204 | 1201 | diff_against_undo(zDiffCmd, zBinGlob, fIncludeBinary, |
| 1205 | | - DCfg.diffFlags, pFileDir); |
| 1202 | + &DCfg, pFileDir); |
| 1206 | 1203 | }else if( zTo==0 ){ |
| 1207 | 1204 | diff_against_disk(zFrom, zDiffCmd, zBinGlob, fIncludeBinary, |
| 1208 | | - DCfg.diffFlags, pFileDir, 0); |
| 1205 | + &DCfg, pFileDir, 0); |
| 1209 | 1206 | }else{ |
| 1210 | 1207 | diff_two_versions(zFrom, zTo, zDiffCmd, zBinGlob, fIncludeBinary, |
| 1211 | | - DCfg.diffFlags, pFileDir); |
| 1208 | + &DCfg, pFileDir); |
| 1212 | 1209 | } |
| 1213 | 1210 | if( pFileDir ){ |
| 1214 | 1211 | int i; |
| 1215 | 1212 | for(i=0; pFileDir[i].zName; i++){ |
| 1216 | 1213 | if( pFileDir[i].nUsed==0 |
| | @@ -1237,12 +1234,14 @@ |
| 1237 | 1234 | ** Show a patch that goes from check-in FROM to check-in TO. |
| 1238 | 1235 | */ |
| 1239 | 1236 | void vpatch_page(void){ |
| 1240 | 1237 | const char *zFrom = P("from"); |
| 1241 | 1238 | const char *zTo = P("to"); |
| 1239 | + DiffConfig DCfg; |
| 1242 | 1240 | login_check_credentials(); |
| 1243 | 1241 | if( !g.perm.Read ){ login_needed(g.anon.Read); return; } |
| 1244 | 1242 | if( zFrom==0 || zTo==0 ) fossil_redirect_home(); |
| 1245 | 1243 | |
| 1246 | 1244 | cgi_set_content_type("text/plain"); |
| 1247 | | - diff_two_versions(zFrom, zTo, 0, 0, 0, DIFF_VERBOSE, 0); |
| 1245 | + diff_config_init(&DCfg, DIFF_VERBOSE); |
| 1246 | + diff_two_versions(zFrom, zTo, 0, 0, 0, &DCfg, 0); |
| 1248 | 1247 | } |
| 1249 | 1248 | |