| | @@ -69,16 +69,23 @@ |
| 69 | 69 | ** The difference is the set of edits needed to transform pFile1 into |
| 70 | 70 | ** zFile2. The content of pFile1 is in memory. zFile2 exists on disk. |
| 71 | 71 | ** |
| 72 | 72 | ** Use the internal diff logic if zDiffCmd is NULL. Otherwise call the |
| 73 | 73 | ** command zDiffCmd to do the diffing. |
| 74 | +** |
| 75 | +** When using an external diff program, zBinGlob contains the GLOB patterns |
| 76 | +** for file names to treat as binary. If fIncludeBinary is zero, these files |
| 77 | +** will be skipped in addition to files that may contain binary content. |
| 74 | 78 | */ |
| 75 | 79 | void diff_file( |
| 76 | 80 | Blob *pFile1, /* In memory content to compare from */ |
| 81 | + int isBin1, /* Does the 'from' content appear to be binary */ |
| 77 | 82 | const char *zFile2, /* On disk content to compare to */ |
| 78 | 83 | const char *zName, /* Display name of the file */ |
| 79 | 84 | const char *zDiffCmd, /* Command for comparison */ |
| 85 | + const char *zBinGlob, /* Treat file names matching this as binary */ |
| 86 | + int fIncludeBinary, /* Include binary files for external diff */ |
| 80 | 87 | u64 diffFlags /* Flags to control the diff */ |
| 81 | 88 | ){ |
| 82 | 89 | if( zDiffCmd==0 ){ |
| 83 | 90 | Blob out; /* Diff output text */ |
| 84 | 91 | Blob file2; /* Content of zFile2 */ |
| | @@ -116,10 +123,41 @@ |
| 116 | 123 | blob_reset(&file2); |
| 117 | 124 | }else{ |
| 118 | 125 | int cnt = 0; |
| 119 | 126 | Blob nameFile1; /* Name of temporary file to old pFile1 content */ |
| 120 | 127 | Blob cmd; /* Text of command to run */ |
| 128 | + |
| 129 | + if( !fIncludeBinary ){ |
| 130 | + Blob file2; |
| 131 | + if( isBin1 ){ |
| 132 | + fossil_print(DIFF_CANNOT_COMPUTE_BINARY); |
| 133 | + return; |
| 134 | + } |
| 135 | + if( zBinGlob ){ |
| 136 | + Glob *pBinary = glob_create(zBinGlob); |
| 137 | + if( glob_match(pBinary, zName) ){ |
| 138 | + fossil_print(DIFF_CANNOT_COMPUTE_BINARY); |
| 139 | + glob_free(pBinary); |
| 140 | + return; |
| 141 | + } |
| 142 | + glob_free(pBinary); |
| 143 | + } |
| 144 | + blob_zero(&file2); |
| 145 | + if( file_wd_size(zFile2)>=0 ){ |
| 146 | + if( file_wd_islink(zFile2) ){ |
| 147 | + blob_read_link(&file2, zFile2); |
| 148 | + }else{ |
| 149 | + blob_read_from_file(&file2, zFile2); |
| 150 | + } |
| 151 | + } |
| 152 | + if( looks_like_binary(blob_str(&file2), blob_size(&file2)) ){ |
| 153 | + fossil_print(DIFF_CANNOT_COMPUTE_BINARY); |
| 154 | + blob_reset(&file2); |
| 155 | + return; |
| 156 | + } |
| 157 | + blob_reset(&file2); |
| 158 | + } |
| 121 | 159 | |
| 122 | 160 | /* Construct a temporary file to hold pFile1 based on the name of |
| 123 | 161 | ** zFile2 */ |
| 124 | 162 | blob_zero(&nameFile1); |
| 125 | 163 | do{ |
| | @@ -151,16 +189,24 @@ |
| 151 | 189 | ** The difference is the set of edits needed to transform pFile1 into |
| 152 | 190 | ** pFile2. |
| 153 | 191 | ** |
| 154 | 192 | ** Use the internal diff logic if zDiffCmd is NULL. Otherwise call the |
| 155 | 193 | ** command zDiffCmd to do the diffing. |
| 194 | +** |
| 195 | +** When using an external diff program, zBinGlob contains the GLOB patterns |
| 196 | +** for file names to treat as binary. If fIncludeBinary is zero, these files |
| 197 | +** will be skipped in addition to files that may contain binary content. |
| 156 | 198 | */ |
| 157 | 199 | void diff_file_mem( |
| 158 | 200 | Blob *pFile1, /* In memory content to compare from */ |
| 159 | 201 | Blob *pFile2, /* In memory content to compare to */ |
| 202 | + int isBin1, /* Does the 'from' content appear to be binary */ |
| 203 | + int isBin2, /* Does the 'to' content appear to be binary */ |
| 160 | 204 | const char *zName, /* Display name of the file */ |
| 161 | 205 | const char *zDiffCmd, /* Command for comparison */ |
| 206 | + const char *zBinGlob, /* Treat file names matching this as binary */ |
| 207 | + int fIncludeBinary, /* Include binary files for external diff */ |
| 162 | 208 | u64 diffFlags /* Diff flags */ |
| 163 | 209 | ){ |
| 164 | 210 | if( diffFlags & DIFF_BRIEF ) return; |
| 165 | 211 | if( zDiffCmd==0 ){ |
| 166 | 212 | Blob out; /* Diff output text */ |
| | @@ -174,10 +220,26 @@ |
| 174 | 220 | blob_reset(&out); |
| 175 | 221 | }else{ |
| 176 | 222 | Blob cmd; |
| 177 | 223 | char zTemp1[300]; |
| 178 | 224 | char zTemp2[300]; |
| 225 | + |
| 226 | + if( !fIncludeBinary ){ |
| 227 | + if( isBin1 || isBin2 ){ |
| 228 | + fossil_print(DIFF_CANNOT_COMPUTE_BINARY); |
| 229 | + return; |
| 230 | + } |
| 231 | + if( zBinGlob ){ |
| 232 | + Glob *pBinary = glob_create(zBinGlob); |
| 233 | + if( glob_match(pBinary, zName) ){ |
| 234 | + fossil_print(DIFF_CANNOT_COMPUTE_BINARY); |
| 235 | + glob_free(pBinary); |
| 236 | + return; |
| 237 | + } |
| 238 | + glob_free(pBinary); |
| 239 | + } |
| 240 | + } |
| 179 | 241 | |
| 180 | 242 | /* Construct a temporary file names */ |
| 181 | 243 | file_tempname(sizeof(zTemp1), zTemp1); |
| 182 | 244 | file_tempname(sizeof(zTemp2), zTemp2); |
| 183 | 245 | blob_write_to_file(pFile1, zTemp1); |
| | @@ -201,40 +263,60 @@ |
| 201 | 263 | } |
| 202 | 264 | |
| 203 | 265 | /* |
| 204 | 266 | ** Do a diff against a single file named in zFileTreeName from version zFrom |
| 205 | 267 | ** against the same file on disk. |
| 268 | +** |
| 269 | +** Use the internal diff logic if zDiffCmd is NULL. Otherwise call the |
| 270 | +** command zDiffCmd to do the diffing. |
| 271 | +** |
| 272 | +** When using an external diff program, zBinGlob contains the GLOB patterns |
| 273 | +** for file names to treat as binary. If fIncludeBinary is zero, these files |
| 274 | +** will be skipped in addition to files that may contain binary content. |
| 206 | 275 | */ |
| 207 | 276 | static void diff_one_against_disk( |
| 208 | 277 | const char *zFrom, /* Name of file */ |
| 209 | 278 | const char *zDiffCmd, /* Use this "diff" command */ |
| 279 | + const char *zBinGlob, /* Treat file names matching this as binary */ |
| 280 | + int fIncludeBinary, /* Include binary files for external diff */ |
| 210 | 281 | u64 diffFlags, /* Diff control flags */ |
| 211 | 282 | const char *zFileTreeName |
| 212 | 283 | ){ |
| 213 | 284 | Blob fname; |
| 214 | 285 | Blob content; |
| 215 | 286 | int isLink; |
| 287 | + int isBin; |
| 216 | 288 | file_tree_name(zFileTreeName, &fname, 1); |
| 217 | | - historical_version_of_file(zFrom, blob_str(&fname), &content, &isLink, 0, 0); |
| 289 | + historical_version_of_file(zFrom, blob_str(&fname), &content, &isLink, 0, |
| 290 | + fIncludeBinary ? 0 : &isBin, 0); |
| 218 | 291 | if( !isLink != !file_wd_islink(zFrom) ){ |
| 219 | | - fossil_print("cannot compute difference between " |
| 220 | | - "symlink and regular file\n"); |
| 292 | + fossil_print(DIFF_CANNOT_COMPUTE_SYMLINK); |
| 221 | 293 | }else{ |
| 222 | | - diff_file(&content, zFileTreeName, zFileTreeName, zDiffCmd, diffFlags); |
| 294 | + diff_file(&content, isBin, zFileTreeName, zFileTreeName, |
| 295 | + zDiffCmd, zBinGlob, fIncludeBinary, diffFlags); |
| 223 | 296 | } |
| 224 | 297 | blob_reset(&content); |
| 225 | 298 | blob_reset(&fname); |
| 226 | 299 | } |
| 227 | 300 | |
| 228 | 301 | /* |
| 229 | 302 | ** Run a diff between the version zFrom and files on disk. zFrom might |
| 230 | 303 | ** be NULL which means to simply show the difference between the edited |
| 231 | 304 | ** files on disk and the check-out on which they are based. |
| 305 | +** |
| 306 | +** Use the internal diff logic if zDiffCmd is NULL. Otherwise call the |
| 307 | +** command zDiffCmd to do the diffing. |
| 308 | +** |
| 309 | +** When using an external diff program, zBinGlob contains the GLOB patterns |
| 310 | +** for file names to treat as binary. If fIncludeBinary is zero, these files |
| 311 | +** will be skipped in addition to files that may contain binary content. |
| 232 | 312 | */ |
| 233 | 313 | static void diff_all_against_disk( |
| 234 | 314 | const char *zFrom, /* Version to difference from */ |
| 235 | 315 | const char *zDiffCmd, /* Use this diff command. NULL for built-in */ |
| 316 | + const char *zBinGlob, /* Treat file names matching this as binary */ |
| 317 | + int fIncludeBinary, /* Treat file names matching this as binary */ |
| 236 | 318 | u64 diffFlags /* Flags controlling diff output */ |
| 237 | 319 | ){ |
| 238 | 320 | int vid; |
| 239 | 321 | Blob sql; |
| 240 | 322 | Stmt q; |
| | @@ -307,24 +389,27 @@ |
| 307 | 389 | srcid = 0; |
| 308 | 390 | if( !asNewFile ){ showDiff = 0; } |
| 309 | 391 | } |
| 310 | 392 | if( showDiff ){ |
| 311 | 393 | Blob content; |
| 394 | + int isBin; |
| 312 | 395 | if( !isLink != !file_wd_islink(zFullName) ){ |
| 313 | 396 | diff_print_index(zPathname, diffFlags); |
| 314 | 397 | diff_print_filenames(zPathname, zPathname, diffFlags); |
| 315 | | - fossil_print("cannot compute difference between " |
| 316 | | - "symlink and regular file\n"); |
| 398 | + fossil_print(DIFF_CANNOT_COMPUTE_SYMLINK); |
| 317 | 399 | continue; |
| 318 | 400 | } |
| 319 | 401 | if( srcid>0 ){ |
| 320 | 402 | content_get(srcid, &content); |
| 321 | 403 | }else{ |
| 322 | 404 | blob_zero(&content); |
| 323 | 405 | } |
| 406 | + isBin = fIncludeBinary ? 0 : looks_like_binary(blob_str(&content), |
| 407 | + blob_size(&content)); |
| 324 | 408 | diff_print_index(zPathname, diffFlags); |
| 325 | | - diff_file(&content, zFullName, zPathname, zDiffCmd, diffFlags); |
| 409 | + diff_file(&content, isBin, zFullName, zPathname, zDiffCmd, |
| 410 | + zBinGlob, fIncludeBinary, diffFlags); |
| 326 | 411 | blob_reset(&content); |
| 327 | 412 | } |
| 328 | 413 | free(zToFree); |
| 329 | 414 | } |
| 330 | 415 | db_finalize(&q); |
| | @@ -332,50 +417,72 @@ |
| 332 | 417 | } |
| 333 | 418 | |
| 334 | 419 | /* |
| 335 | 420 | ** Output the differences between two versions of a single file. |
| 336 | 421 | ** zFrom and zTo are the check-ins containing the two file versions. |
| 422 | +** |
| 423 | +** Use the internal diff logic if zDiffCmd is NULL. Otherwise call the |
| 424 | +** command zDiffCmd to do the diffing. |
| 425 | +** |
| 426 | +** When using an external diff program, zBinGlob contains the GLOB patterns |
| 427 | +** for file names to treat as binary. If fIncludeBinary is zero, these files |
| 428 | +** will be skipped in addition to files that may contain binary content. |
| 337 | 429 | */ |
| 338 | 430 | static void diff_one_two_versions( |
| 339 | 431 | const char *zFrom, |
| 340 | 432 | const char *zTo, |
| 341 | 433 | const char *zDiffCmd, |
| 434 | + const char *zBinGlob, |
| 435 | + int fIncludeBinary, |
| 342 | 436 | u64 diffFlags, |
| 343 | 437 | const char *zFileTreeName |
| 344 | 438 | ){ |
| 345 | 439 | char *zName; |
| 346 | 440 | Blob fname; |
| 347 | 441 | Blob v1, v2; |
| 348 | 442 | int isLink1, isLink2; |
| 443 | + int isBin1, isBin2; |
| 349 | 444 | if( diffFlags & DIFF_BRIEF ) return; |
| 350 | 445 | file_tree_name(zFileTreeName, &fname, 1); |
| 351 | 446 | zName = blob_str(&fname); |
| 352 | | - historical_version_of_file(zFrom, zName, &v1, &isLink1, 0, 0); |
| 353 | | - historical_version_of_file(zTo, zName, &v2, &isLink2, 0, 0); |
| 447 | + historical_version_of_file(zFrom, zName, &v1, &isLink1, 0, |
| 448 | + fIncludeBinary ? 0 : &isBin1, 0); |
| 449 | + historical_version_of_file(zTo, zName, &v2, &isLink2, 0, |
| 450 | + fIncludeBinary ? 0 : &isBin2, 0); |
| 354 | 451 | if( isLink1 != isLink2 ){ |
| 355 | 452 | diff_print_filenames(zName, zName, diffFlags); |
| 356 | | - fossil_print("cannot compute difference " |
| 357 | | - " between symlink and regular file\n"); |
| 453 | + fossil_print(DIFF_CANNOT_COMPUTE_SYMLINK); |
| 358 | 454 | }else{ |
| 359 | | - diff_file_mem(&v1, &v2, zName, zDiffCmd, diffFlags); |
| 455 | + diff_file_mem(&v1, &v2, isBin1, isBin2, zName, zDiffCmd, |
| 456 | + zBinGlob, fIncludeBinary, diffFlags); |
| 360 | 457 | } |
| 361 | 458 | blob_reset(&v1); |
| 362 | 459 | blob_reset(&v2); |
| 363 | 460 | blob_reset(&fname); |
| 364 | 461 | } |
| 365 | 462 | |
| 366 | 463 | /* |
| 367 | 464 | ** Show the difference between two files identified by ManifestFile |
| 368 | 465 | ** entries. |
| 466 | +** |
| 467 | +** Use the internal diff logic if zDiffCmd is NULL. Otherwise call the |
| 468 | +** command zDiffCmd to do the diffing. |
| 469 | +** |
| 470 | +** When using an external diff program, zBinGlob contains the GLOB patterns |
| 471 | +** for file names to treat as binary. If fIncludeBinary is zero, these files |
| 472 | +** will be skipped in addition to files that may contain binary content. |
| 369 | 473 | */ |
| 370 | 474 | static void diff_manifest_entry( |
| 371 | 475 | struct ManifestFile *pFrom, |
| 372 | 476 | struct ManifestFile *pTo, |
| 373 | 477 | const char *zDiffCmd, |
| 478 | + const char *zBinGlob, |
| 479 | + int fIncludeBinary, |
| 374 | 480 | u64 diffFlags |
| 375 | 481 | ){ |
| 376 | 482 | Blob f1, f2; |
| 483 | + int isBin1, isBin2; |
| 377 | 484 | int rid; |
| 378 | 485 | const char *zName = pFrom ? pFrom->zName : pTo->zName; |
| 379 | 486 | if( diffFlags & DIFF_BRIEF ) return; |
| 380 | 487 | diff_print_index(zName, diffFlags); |
| 381 | 488 | if( pFrom ){ |
| | @@ -388,22 +495,36 @@ |
| 388 | 495 | rid = uuid_to_rid(pTo->zUuid, 0); |
| 389 | 496 | content_get(rid, &f2); |
| 390 | 497 | }else{ |
| 391 | 498 | blob_zero(&f2); |
| 392 | 499 | } |
| 393 | | - diff_file_mem(&f1, &f2, zName, zDiffCmd, diffFlags); |
| 500 | + isBin1 = fIncludeBinary ? 0 : looks_like_binary(blob_str(&f1), |
| 501 | + blob_size(&f1)); |
| 502 | + isBin2 = fIncludeBinary ? 0 : looks_like_binary(blob_str(&f2), |
| 503 | + blob_size(&f2)); |
| 504 | + diff_file_mem(&f1, &f2, isBin1, isBin2, zName, zDiffCmd, |
| 505 | + zBinGlob, fIncludeBinary, diffFlags); |
| 394 | 506 | blob_reset(&f1); |
| 395 | 507 | blob_reset(&f2); |
| 396 | 508 | } |
| 397 | 509 | |
| 398 | 510 | /* |
| 399 | 511 | ** Output the differences between two check-ins. |
| 512 | +** |
| 513 | +** Use the internal diff logic if zDiffCmd is NULL. Otherwise call the |
| 514 | +** command zDiffCmd to do the diffing. |
| 515 | +** |
| 516 | +** When using an external diff program, zBinGlob contains the GLOB patterns |
| 517 | +** for file names to treat as binary. If fIncludeBinary is zero, these files |
| 518 | +** will be skipped in addition to files that may contain binary content. |
| 400 | 519 | */ |
| 401 | 520 | static void diff_all_two_versions( |
| 402 | 521 | const char *zFrom, |
| 403 | 522 | const char *zTo, |
| 404 | 523 | const char *zDiffCmd, |
| 524 | + const char *zBinGlob, |
| 525 | + int fIncludeBinary, |
| 405 | 526 | u64 diffFlags |
| 406 | 527 | ){ |
| 407 | 528 | Manifest *pFrom, *pTo; |
| 408 | 529 | ManifestFile *pFromFile, *pToFile; |
| 409 | 530 | int asNewFlag = (diffFlags & DIFF_NEWFILE)!=0 ? 1 : 0; |
| | @@ -425,17 +546,19 @@ |
| 425 | 546 | cmp = fossil_strcmp(pFromFile->zName, pToFile->zName); |
| 426 | 547 | } |
| 427 | 548 | if( cmp<0 ){ |
| 428 | 549 | fossil_print("DELETED %s\n", pFromFile->zName); |
| 429 | 550 | if( asNewFlag ){ |
| 430 | | - diff_manifest_entry(pFromFile, 0, zDiffCmd, diffFlags); |
| 551 | + diff_manifest_entry(pFromFile, 0, zDiffCmd, zBinGlob, |
| 552 | + fIncludeBinary, diffFlags); |
| 431 | 553 | } |
| 432 | 554 | pFromFile = manifest_file_next(pFrom,0); |
| 433 | 555 | }else if( cmp>0 ){ |
| 434 | 556 | fossil_print("ADDED %s\n", pToFile->zName); |
| 435 | 557 | if( asNewFlag ){ |
| 436 | | - diff_manifest_entry(0, pToFile, zDiffCmd, diffFlags); |
| 558 | + diff_manifest_entry(0, pToFile, zDiffCmd, zBinGlob, |
| 559 | + fIncludeBinary, diffFlags); |
| 437 | 560 | } |
| 438 | 561 | pToFile = manifest_file_next(pTo,0); |
| 439 | 562 | }else if( fossil_strcmp(pFromFile->zUuid, pToFile->zUuid)==0 ){ |
| 440 | 563 | /* No changes */ |
| 441 | 564 | pFromFile = manifest_file_next(pFrom,0); |
| | @@ -442,11 +565,12 @@ |
| 442 | 565 | pToFile = manifest_file_next(pTo,0); |
| 443 | 566 | }else{ |
| 444 | 567 | if( diffFlags & DIFF_BRIEF ){ |
| 445 | 568 | fossil_print("CHANGED %s\n", pFromFile->zName); |
| 446 | 569 | }else{ |
| 447 | | - diff_manifest_entry(pFromFile, pToFile, zDiffCmd, diffFlags); |
| 570 | + diff_manifest_entry(pFromFile, pToFile, zDiffCmd, zBinGlob, |
| 571 | + fIncludeBinary, diffFlags); |
| 448 | 572 | } |
| 449 | 573 | pFromFile = manifest_file_next(pFrom,0); |
| 450 | 574 | pToFile = manifest_file_next(pTo,0); |
| 451 | 575 | } |
| 452 | 576 | } |
| | @@ -544,10 +668,34 @@ |
| 544 | 668 | zTempFile = write_blob_to_temp_file(&script); |
| 545 | 669 | zCmd = mprintf("tclsh \"%s\"", zTempFile); |
| 546 | 670 | fossil_system(zCmd); |
| 547 | 671 | file_delete(zTempFile); |
| 548 | 672 | } |
| 673 | + |
| 674 | +/* |
| 675 | +** Returns non-zero if files that may be binary should be used with external |
| 676 | +** diff programs. |
| 677 | +*/ |
| 678 | +int diff_include_binary_files(void){ |
| 679 | + if( is_truth(find_option("diff-binary", 0, 1)) ){ |
| 680 | + return 1; |
| 681 | + } |
| 682 | + if( db_get_boolean("diff-binary", 1) ){ |
| 683 | + return 1; |
| 684 | + } |
| 685 | + return 0; |
| 686 | +} |
| 687 | + |
| 688 | +/* |
| 689 | +** Returns the GLOB pattern for file names that should be treated as binary |
| 690 | +** by the diff subsystem, if any. |
| 691 | +*/ |
| 692 | +const char *diff_get_binary_glob(void){ |
| 693 | + const char *zBinGlob = find_option("binary", 0, 1); |
| 694 | + if( zBinGlob==0 ) zBinGlob = db_get("binary-glob",0); |
| 695 | + return zBinGlob; |
| 696 | +} |
| 549 | 697 | |
| 550 | 698 | /* |
| 551 | 699 | ** COMMAND: diff |
| 552 | 700 | ** COMMAND: gdiff |
| 553 | 701 | ** |
| | @@ -573,10 +721,17 @@ |
| 573 | 721 | ** the "-i" option is a no-op. The "-i" option converts "gdiff" into "diff". |
| 574 | 722 | ** |
| 575 | 723 | ** The "-N" or "--new-file" option causes the complete text of added or |
| 576 | 724 | ** deleted files to be displayed. |
| 577 | 725 | ** |
| 726 | +** The "--diff-binary" option enables or disables the inclusion of binary files |
| 727 | +** when using an external diff program. |
| 728 | +** |
| 729 | +** The "--binary" option causes files matching the glob PATTERN to be treated |
| 730 | +** as binary when considering if they should be used with external diff program. |
| 731 | +** This option overrides the "binary-glob" setting. |
| 732 | +** |
| 578 | 733 | ** Options: |
| 579 | 734 | ** --branch BRANCH Show diff of all changes on BRANCH |
| 580 | 735 | ** --brief Show filenames only |
| 581 | 736 | ** --context|-c N Use N lines of context |
| 582 | 737 | ** --from|-r VERSION select VERSION as source for the diff |
| | @@ -585,19 +740,23 @@ |
| 585 | 740 | ** --tk Launch a Tcl/Tk GUI for display |
| 586 | 741 | ** --to VERSION select VERSION as target for the diff |
| 587 | 742 | ** --side-by-side|-y side-by-side diff |
| 588 | 743 | ** --unified unified diff |
| 589 | 744 | ** --width|-W N Width of lines in side-by-side diff |
| 745 | +** --diff-binary BOOL Include binary files when using external commands |
| 746 | +** --binary PATTERN Treat files that match the glob PATTERN as binary |
| 590 | 747 | */ |
| 591 | 748 | void diff_cmd(void){ |
| 592 | 749 | int isGDiff; /* True for gdiff. False for normal diff */ |
| 593 | 750 | int isInternDiff; /* True for internal diff */ |
| 594 | 751 | int hasNFlag; /* True if -N or --new-file flag is used */ |
| 595 | 752 | const char *zFrom; /* Source version number */ |
| 596 | 753 | const char *zTo; /* Target version number */ |
| 597 | 754 | const char *zBranch; /* Branch to diff */ |
| 598 | 755 | const char *zDiffCmd = 0; /* External diff command. NULL for internal diff */ |
| 756 | + const char *zBinGlob = 0; /* Treat file names matching this as binary */ |
| 757 | + int fIncludeBinary = 0; /* Include binary files for external diff */ |
| 599 | 758 | u64 diffFlags = 0; /* Flags to control the DIFF */ |
| 600 | 759 | int f; |
| 601 | 760 | |
| 602 | 761 | if( find_option("tk",0,0)!=0 ){ |
| 603 | 762 | diff_tk(); |
| | @@ -619,35 +778,43 @@ |
| 619 | 778 | zTo = zBranch; |
| 620 | 779 | zFrom = mprintf("root:%s", zBranch); |
| 621 | 780 | } |
| 622 | 781 | if( zTo==0 ){ |
| 623 | 782 | db_must_be_within_tree(); |
| 624 | | - verify_all_options(); |
| 625 | 783 | if( !isInternDiff ){ |
| 626 | 784 | zDiffCmd = diff_command_external(isGDiff); |
| 627 | 785 | } |
| 786 | + zBinGlob = diff_get_binary_glob(); |
| 787 | + fIncludeBinary = diff_include_binary_files(); |
| 788 | + verify_all_options(); |
| 628 | 789 | if( g.argc>=3 ){ |
| 629 | 790 | for(f=2; f<g.argc; ++f){ |
| 630 | | - diff_one_against_disk(zFrom, zDiffCmd, diffFlags, g.argv[f]); |
| 791 | + diff_one_against_disk(zFrom, zDiffCmd, zBinGlob, fIncludeBinary, |
| 792 | + diffFlags, g.argv[f]); |
| 631 | 793 | } |
| 632 | 794 | }else{ |
| 633 | | - diff_all_against_disk(zFrom, zDiffCmd, diffFlags); |
| 795 | + diff_all_against_disk(zFrom, zDiffCmd, zBinGlob, fIncludeBinary, |
| 796 | + diffFlags); |
| 634 | 797 | } |
| 635 | 798 | }else if( zFrom==0 ){ |
| 636 | 799 | fossil_fatal("must use --from if --to is present"); |
| 637 | 800 | }else{ |
| 638 | 801 | db_find_and_open_repository(0, 0); |
| 639 | | - verify_all_options(); |
| 640 | 802 | if( !isInternDiff ){ |
| 641 | 803 | zDiffCmd = diff_command_external(isGDiff); |
| 642 | 804 | } |
| 805 | + zBinGlob = diff_get_binary_glob(); |
| 806 | + fIncludeBinary = diff_include_binary_files(); |
| 807 | + verify_all_options(); |
| 643 | 808 | if( g.argc>=3 ){ |
| 644 | 809 | for(f=2; f<g.argc; ++f){ |
| 645 | | - diff_one_two_versions(zFrom, zTo, zDiffCmd, diffFlags, g.argv[f]); |
| 810 | + diff_one_two_versions(zFrom, zTo, zDiffCmd, zBinGlob, fIncludeBinary, |
| 811 | + diffFlags, g.argv[f]); |
| 646 | 812 | } |
| 647 | 813 | }else{ |
| 648 | | - diff_all_two_versions(zFrom, zTo, zDiffCmd, diffFlags); |
| 814 | + diff_all_two_versions(zFrom, zTo, zDiffCmd, zBinGlob, fIncludeBinary, |
| 815 | + diffFlags); |
| 649 | 816 | } |
| 650 | 817 | } |
| 651 | 818 | } |
| 652 | 819 | |
| 653 | 820 | /* |
| | @@ -660,7 +827,7 @@ |
| 660 | 827 | login_check_credentials(); |
| 661 | 828 | if( !g.perm.Read ){ login_needed(); return; } |
| 662 | 829 | if( zFrom==0 || zTo==0 ) fossil_redirect_home(); |
| 663 | 830 | |
| 664 | 831 | cgi_set_content_type("text/plain"); |
| 665 | | - diff_all_two_versions(zFrom, zTo, 0, DIFF_NEWFILE); |
| 832 | + diff_all_two_versions(zFrom, zTo, 0, 0, 0, DIFF_NEWFILE); |
| 666 | 833 | } |
| 667 | 834 | |