Fossil SCM
Better fix for the case of doing a "fossil diff" on a checkout that includes a merge and specifying a --from clause that is the branch that was merged from.
Commit
960c9e8bd69531ebca9664afadd49326b1d336c877bdd7253eae000e6d5203c6
Parent
2169f323facef6b…
1 file changed
+23
-2
+23
-2
| --- src/diffcmd.c | ||
| +++ src/diffcmd.c | ||
| @@ -551,10 +551,29 @@ | ||
| 551 | 551 | blob_reset(&temp1); |
| 552 | 552 | blob_reset(&temp2); |
| 553 | 553 | blob_reset(&cmd); |
| 554 | 554 | } |
| 555 | 555 | } |
| 556 | + | |
| 557 | +/* | |
| 558 | +** Return true the disk file is identical to the Blob. Return zero | |
| 559 | +** if the files differ in any way. | |
| 560 | +*/ | |
| 561 | +static int file_same_as_blob(Blob *blob, const char *zDiskFile){ | |
| 562 | + Blob file; | |
| 563 | + int rc = 0; | |
| 564 | + if( blob_size(blob)!=file_size(zDiskFile, ExtFILE) ) return 0; | |
| 565 | + blob_zero(&file); | |
| 566 | + blob_read_from_file(&file, zDiskFile, ExtFILE); | |
| 567 | + if( blob_size(&file)!=blob_size(blob) ){ | |
| 568 | + rc = 0; | |
| 569 | + }else{ | |
| 570 | + rc = memcmp(blob_buffer(&file), blob_buffer(blob), blob_size(&file))==0; | |
| 571 | + } | |
| 572 | + blob_reset(&file); | |
| 573 | + return rc; | |
| 574 | +} | |
| 556 | 575 | |
| 557 | 576 | /* |
| 558 | 577 | ** Run a diff between the version zFrom and files on disk. zFrom might |
| 559 | 578 | ** be NULL which means to simply show the difference between the edited |
| 560 | 579 | ** files on disk and the check-out on which they are based. |
| @@ -672,12 +691,14 @@ | ||
| 672 | 691 | if( srcid>0 ){ |
| 673 | 692 | content_get(srcid, &content); |
| 674 | 693 | }else{ |
| 675 | 694 | blob_zero(&content); |
| 676 | 695 | } |
| 677 | - diff_print_index(zPathname, pCfg, pOut); | |
| 678 | - diff_file(&content, zFullName, zPathname, pCfg, pOut); | |
| 696 | + if( isChnged==0 || !file_same_as_blob(&content, zFullName) ){ | |
| 697 | + diff_print_index(zPathname, pCfg, pOut); | |
| 698 | + diff_file(&content, zFullName, zPathname, pCfg, pOut); | |
| 699 | + } | |
| 679 | 700 | blob_reset(&content); |
| 680 | 701 | } |
| 681 | 702 | blob_reset(&fname); |
| 682 | 703 | } |
| 683 | 704 | db_finalize(&q); |
| 684 | 705 |
| --- src/diffcmd.c | |
| +++ src/diffcmd.c | |
| @@ -551,10 +551,29 @@ | |
| 551 | blob_reset(&temp1); |
| 552 | blob_reset(&temp2); |
| 553 | blob_reset(&cmd); |
| 554 | } |
| 555 | } |
| 556 | |
| 557 | /* |
| 558 | ** Run a diff between the version zFrom and files on disk. zFrom might |
| 559 | ** be NULL which means to simply show the difference between the edited |
| 560 | ** files on disk and the check-out on which they are based. |
| @@ -672,12 +691,14 @@ | |
| 672 | if( srcid>0 ){ |
| 673 | content_get(srcid, &content); |
| 674 | }else{ |
| 675 | blob_zero(&content); |
| 676 | } |
| 677 | diff_print_index(zPathname, pCfg, pOut); |
| 678 | diff_file(&content, zFullName, zPathname, pCfg, pOut); |
| 679 | blob_reset(&content); |
| 680 | } |
| 681 | blob_reset(&fname); |
| 682 | } |
| 683 | db_finalize(&q); |
| 684 |
| --- src/diffcmd.c | |
| +++ src/diffcmd.c | |
| @@ -551,10 +551,29 @@ | |
| 551 | blob_reset(&temp1); |
| 552 | blob_reset(&temp2); |
| 553 | blob_reset(&cmd); |
| 554 | } |
| 555 | } |
| 556 | |
| 557 | /* |
| 558 | ** Return true the disk file is identical to the Blob. Return zero |
| 559 | ** if the files differ in any way. |
| 560 | */ |
| 561 | static int file_same_as_blob(Blob *blob, const char *zDiskFile){ |
| 562 | Blob file; |
| 563 | int rc = 0; |
| 564 | if( blob_size(blob)!=file_size(zDiskFile, ExtFILE) ) return 0; |
| 565 | blob_zero(&file); |
| 566 | blob_read_from_file(&file, zDiskFile, ExtFILE); |
| 567 | if( blob_size(&file)!=blob_size(blob) ){ |
| 568 | rc = 0; |
| 569 | }else{ |
| 570 | rc = memcmp(blob_buffer(&file), blob_buffer(blob), blob_size(&file))==0; |
| 571 | } |
| 572 | blob_reset(&file); |
| 573 | return rc; |
| 574 | } |
| 575 | |
| 576 | /* |
| 577 | ** Run a diff between the version zFrom and files on disk. zFrom might |
| 578 | ** be NULL which means to simply show the difference between the edited |
| 579 | ** files on disk and the check-out on which they are based. |
| @@ -672,12 +691,14 @@ | |
| 691 | if( srcid>0 ){ |
| 692 | content_get(srcid, &content); |
| 693 | }else{ |
| 694 | blob_zero(&content); |
| 695 | } |
| 696 | if( isChnged==0 || !file_same_as_blob(&content, zFullName) ){ |
| 697 | diff_print_index(zPathname, pCfg, pOut); |
| 698 | diff_file(&content, zFullName, zPathname, pCfg, pOut); |
| 699 | } |
| 700 | blob_reset(&content); |
| 701 | } |
| 702 | blob_reset(&fname); |
| 703 | } |
| 704 | db_finalize(&q); |
| 705 |