Fossil SCM

Fix diffs that use the DIFF_IGNORE_EOLWS flag. Add a message for diffs that involve only EOL whitespace changes.

joel 2014-03-03 06:44 trunk
Commit 8f885df20975e896aad7ff7c6cac794e97880e78
1 file changed +10 -4
+10 -4
--- src/diff.c
+++ src/diff.c
@@ -54,10 +54,13 @@
5454
"cannot compute difference between symlink and regular file\n"
5555
5656
#define DIFF_TOO_MANY_CHANGES \
5757
"more than 10,000 changes\n"
5858
59
+#define DIFF_EOLWS_ONLY \
60
+ "only end-of-line whitespace changed\n"
61
+
5962
/*
6063
** Maximum length of a line in a text file, in bytes. (2**13 = 8192 bytes)
6164
*/
6265
#define LENGTH_MASK_SZ 13
6366
#define LENGTH_MASK ((1<<LENGTH_MASK_SZ)-1)
@@ -162,14 +165,14 @@
162165
for(i=0; i<nLine; i++){
163166
a[i].z = z;
164167
for(j=0; z[j] && z[j]!='\n'; j++){}
165168
k = j;
166169
while( ignoreWS && k>0 && fossil_isspace(z[k-1]) ){ k--; }
167
- for(h=0, x=0; x<=k; x++){
170
+ for(h=0, x=0; x<k; x++){
168171
h = h ^ (h<<2) ^ z[x];
169172
}
170
- a[i].h = h = (h<<LENGTH_MASK_SZ) | k;;
173
+ a[i].h = h = (h<<LENGTH_MASK_SZ) | k;
171174
h2 = h % nLine;
172175
a[i].iNext = a[h2].iHash;
173176
a[h2].iHash = i+1;
174177
z += j+1;
175178
}
@@ -1787,15 +1790,18 @@
17871790
if( (diffFlags & DIFF_NOTTOOBIG)!=0 ){
17881791
int i, m, n;
17891792
int *a = c.aEdit;
17901793
int mx = c.nEdit;
17911794
for(i=m=n=0; i<mx; i+=3){ m += a[i]; n += a[i+1]+a[i+2]; }
1792
- if( n>10000 ){
1795
+ if( n==0 || n>10000 ){
17931796
fossil_free(c.aFrom);
17941797
fossil_free(c.aTo);
17951798
fossil_free(c.aEdit);
1796
- diff_errmsg(pOut, DIFF_TOO_MANY_CHANGES, diffFlags);
1799
+ if( pOut ) {
1800
+ diff_errmsg(pOut, n==0 ? DIFF_EOLWS_ONLY : DIFF_TOO_MANY_CHANGES,
1801
+ diffFlags);
1802
+ }
17971803
return 0;
17981804
}
17991805
}
18001806
if( (diffFlags & DIFF_NOOPT)==0 ){
18011807
diff_optimize(&c);
18021808
--- src/diff.c
+++ src/diff.c
@@ -54,10 +54,13 @@
54 "cannot compute difference between symlink and regular file\n"
55
56 #define DIFF_TOO_MANY_CHANGES \
57 "more than 10,000 changes\n"
58
 
 
 
59 /*
60 ** Maximum length of a line in a text file, in bytes. (2**13 = 8192 bytes)
61 */
62 #define LENGTH_MASK_SZ 13
63 #define LENGTH_MASK ((1<<LENGTH_MASK_SZ)-1)
@@ -162,14 +165,14 @@
162 for(i=0; i<nLine; i++){
163 a[i].z = z;
164 for(j=0; z[j] && z[j]!='\n'; j++){}
165 k = j;
166 while( ignoreWS && k>0 && fossil_isspace(z[k-1]) ){ k--; }
167 for(h=0, x=0; x<=k; x++){
168 h = h ^ (h<<2) ^ z[x];
169 }
170 a[i].h = h = (h<<LENGTH_MASK_SZ) | k;;
171 h2 = h % nLine;
172 a[i].iNext = a[h2].iHash;
173 a[h2].iHash = i+1;
174 z += j+1;
175 }
@@ -1787,15 +1790,18 @@
1787 if( (diffFlags & DIFF_NOTTOOBIG)!=0 ){
1788 int i, m, n;
1789 int *a = c.aEdit;
1790 int mx = c.nEdit;
1791 for(i=m=n=0; i<mx; i+=3){ m += a[i]; n += a[i+1]+a[i+2]; }
1792 if( n>10000 ){
1793 fossil_free(c.aFrom);
1794 fossil_free(c.aTo);
1795 fossil_free(c.aEdit);
1796 diff_errmsg(pOut, DIFF_TOO_MANY_CHANGES, diffFlags);
 
 
 
1797 return 0;
1798 }
1799 }
1800 if( (diffFlags & DIFF_NOOPT)==0 ){
1801 diff_optimize(&c);
1802
--- src/diff.c
+++ src/diff.c
@@ -54,10 +54,13 @@
54 "cannot compute difference between symlink and regular file\n"
55
56 #define DIFF_TOO_MANY_CHANGES \
57 "more than 10,000 changes\n"
58
59 #define DIFF_EOLWS_ONLY \
60 "only end-of-line whitespace changed\n"
61
62 /*
63 ** Maximum length of a line in a text file, in bytes. (2**13 = 8192 bytes)
64 */
65 #define LENGTH_MASK_SZ 13
66 #define LENGTH_MASK ((1<<LENGTH_MASK_SZ)-1)
@@ -162,14 +165,14 @@
165 for(i=0; i<nLine; i++){
166 a[i].z = z;
167 for(j=0; z[j] && z[j]!='\n'; j++){}
168 k = j;
169 while( ignoreWS && k>0 && fossil_isspace(z[k-1]) ){ k--; }
170 for(h=0, x=0; x<k; x++){
171 h = h ^ (h<<2) ^ z[x];
172 }
173 a[i].h = h = (h<<LENGTH_MASK_SZ) | k;
174 h2 = h % nLine;
175 a[i].iNext = a[h2].iHash;
176 a[h2].iHash = i+1;
177 z += j+1;
178 }
@@ -1787,15 +1790,18 @@
1790 if( (diffFlags & DIFF_NOTTOOBIG)!=0 ){
1791 int i, m, n;
1792 int *a = c.aEdit;
1793 int mx = c.nEdit;
1794 for(i=m=n=0; i<mx; i+=3){ m += a[i]; n += a[i+1]+a[i+2]; }
1795 if( n==0 || n>10000 ){
1796 fossil_free(c.aFrom);
1797 fossil_free(c.aTo);
1798 fossil_free(c.aEdit);
1799 if( pOut ) {
1800 diff_errmsg(pOut, n==0 ? DIFF_EOLWS_ONLY : DIFF_TOO_MANY_CHANGES,
1801 diffFlags);
1802 }
1803 return 0;
1804 }
1805 }
1806 if( (diffFlags & DIFF_NOOPT)==0 ){
1807 diff_optimize(&c);
1808

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button