Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | New format for JSON diff output. Promote the "test-diff" command to "xdiff", retaining the older spelling as a backup for compatibility. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | diff-color-enhancements |
Files: | files | file ages | folders |
SHA3-256: |
b0511022724d7bf02169a54ae9e2c846 |
User & Date: | drh 2021-09-02 19:38:26 |
Context
2021-09-02
| ||
22:28 | Improved comments on the diff formatter and related logic. ... (check-in: d29ddba3 user: drh tags: diff-color-enhancements) | |
19:38 | New format for JSON diff output. Promote the "test-diff" command to "xdiff", retaining the older spelling as a backup for compatibility. ... (check-in: b0511022 user: drh tags: diff-color-enhancements) | |
18:44 | Better control over the blue/red/green colors in the --tk TCL code. ... (check-in: 1df8b9d7 user: drh tags: diff-color-enhancements) | |
Changes
Changes to src/blob.c.
︙ | ︙ | |||
354 355 356 357 358 359 360 361 362 363 364 365 366 367 | ** Append the second blob onto the end of the first blob and reset the ** second blob. */ void blob_append_xfer(Blob *pTo, Blob *pFrom){ blob_append(pTo, blob_buffer(pFrom), blob_size(pFrom)); blob_reset(pFrom); } /* ** Return a pointer to a null-terminated string for a blob. */ char *blob_str(Blob *p){ blob_is_init(p); if( p->nUsed==0 ){ | > > > > > > > > > > > > > > > > > > > > > > > | 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 | ** Append the second blob onto the end of the first blob and reset the ** second blob. */ void blob_append_xfer(Blob *pTo, Blob *pFrom){ blob_append(pTo, blob_buffer(pFrom), blob_size(pFrom)); blob_reset(pFrom); } /* ** Write into pOut, a string literal representation for the first n bytes ** of z[]. The string literal representation is compatible with C, TCL, ** and JSON. Double-quotes are added to both ends. Double-quote and ** backslash characters are escaped. */ void blob_append_string_literal(Blob *pOut, const char *z, int n){ int i; blob_append_char(pOut, '"'); for(i=0; i<n; i++){ switch( z[i] ){ case '"': case '\\': blob_append_char(pOut, '\\'); /* Fall thru */ default: blob_append_char(pOut, z[i]); } } blob_append_char(pOut, '"'); } /* ** Return a pointer to a null-terminated string for a blob. */ char *blob_str(Blob *p){ blob_is_init(p); if( p->nUsed==0 ){ |
︙ | ︙ |
Changes to src/diff.c.
︙ | ︙ | |||
1740 1741 1742 1743 1744 1745 1746 | } /************************* DiffBuilderTcl ********************************/ /* ** This variant outputs a description of the diff formatted as TCL, for ** use by the --tk option to "diff". */ | < < < < < < < < < < < < < < < < < < < < | | | | | | | > | | | | < > | | | | | | > > > > < | < < > > | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | | < | | | < | | | < | | | | | | < < > < | | | < < < | | | | < < < | < | < < < < < < < < | < | > | | 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 | } /************************* DiffBuilderTcl ********************************/ /* ** This variant outputs a description of the diff formatted as TCL, for ** use by the --tk option to "diff". */ static void dftclSkip(DiffBuilder *p, unsigned int n, int isFinal){ blob_appendf(p->pOut, "SKIP %u\n", n); } static void dftclCommon(DiffBuilder *p, const DLine *pLine){ blob_appendf(p->pOut, "COM "); blob_append_string_literal(p->pOut, pLine->z, pLine->n); blob_append_char(p->pOut, '\n'); } static void dftclInsert(DiffBuilder *p, const DLine *pLine){ blob_append(p->pOut, "INS ", -1); blob_append_string_literal(p->pOut, pLine->z, pLine->n); blob_append_char(p->pOut, '\n'); } static void dftclDelete(DiffBuilder *p, const DLine *pLine){ blob_append(p->pOut, "DEL ", -1); blob_append_string_literal(p->pOut, pLine->z, pLine->n); blob_append_char(p->pOut, '\n'); } static void dftclReplace(DiffBuilder *p, const DLine *pX, const DLine *pY){ blob_append(p->pOut, "EDIT ", -1); blob_append_string_literal(p->pOut, pX->z, pX->n); blob_append_char(p->pOut, ' '); blob_append_string_literal(p->pOut, pY->z, pY->n); blob_append_char(p->pOut, '\n'); } static void dftclEdit(DiffBuilder *p, const DLine *pX, const DLine *pY){ int i, x; ChangeSpan span; blob_append(p->pOut, "EDIT", 4); oneLineChange(pX, pY, &span); for(i=x=0; i<span.n; i++){ blob_append_char(p->pOut, ' '); blob_append_string_literal(p->pOut, pX->z + x, span.a[i].iStart1 - x); x = span.a[i].iStart1; blob_append_char(p->pOut, ' '); blob_append_string_literal(p->pOut, pX->z + x, span.a[i].iLen1); x += span.a[i].iLen1; blob_append_char(p->pOut, ' '); blob_append_string_literal(p->pOut, pY->z + span.a[i].iStart2, span.a[i].iLen2); } if( x<pX->n ){ blob_append_char(p->pOut, ' '); blob_append_string_literal(p->pOut, pX->z + x, pX->n - x); } blob_append_char(p->pOut, '\n'); } static void dftclEnd(DiffBuilder *p){ fossil_free(p); } static DiffBuilder *dftclNew(Blob *pOut){ DiffBuilder *p = fossil_malloc(sizeof(*p)); p->xSkip = dftclSkip; p->xCommon = dftclCommon; p->xInsert = dftclInsert; p->xDelete = dftclDelete; p->xReplace = dftclReplace; p->xEdit = dftclEdit; p->xEnd = dftclEnd; p->pOut = pOut; return p; } /************************* DiffBuilderJson ********************************/ /* ** This module generates a JSON array that describes the difference. ** ** The Json array consists of integer opcodes with each opcode followed ** by zero or more arguments: ** ** Syntax Mnemonic Description ** ----------- -------- -------------------------- ** 0 END This is the end of the diff ** 1 INTEGER SKIP Skip N lines from both files ** 2 STRING COMMON The line show by STRING is in both files ** 3 STRING INSERT The line STRING is in only the right file ** 4 STRING DELETE The STRING line is in only the left file ** 5 SUBARRAY EDIT One line is different on left and right. ** ** The SUBARRAY is an array of 3*N+1 strings with N>=0. The triples ** represent common-text, left-text, and right-text. The last string ** in SUBARRAY is the common-suffix. Any string can be empty if it does ** not apply. */ static void dfjsonSkip(DiffBuilder *p, unsigned int n, int isFinal){ blob_appendf(p->pOut, "1,%u,\n", n); } static void dfjsonCommon(DiffBuilder *p, const DLine *pLine){ blob_append(p->pOut, "2,",2); blob_append_string_literal(p->pOut, pLine->z, (int)pLine->n); blob_append(p->pOut, ",\n",2); } static void dfjsonInsert(DiffBuilder *p, const DLine *pLine){ blob_append(p->pOut, "3,",2); blob_append_string_literal(p->pOut, pLine->z, (int)pLine->n); blob_append(p->pOut, ",\n",2); } static void dfjsonDelete(DiffBuilder *p, const DLine *pLine){ blob_append(p->pOut, "4,",2); blob_append_string_literal(p->pOut, pLine->z, (int)pLine->n); blob_append(p->pOut, ",\n",2); } static void dfjsonReplace(DiffBuilder *p, const DLine *pX, const DLine *pY){ blob_append(p->pOut, "5,[\"\",",-1); blob_append_string_literal(p->pOut, pX->z, (int)pX->n); blob_append(p->pOut, ",",1); blob_append_string_literal(p->pOut, pY->z, (int)pY->n); blob_append(p->pOut, ",\"\"],\n",-1); } static void dfjsonEdit(DiffBuilder *p, const DLine *pX, const DLine *pY){ int i, x; ChangeSpan span; blob_append(p->pOut, "5,[", 3); oneLineChange(pX, pY, &span); for(i=x=0; i<span.n; i++){ blob_append_string_literal(p->pOut, pX->z + x, span.a[i].iStart1 - x); x = span.a[i].iStart1; blob_append_char(p->pOut, ','); blob_append_string_literal(p->pOut, pX->z + x, span.a[i].iLen1); x += span.a[i].iLen1; blob_append_char(p->pOut, ','); blob_append_string_literal(p->pOut, pY->z + span.a[i].iStart2, span.a[i].iLen2); } blob_append_char(p->pOut, ','); blob_append_string_literal(p->pOut, pX->z + x, pX->n - x); blob_append(p->pOut, "],\n",3); } static void dfjsonEnd(DiffBuilder *p){ blob_append(p->pOut, "0]", 2); fossil_free(p); } static DiffBuilder *dfjsonNew(Blob *pOut){ DiffBuilder *p = fossil_malloc(sizeof(*p)); |
︙ | ︙ | |||
1968 1969 1970 1971 1972 1973 1974 | p->lnLeft = p->lnRight = 0; p->pOut = pOut; blob_append_char(pOut, '['); return p; } /************************* DiffBuilderUnified********************************/ | | > | | 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 | p->lnLeft = p->lnRight = 0; p->pOut = pOut; blob_append_char(pOut, '['); return p; } /************************* DiffBuilderUnified********************************/ /* This module generates a unified diff for HTML ** ** Accumulator strategy: ** ** * Delete line numbers are output directly to p->pOut ** * Insert line numbers accumulate in p->aCol[0]. ** * Separator marks accumulate in p->aCol[1]. ** * Change text accumulates in p->aCol[2]. ** * Pending insert line numbers go into p->aCol[3]. ** * Pending insert text goes into p->aCol[4]. |
︙ | ︙ | |||
2037 2038 2039 2040 2041 2042 2043 | blob_append(p->pOut, "<tr><td class=\"diffln difflne\">" "︙</td><td></td><td></td></tr>\n", -1); } p->lnLeft += n; p->lnRight += n; } static void dfunifiedCommon(DiffBuilder *p, const DLine *pLine){ | < | < | < | < < | < | < | | | | | | | | | 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 | blob_append(p->pOut, "<tr><td class=\"diffln difflne\">" "︙</td><td></td><td></td></tr>\n", -1); } p->lnLeft += n; p->lnRight += n; } static void dfunifiedCommon(DiffBuilder *p, const DLine *pLine){ dfunifiedStartRow(p); dfunifiedFinishDelete(p); dfunifiedFinishInsert(p); p->lnLeft++; p->lnRight++; blob_appendf(p->pOut,"%d\n", p->lnLeft); blob_appendf(&p->aCol[0],"%d\n",p->lnRight); blob_append_char(&p->aCol[1], '\n'); htmlize_to_blob(&p->aCol[2], pLine->z, (int)pLine->n); blob_append_char(&p->aCol[2], '\n'); } static void dfunifiedInsert(DiffBuilder *p, const DLine *pLine){ dfunifiedStartRow(p); p->lnRight++; blob_appendf(&p->aCol[3],"%d\n", p->lnRight); blob_append(&p->aCol[4], "<ins>", 5); htmlize_to_blob(&p->aCol[4], pLine->z, (int)pLine->n); blob_append(&p->aCol[4], "</ins>\n", 7); p->nPending++; } static void dfunifiedDelete(DiffBuilder *p, const DLine *pLine){ dfunifiedStartRow(p); dfunifiedFinishInsert(p); if( p->eState==0 ){ dfunifiedFinishInsert(p); blob_append(p->pOut, "<del>", 5); blob_append(&p->aCol[2], "<del>", 5); p->eState = 1; } p->lnLeft++; blob_appendf(p->pOut,"%d\n", p->lnLeft); blob_append_char(&p->aCol[0],'\n'); blob_append(&p->aCol[1],"-\n",2); blob_append(&p->aCol[2], "<del>", 5); htmlize_to_blob(&p->aCol[2], pLine->z, (int)pLine->n); blob_append(&p->aCol[2], "</del>\n", 7); } static void dfunifiedReplace(DiffBuilder *p, const DLine *pX, const DLine *pY){ dfunifiedStartRow(p); if( p->eState==0 ){ dfunifiedFinishInsert(p); blob_append(p->pOut, "<del>", 5); blob_append(&p->aCol[2], "<del>", 5); p->eState = 1; } p->lnLeft++; p->lnRight++; blob_appendf(p->pOut,"%d\n", p->lnLeft); blob_append_char(&p->aCol[0], '\n'); blob_append(&p->aCol[1], "-\n", 2); htmlize_to_blob(&p->aCol[2], pX->z, pX->n); blob_append_char(&p->aCol[2], '\n'); blob_appendf(&p->aCol[3],"%d\n", p->lnRight); htmlize_to_blob(&p->aCol[4], pY->z, pY->n); blob_append_char(&p->aCol[4], '\n'); p->nPending++; } static void dfunifiedEdit(DiffBuilder *p, const DLine *pX, const DLine *pY){ int i; int x; ChangeSpan span; oneLineChange(pX, pY, &span); dfunifiedStartRow(p); if( p->eState==0 ){ dfunifiedFinishInsert(p); blob_append(p->pOut, "<del>", 5); blob_append(&p->aCol[2], "<del>", 5); p->eState = 1; } p->lnLeft++; p->lnRight++; blob_appendf(p->pOut,"%d\n", p->lnLeft); blob_append_char(&p->aCol[0], '\n'); blob_append(&p->aCol[1], "-\n", 2); for(i=x=0; i<span.n; i++){ int ofst = span.a[i].iStart1; int len = span.a[i].iLen1; if( len ){ htmlize_to_blob(&p->aCol[2], pX->z+x, ofst - x); x = ofst; blob_append(&p->aCol[2], "<del>", 5); htmlize_to_blob(&p->aCol[2], pX->z+x, len); x += len; blob_append(&p->aCol[2], "</del>", 6); } } htmlize_to_blob(&p->aCol[2], pX->z+x, pX->n - x); blob_append_char(&p->aCol[2], '\n'); blob_appendf(&p->aCol[3],"%d\n", p->lnRight); for(i=x=0; i<span.n; i++){ int ofst = span.a[i].iStart2; int len = span.a[i].iLen2; if( len ){ htmlize_to_blob(&p->aCol[4], pY->z+x, ofst - x); x = ofst; blob_append(&p->aCol[4], "<ins>", 5); htmlize_to_blob(&p->aCol[4], pY->z+x, len); x += len; blob_append(&p->aCol[4], "</ins>", 6); } } htmlize_to_blob(&p->aCol[4], pY->z+x, pY->n - x); blob_append_char(&p->aCol[4], '\n'); p->nPending++; } static void dfunifiedEnd(DiffBuilder *p){ dfunifiedFinishRow(p); blob_append(p->pOut, "</table>\n",-1); fossil_free(p); |
︙ | ︙ | |||
2182 2183 2184 2185 2186 2187 2188 | blob_init(&p->aCol[2], 0, 0); blob_init(&p->aCol[3], 0, 0); blob_init(&p->aCol[4], 0, 0); return p; } /************************* DiffBuilderSplit ******************************/ | | > | | 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 | blob_init(&p->aCol[2], 0, 0); blob_init(&p->aCol[3], 0, 0); blob_init(&p->aCol[4], 0, 0); return p; } /************************* DiffBuilderSplit ******************************/ /* This module generates a side-by-side diff for HTML. ** ** Accumulator strategy: ** ** * Left line numbers are output directly to p->pOut ** * Left text accumulates in p->aCol[0]. ** * Edit marks accumulates in p->aCol[1]. ** * Right line numbers accumulate in p->aCol[2]. ** * Right text accumulates in p->aCol[3]. ** |
︙ | ︙ | |||
2249 2250 2251 2252 2253 2254 2255 | "<td class=\"diffln difflnr difflne\">︙</td>" "<td/td></tr>\n", -1); } p->lnLeft += n; p->lnRight += n; } static void dfsplitCommon(DiffBuilder *p, const DLine *pLine){ | < | | < | < | < < | < | < | | | | | | | | | | 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 | "<td class=\"diffln difflnr difflne\">︙</td>" "<td/td></tr>\n", -1); } p->lnLeft += n; p->lnRight += n; } static void dfsplitCommon(DiffBuilder *p, const DLine *pLine){ dfsplitStartRow(p); dfsplitChangeState(p, 0); p->lnLeft++; p->lnRight++; blob_appendf(p->pOut,"%d\n", p->lnLeft); htmlize_to_blob(&p->aCol[0], pLine->z, (int)pLine->n); blob_append_char(&p->aCol[0], '\n'); blob_append_char(&p->aCol[1], '\n'); blob_appendf(&p->aCol[2],"%d\n",p->lnRight); htmlize_to_blob(&p->aCol[3], pLine->z, (int)pLine->n); blob_append_char(&p->aCol[3], '\n'); } static void dfsplitInsert(DiffBuilder *p, const DLine *pLine){ dfsplitStartRow(p); dfsplitChangeState(p, 2); p->lnRight++; blob_append_char(p->pOut, '\n'); blob_append_char(&p->aCol[0], '\n'); blob_append(&p->aCol[1], ">\n", -1); blob_appendf(&p->aCol[2],"%d\n", p->lnRight); blob_append(&p->aCol[3], "<ins>", 5); htmlize_to_blob(&p->aCol[3], pLine->z, (int)pLine->n); blob_append(&p->aCol[3], "</ins>\n", 7); } static void dfsplitDelete(DiffBuilder *p, const DLine *pLine){ dfsplitStartRow(p); dfsplitChangeState(p, 1); p->lnLeft++; blob_appendf(p->pOut,"%d\n", p->lnLeft); blob_append(&p->aCol[0], "<del>", 5); htmlize_to_blob(&p->aCol[0], pLine->z, (int)pLine->n); blob_append(&p->aCol[0], "</del>\n", 7); blob_append(&p->aCol[1], "<\n", -1); blob_append_char(&p->aCol[2],'\n'); blob_append_char(&p->aCol[3],'\n'); } static void dfsplitReplace(DiffBuilder *p, const DLine *pX, const DLine *pY){ dfsplitStartRow(p); dfsplitChangeState(p, 3); p->lnLeft++; p->lnRight++; blob_appendf(p->pOut,"%d\n", p->lnLeft); htmlize_to_blob(&p->aCol[0], pX->z, pX->n); blob_append_char(&p->aCol[0], '\n'); blob_append(&p->aCol[1], "|\n", 2); blob_appendf(&p->aCol[2],"%d\n", p->lnRight); htmlize_to_blob(&p->aCol[3], pY->z, pY->n); blob_append_char(&p->aCol[3], '\n'); } static void dfsplitEdit(DiffBuilder *p, const DLine *pX, const DLine *pY){ int i; int x; ChangeSpan span; oneLineChange(pX, pY, &span); dfsplitStartRow(p); dfsplitChangeState(p, 3); p->lnLeft++; p->lnRight++; blob_appendf(p->pOut,"%d\n", p->lnLeft); for(i=x=0; i<span.n; i++){ int ofst = span.a[i].iStart1; int len = span.a[i].iLen1; if( len ){ htmlize_to_blob(&p->aCol[0], pX->z+x, ofst - x); x = ofst; blob_append(&p->aCol[0], "<del>", 5); htmlize_to_blob(&p->aCol[0], pX->z+x, len); x += len; blob_append(&p->aCol[0], "</del>", 6); } } htmlize_to_blob(&p->aCol[0], pX->z+x, pX->n - x); blob_append_char(&p->aCol[0], '\n'); blob_append(&p->aCol[1], "|\n", 2); blob_appendf(&p->aCol[2],"%d\n", p->lnRight); for(i=x=0; i<span.n; i++){ int ofst = span.a[i].iStart2; int len = span.a[i].iLen2; if( len ){ htmlize_to_blob(&p->aCol[3], pY->z+x, ofst - x); x = ofst; blob_append(&p->aCol[3], "<ins>", 5); htmlize_to_blob(&p->aCol[3], pY->z+x, len); x += len; blob_append(&p->aCol[3], "</ins>", 6); } } htmlize_to_blob(&p->aCol[3], pY->z+x, pY->n - x); blob_append_char(&p->aCol[3], '\n'); } static void dfsplitEnd(DiffBuilder *p){ dfsplitFinishRow(p); blob_append(p->pOut, "</table>\n",-1); fossil_free(p); } |
︙ | ︙ | |||
3210 3211 3212 3213 3214 3215 3216 3217 | if( find_option("debug",0,0)!=0 ) diffFlags |= DIFF_DEBUG; if( find_option("raw",0,0)!=0 ) diffFlags |= DIFF_RAW; return diffFlags; } /* ** COMMAND: test-diff ** | > | > > > > > | > > > > | 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 | if( find_option("debug",0,0)!=0 ) diffFlags |= DIFF_DEBUG; if( find_option("raw",0,0)!=0 ) diffFlags |= DIFF_RAW; return diffFlags; } /* ** COMMAND: test-diff ** COMMAND: xdiff ** ** Usage: %fossil xdiff [options] FILE1 FILE2 ** ** This is the "external diff" feature. By "external" here we mean a diff ** applied to files that are not under version control. See the "diff" ** command for computing differences between files that are under control. ** ** This command prints the differences between the two files FILE1 and FILE2. ** all of the usual diff command-line options apply. See the "diff" command ** for a full list of command-line options. ** ** This command used to be called "test-diff". The older "test-diff" spelling ** still works, for compatibility. */ void test_diff_cmd(void){ Blob a, b, out; u64 diffFlag; const char *zRe; /* Regex filter for diff output */ ReCompiled *pRe = 0; /* Regex filter for diff output */ |
︙ | ︙ |
Changes to src/diffcmd.c.
︙ | ︙ | |||
112 113 114 115 116 117 118 | return 0; } /* ** Print the "Index:" message that patches wants to see at the top of a diff. */ void diff_print_index(const char *zFile, u64 diffFlags, Blob *diffBlob){ | | | 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | return 0; } /* ** Print the "Index:" message that patches wants to see at the top of a diff. */ void diff_print_index(const char *zFile, u64 diffFlags, Blob *diffBlob){ if( (diffFlags & (DIFF_SIDEBYSIDE|DIFF_BRIEF|DIFF_NUMSTAT|DIFF_JSON| DIFF_WEBPAGE|DIFF_TCL))==0 ){ char *z = mprintf("Index: %s\n%.66c\n", zFile, '='); if( !diffBlob ){ fossil_print("%s", z); }else{ blob_appendf(diffBlob, "%s", z); } |
︙ | ︙ | |||
134 135 136 137 138 139 140 | void diff_print_filenames( const char *zLeft, const char *zRight, u64 diffFlags, Blob *diffBlob ){ char *z = 0; | | | | | 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | void diff_print_filenames( const char *zLeft, const char *zRight, u64 diffFlags, Blob *diffBlob ){ char *z = 0; if( diffFlags & (DIFF_BRIEF|DIFF_RAW|DIFF_JSON) ){ /* no-op */ }else if( diffFlags & DIFF_DEBUG ){ fossil_print("FILE-LEFT %s\nFILE-RIGHT %s\n", zLeft, zRight); }else if( diffFlags & DIFF_WEBPAGE ){ if( fossil_strcmp(zLeft,zRight)==0 ){ z = mprintf("<h1>%h</h1>\n", zLeft); }else{ z = mprintf("<h1>%h ⇆ %h</h1>\n", zLeft, zRight); } }else if( diffFlags & DIFF_TCL ){ Blob *pOut; Blob x; if( diffBlob ){ pOut = diffBlob; }else{ blob_init(&x, 0, 0); pOut = &x; } blob_append(pOut, "FILE ", 5); blob_append_string_literal(pOut, zLeft, (int)strlen(zLeft)); blob_append_char(pOut, ' '); blob_append_string_literal(pOut, zRight, (int)strlen(zRight)); blob_append_char(pOut, '\n'); if( !diffBlob ){ fossil_print("%s", blob_str(pOut)); blob_reset(&x); } return; }else if( diffFlags & DIFF_SIDEBYSIDE ){ |
︙ | ︙ |