Fossil SCM
When editing the properties of a check-in and comparing the old and new comment text, ignore leading and trailing whitespace and the differences between \r\n and \n. Hopefully this will reduce the number of unwanted comment edits.
Commit
48928829e23d602162c71a469f2fef9f30ae058f
Parent
c80ee413ab77fb4…
1 file changed
+35
-2
+35
-2
| --- src/info.c | ||
| +++ src/info.c | ||
| @@ -1675,10 +1675,42 @@ | ||
| 1675 | 1675 | @ value="%h(stdClrFound?"":zDefaultColor)" /> |
| 1676 | 1676 | @ </td> |
| 1677 | 1677 | @ </tr> |
| 1678 | 1678 | @ </table> |
| 1679 | 1679 | } |
| 1680 | + | |
| 1681 | +/* | |
| 1682 | +** Do a comment comparison. | |
| 1683 | +** | |
| 1684 | +** + Leading and trailing whitespace are ignored. | |
| 1685 | +** + \r\n characters compare equal to \n | |
| 1686 | +** | |
| 1687 | +** Return true if equal and false if not equal. | |
| 1688 | +*/ | |
| 1689 | +static int comment_compare(const char *zA, const char *zB){ | |
| 1690 | + if( zA==0 ) zA = ""; | |
| 1691 | + if( zB==0 ) zB = ""; | |
| 1692 | + while( fossil_isspace(zA[0]) ) zA++; | |
| 1693 | + while( fossil_isspace(zB[0]) ) zB++; | |
| 1694 | + while( zA[0] && zB[0] ){ | |
| 1695 | + if( zA[0]==zB[0] ){ zA++; zB++; continue; } | |
| 1696 | + if( zA[0]=='\r' && zA[1]=='\n' && zB[0]=='\n' ){ | |
| 1697 | + zA += 2; | |
| 1698 | + zB++; | |
| 1699 | + continue; | |
| 1700 | + } | |
| 1701 | + if( zB[0]=='\r' && zB[1]=='\n' && zA[0]=='\n' ){ | |
| 1702 | + zB += 2; | |
| 1703 | + zA++; | |
| 1704 | + continue; | |
| 1705 | + } | |
| 1706 | + return 0; | |
| 1707 | + } | |
| 1708 | + while( fossil_isspace(zB[0]) ) zB++; | |
| 1709 | + while( fossil_isspace(zA[0]) ) zA++; | |
| 1710 | + return zA[0]==0 && zB[0]==0; | |
| 1711 | +} | |
| 1680 | 1712 | |
| 1681 | 1713 | /* |
| 1682 | 1714 | ** WEBPAGE: ci_edit |
| 1683 | 1715 | ** URL: ci_edit?r=RID&c=NEWCOMMENT&u=NEWUSER |
| 1684 | 1716 | ** |
| @@ -1752,11 +1784,12 @@ | ||
| 1752 | 1784 | blob_zero(&ctrl); |
| 1753 | 1785 | zNow = date_in_standard_format("now"); |
| 1754 | 1786 | blob_appendf(&ctrl, "D %s\n", zNow); |
| 1755 | 1787 | db_multi_exec("CREATE TEMP TABLE newtags(tag UNIQUE, prefix, value)"); |
| 1756 | 1788 | if( zNewColor[0] |
| 1757 | - && (fPropagateColor!=fNewPropagateColor || fossil_strcmp(zColor,zNewColor)!=0) | |
| 1789 | + && (fPropagateColor!=fNewPropagateColor | |
| 1790 | + || fossil_strcmp(zColor,zNewColor)!=0) | |
| 1758 | 1791 | ){ |
| 1759 | 1792 | char *zPrefix = "+"; |
| 1760 | 1793 | if( fNewPropagateColor ){ |
| 1761 | 1794 | zPrefix = "*"; |
| 1762 | 1795 | } |
| @@ -1764,11 +1797,11 @@ | ||
| 1764 | 1797 | zPrefix, zNewColor); |
| 1765 | 1798 | } |
| 1766 | 1799 | if( zNewColor[0]==0 && zColor[0]!=0 ){ |
| 1767 | 1800 | db_multi_exec("REPLACE INTO newtags VALUES('bgcolor','-',NULL)"); |
| 1768 | 1801 | } |
| 1769 | - if( fossil_strcmp(zComment,zNewComment)!=0 ){ | |
| 1802 | + if( comment_compare(zComment,zNewComment)==0 ){ | |
| 1770 | 1803 | db_multi_exec("REPLACE INTO newtags VALUES('comment','+',%Q)", |
| 1771 | 1804 | zNewComment); |
| 1772 | 1805 | } |
| 1773 | 1806 | if( fossil_strcmp(zDate,zNewDate)!=0 ){ |
| 1774 | 1807 | db_multi_exec("REPLACE INTO newtags VALUES('date','+',%Q)", |
| 1775 | 1808 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -1675,10 +1675,42 @@ | |
| 1675 | @ value="%h(stdClrFound?"":zDefaultColor)" /> |
| 1676 | @ </td> |
| 1677 | @ </tr> |
| 1678 | @ </table> |
| 1679 | } |
| 1680 | |
| 1681 | /* |
| 1682 | ** WEBPAGE: ci_edit |
| 1683 | ** URL: ci_edit?r=RID&c=NEWCOMMENT&u=NEWUSER |
| 1684 | ** |
| @@ -1752,11 +1784,12 @@ | |
| 1752 | blob_zero(&ctrl); |
| 1753 | zNow = date_in_standard_format("now"); |
| 1754 | blob_appendf(&ctrl, "D %s\n", zNow); |
| 1755 | db_multi_exec("CREATE TEMP TABLE newtags(tag UNIQUE, prefix, value)"); |
| 1756 | if( zNewColor[0] |
| 1757 | && (fPropagateColor!=fNewPropagateColor || fossil_strcmp(zColor,zNewColor)!=0) |
| 1758 | ){ |
| 1759 | char *zPrefix = "+"; |
| 1760 | if( fNewPropagateColor ){ |
| 1761 | zPrefix = "*"; |
| 1762 | } |
| @@ -1764,11 +1797,11 @@ | |
| 1764 | zPrefix, zNewColor); |
| 1765 | } |
| 1766 | if( zNewColor[0]==0 && zColor[0]!=0 ){ |
| 1767 | db_multi_exec("REPLACE INTO newtags VALUES('bgcolor','-',NULL)"); |
| 1768 | } |
| 1769 | if( fossil_strcmp(zComment,zNewComment)!=0 ){ |
| 1770 | db_multi_exec("REPLACE INTO newtags VALUES('comment','+',%Q)", |
| 1771 | zNewComment); |
| 1772 | } |
| 1773 | if( fossil_strcmp(zDate,zNewDate)!=0 ){ |
| 1774 | db_multi_exec("REPLACE INTO newtags VALUES('date','+',%Q)", |
| 1775 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -1675,10 +1675,42 @@ | |
| 1675 | @ value="%h(stdClrFound?"":zDefaultColor)" /> |
| 1676 | @ </td> |
| 1677 | @ </tr> |
| 1678 | @ </table> |
| 1679 | } |
| 1680 | |
| 1681 | /* |
| 1682 | ** Do a comment comparison. |
| 1683 | ** |
| 1684 | ** + Leading and trailing whitespace are ignored. |
| 1685 | ** + \r\n characters compare equal to \n |
| 1686 | ** |
| 1687 | ** Return true if equal and false if not equal. |
| 1688 | */ |
| 1689 | static int comment_compare(const char *zA, const char *zB){ |
| 1690 | if( zA==0 ) zA = ""; |
| 1691 | if( zB==0 ) zB = ""; |
| 1692 | while( fossil_isspace(zA[0]) ) zA++; |
| 1693 | while( fossil_isspace(zB[0]) ) zB++; |
| 1694 | while( zA[0] && zB[0] ){ |
| 1695 | if( zA[0]==zB[0] ){ zA++; zB++; continue; } |
| 1696 | if( zA[0]=='\r' && zA[1]=='\n' && zB[0]=='\n' ){ |
| 1697 | zA += 2; |
| 1698 | zB++; |
| 1699 | continue; |
| 1700 | } |
| 1701 | if( zB[0]=='\r' && zB[1]=='\n' && zA[0]=='\n' ){ |
| 1702 | zB += 2; |
| 1703 | zA++; |
| 1704 | continue; |
| 1705 | } |
| 1706 | return 0; |
| 1707 | } |
| 1708 | while( fossil_isspace(zB[0]) ) zB++; |
| 1709 | while( fossil_isspace(zA[0]) ) zA++; |
| 1710 | return zA[0]==0 && zB[0]==0; |
| 1711 | } |
| 1712 | |
| 1713 | /* |
| 1714 | ** WEBPAGE: ci_edit |
| 1715 | ** URL: ci_edit?r=RID&c=NEWCOMMENT&u=NEWUSER |
| 1716 | ** |
| @@ -1752,11 +1784,12 @@ | |
| 1784 | blob_zero(&ctrl); |
| 1785 | zNow = date_in_standard_format("now"); |
| 1786 | blob_appendf(&ctrl, "D %s\n", zNow); |
| 1787 | db_multi_exec("CREATE TEMP TABLE newtags(tag UNIQUE, prefix, value)"); |
| 1788 | if( zNewColor[0] |
| 1789 | && (fPropagateColor!=fNewPropagateColor |
| 1790 | || fossil_strcmp(zColor,zNewColor)!=0) |
| 1791 | ){ |
| 1792 | char *zPrefix = "+"; |
| 1793 | if( fNewPropagateColor ){ |
| 1794 | zPrefix = "*"; |
| 1795 | } |
| @@ -1764,11 +1797,11 @@ | |
| 1797 | zPrefix, zNewColor); |
| 1798 | } |
| 1799 | if( zNewColor[0]==0 && zColor[0]!=0 ){ |
| 1800 | db_multi_exec("REPLACE INTO newtags VALUES('bgcolor','-',NULL)"); |
| 1801 | } |
| 1802 | if( comment_compare(zComment,zNewComment)==0 ){ |
| 1803 | db_multi_exec("REPLACE INTO newtags VALUES('comment','+',%Q)", |
| 1804 | zNewComment); |
| 1805 | } |
| 1806 | if( fossil_strcmp(zDate,zNewDate)!=0 ){ |
| 1807 | db_multi_exec("REPLACE INTO newtags VALUES('date','+',%Q)", |
| 1808 |