Fossil SCM

Show numstat-style statistics in the 'Changes' section of /info and friends.

danield 2025-08-06 10:30 trunk merge
Commit 18151a86152e50e9df8001a08ed19def1e0a02dad058a7bae92586f2757d7322
2 files changed +15 -9 +8 -1
+15 -9
--- src/diff.c
+++ src/diff.c
@@ -3085,10 +3085,11 @@
30853085
Blob *pOut, /* Write diff here if not NULL */
30863086
DiffConfig *pCfg /* Configuration options */
30873087
){
30883088
int ignoreWs; /* Ignore whitespace */
30893089
DContext c;
3090
+ int nDel = 0, nIns = 0;
30903091
30913092
if( pCfg->diffFlags & DIFF_INVERT ){
30923093
Blob *pTemp = pA_Blob;
30933094
pA_Blob = pB_Blob;
30943095
pB_Blob = pTemp;
@@ -3163,22 +3164,27 @@
31633164
c.aEdit[i+1] = sum;
31643165
for(k=0, sum=0; k<c.aEdit[i+2]; k++) sum += c.aTo[iB++].n;
31653166
c.aEdit[i+2] = sum;
31663167
}
31673168
}
3169
+
3170
+ if( pCfg->diffFlags & DIFF_NUMSTAT ){
3171
+ int i;
3172
+ for(i=0; c.aEdit[i] || c.aEdit[i+1] || c.aEdit[i+2]; i+=3){
3173
+ nDel += c.aEdit[i+1];
3174
+ nIns += c.aEdit[i+2];
3175
+ }
3176
+ g.diffCnt[1] += nIns;
3177
+ g.diffCnt[2] += nDel;
3178
+ if( nIns+nDel ){
3179
+ g.diffCnt[0]++;
3180
+ }
3181
+ }
31683182
31693183
if( pOut ){
3170
- if( pCfg->diffFlags & DIFF_NUMSTAT ){
3171
- int nDel = 0, nIns = 0, i;
3172
- for(i=0; c.aEdit[i] || c.aEdit[i+1] || c.aEdit[i+2]; i+=3){
3173
- nDel += c.aEdit[i+1];
3174
- nIns += c.aEdit[i+2];
3175
- }
3176
- g.diffCnt[1] += nIns;
3177
- g.diffCnt[2] += nDel;
3184
+ if( pCfg->diffFlags & DIFF_NUMSTAT && !(pCfg->diffFlags & DIFF_HTML)){
31783185
if( nIns+nDel ){
3179
- g.diffCnt[0]++;
31803186
if( !(pCfg->diffFlags & DIFF_BRIEF) ){
31813187
blob_appendf(pOut, "%10d %10d", nIns, nDel);
31823188
}
31833189
}
31843190
}else if( pCfg->diffFlags & (DIFF_RAW|DIFF_BY_TOKEN) ){
31853191
--- src/diff.c
+++ src/diff.c
@@ -3085,10 +3085,11 @@
3085 Blob *pOut, /* Write diff here if not NULL */
3086 DiffConfig *pCfg /* Configuration options */
3087 ){
3088 int ignoreWs; /* Ignore whitespace */
3089 DContext c;
 
3090
3091 if( pCfg->diffFlags & DIFF_INVERT ){
3092 Blob *pTemp = pA_Blob;
3093 pA_Blob = pB_Blob;
3094 pB_Blob = pTemp;
@@ -3163,22 +3164,27 @@
3163 c.aEdit[i+1] = sum;
3164 for(k=0, sum=0; k<c.aEdit[i+2]; k++) sum += c.aTo[iB++].n;
3165 c.aEdit[i+2] = sum;
3166 }
3167 }
 
 
 
 
 
 
 
 
 
 
 
 
 
3168
3169 if( pOut ){
3170 if( pCfg->diffFlags & DIFF_NUMSTAT ){
3171 int nDel = 0, nIns = 0, i;
3172 for(i=0; c.aEdit[i] || c.aEdit[i+1] || c.aEdit[i+2]; i+=3){
3173 nDel += c.aEdit[i+1];
3174 nIns += c.aEdit[i+2];
3175 }
3176 g.diffCnt[1] += nIns;
3177 g.diffCnt[2] += nDel;
3178 if( nIns+nDel ){
3179 g.diffCnt[0]++;
3180 if( !(pCfg->diffFlags & DIFF_BRIEF) ){
3181 blob_appendf(pOut, "%10d %10d", nIns, nDel);
3182 }
3183 }
3184 }else if( pCfg->diffFlags & (DIFF_RAW|DIFF_BY_TOKEN) ){
3185
--- src/diff.c
+++ src/diff.c
@@ -3085,10 +3085,11 @@
3085 Blob *pOut, /* Write diff here if not NULL */
3086 DiffConfig *pCfg /* Configuration options */
3087 ){
3088 int ignoreWs; /* Ignore whitespace */
3089 DContext c;
3090 int nDel = 0, nIns = 0;
3091
3092 if( pCfg->diffFlags & DIFF_INVERT ){
3093 Blob *pTemp = pA_Blob;
3094 pA_Blob = pB_Blob;
3095 pB_Blob = pTemp;
@@ -3163,22 +3164,27 @@
3164 c.aEdit[i+1] = sum;
3165 for(k=0, sum=0; k<c.aEdit[i+2]; k++) sum += c.aTo[iB++].n;
3166 c.aEdit[i+2] = sum;
3167 }
3168 }
3169
3170 if( pCfg->diffFlags & DIFF_NUMSTAT ){
3171 int i;
3172 for(i=0; c.aEdit[i] || c.aEdit[i+1] || c.aEdit[i+2]; i+=3){
3173 nDel += c.aEdit[i+1];
3174 nIns += c.aEdit[i+2];
3175 }
3176 g.diffCnt[1] += nIns;
3177 g.diffCnt[2] += nDel;
3178 if( nIns+nDel ){
3179 g.diffCnt[0]++;
3180 }
3181 }
3182
3183 if( pOut ){
3184 if( pCfg->diffFlags & DIFF_NUMSTAT && !(pCfg->diffFlags & DIFF_HTML)){
 
 
 
 
 
 
 
3185 if( nIns+nDel ){
 
3186 if( !(pCfg->diffFlags & DIFF_BRIEF) ){
3187 blob_appendf(pOut, "%10d %10d", nIns, nDel);
3188 }
3189 }
3190 }else if( pCfg->diffFlags & (DIFF_RAW|DIFF_BY_TOKEN) ){
3191
+8 -1
--- src/info.c
+++ src/info.c
@@ -1167,15 +1167,16 @@
11671167
}
11681168
render_backlink_graph(zUuid,
11691169
"<div class=\"section accordion\">References</div>\n");
11701170
@ <div class="section accordion">Context</div><div class="accordion_panel">
11711171
render_checkin_context(rid, 0, 0, 0);
1172
- @ </div><div class="section accordion">Changes</div>
1172
+ @ </div><div class="section accordion" id="changes_section">Changes</div>
11731173
@ <div class="accordion_panel">
11741174
@ <div class="sectionmenu info-changes-menu">
11751175
/* ^^^ .info-changes-menu is used by diff scroll sync */
11761176
pCfg = construct_diff_flags(diffType, &DCfg);
1177
+ DCfg.diffFlags |= DIFF_NUMSTAT; /* Show stats in the 'Changes' section */
11771178
DCfg.pRe = pRe;
11781179
zW = (DCfg.diffFlags&DIFF_IGNORE_ALLWS)?"&w":"";
11791180
if( diffType!=1 ){
11801181
@ %z(chref("button","%R/%s/%T?diff=1%s",zPage,zName,zW))\
11811182
@ Unified&nbsp;Diff</a>
@@ -1227,10 +1228,16 @@
12271228
append_file_change_line(zUuid, zName, zOld, zNew, zOldName,
12281229
pCfg,mperm);
12291230
}
12301231
db_finalize(&q3);
12311232
@ </div>
1233
+ @ <script nonce='%h(style_nonce())'>;/* info.c:%d(__LINE__) */
1234
+ @ document.getElementById('changes_section').textContent = 'Changes ' +
1235
+ @ '(%d(g.diffCnt[0]) file' + (%d(g.diffCnt[0])===1 ? '' : 's') + ': ' +
1236
+ @ '+%d(g.diffCnt[1]) ' +
1237
+ @ '−%d(g.diffCnt[2]))'
1238
+ @ </script>
12321239
append_diff_javascript(diffType);
12331240
style_finish_page();
12341241
}
12351242
12361243
/*
12371244
--- src/info.c
+++ src/info.c
@@ -1167,15 +1167,16 @@
1167 }
1168 render_backlink_graph(zUuid,
1169 "<div class=\"section accordion\">References</div>\n");
1170 @ <div class="section accordion">Context</div><div class="accordion_panel">
1171 render_checkin_context(rid, 0, 0, 0);
1172 @ </div><div class="section accordion">Changes</div>
1173 @ <div class="accordion_panel">
1174 @ <div class="sectionmenu info-changes-menu">
1175 /* ^^^ .info-changes-menu is used by diff scroll sync */
1176 pCfg = construct_diff_flags(diffType, &DCfg);
 
1177 DCfg.pRe = pRe;
1178 zW = (DCfg.diffFlags&DIFF_IGNORE_ALLWS)?"&w":"";
1179 if( diffType!=1 ){
1180 @ %z(chref("button","%R/%s/%T?diff=1%s",zPage,zName,zW))\
1181 @ Unified&nbsp;Diff</a>
@@ -1227,10 +1228,16 @@
1227 append_file_change_line(zUuid, zName, zOld, zNew, zOldName,
1228 pCfg,mperm);
1229 }
1230 db_finalize(&q3);
1231 @ </div>
 
 
 
 
 
 
1232 append_diff_javascript(diffType);
1233 style_finish_page();
1234 }
1235
1236 /*
1237
--- src/info.c
+++ src/info.c
@@ -1167,15 +1167,16 @@
1167 }
1168 render_backlink_graph(zUuid,
1169 "<div class=\"section accordion\">References</div>\n");
1170 @ <div class="section accordion">Context</div><div class="accordion_panel">
1171 render_checkin_context(rid, 0, 0, 0);
1172 @ </div><div class="section accordion" id="changes_section">Changes</div>
1173 @ <div class="accordion_panel">
1174 @ <div class="sectionmenu info-changes-menu">
1175 /* ^^^ .info-changes-menu is used by diff scroll sync */
1176 pCfg = construct_diff_flags(diffType, &DCfg);
1177 DCfg.diffFlags |= DIFF_NUMSTAT; /* Show stats in the 'Changes' section */
1178 DCfg.pRe = pRe;
1179 zW = (DCfg.diffFlags&DIFF_IGNORE_ALLWS)?"&w":"";
1180 if( diffType!=1 ){
1181 @ %z(chref("button","%R/%s/%T?diff=1%s",zPage,zName,zW))\
1182 @ Unified&nbsp;Diff</a>
@@ -1227,10 +1228,16 @@
1228 append_file_change_line(zUuid, zName, zOld, zNew, zOldName,
1229 pCfg,mperm);
1230 }
1231 db_finalize(&q3);
1232 @ </div>
1233 @ <script nonce='%h(style_nonce())'>;/* info.c:%d(__LINE__) */
1234 @ document.getElementById('changes_section').textContent = 'Changes ' +
1235 @ '(%d(g.diffCnt[0]) file' + (%d(g.diffCnt[0])===1 ? '' : 's') + ': ' +
1236 @ '+%d(g.diffCnt[1]) ' +
1237 @ '−%d(g.diffCnt[2]))'
1238 @ </script>
1239 append_diff_javascript(diffType);
1240 style_finish_page();
1241 }
1242
1243 /*
1244

Keyboard Shortcuts

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