Fossil SCM

More accurate determination of whether or not a setting is set to its default value, for display purpose with the --changes option.

drh 2025-03-20 18:10 trunk
Commit bff93fc819b904d659192be643b6df2693348bdd8bb0f9724aa4b485f34ba760
2 files changed +17 -14 +6 -9
+17 -14
--- src/db.c
+++ src/db.c
@@ -4428,10 +4428,26 @@
44284428
}
44294429
}
44304430
g.argc = 2;
44314431
info_cmd();
44324432
}
4433
+
4434
+/*
4435
+** Return true if pSetting has its default value assuming its
4436
+** current value is zVal.
4437
+*/
4438
+int setting_has_default_value(const Setting *pSetting, const char *zVal){
4439
+ if( zVal==0 ) return 1;
4440
+ if( pSetting->def==0 ) return 0;
4441
+ if( pSetting->width==0 ){
4442
+ return is_false(pSetting->def)==is_false(zVal);
4443
+ }
4444
+ if( fossil_strcmp(pSetting->def, zVal)==0 ) return 1;
4445
+ if( is_false(zVal) && is_false(pSetting->def) ) return 1;
4446
+ if( is_truth(zVal) && is_truth(pSetting->def) ) return 1;
4447
+ return 0;
4448
+}
44334449
44344450
/*
44354451
** Print the current value of a setting identified by the pSetting
44364452
** pointer.
44374453
**
@@ -4476,24 +4492,11 @@
44764492
pSetting->name
44774493
);
44784494
}
44794495
if( db_step(&q)==SQLITE_ROW ){
44804496
const char *zVal = db_column_text(&q,1);
4481
- int noShow = 0;
4482
- if( bIfChng ){
4483
- /* Don't display the value is equal to the default */
4484
- if( zVal==0 ){
4485
- noShow = 1;
4486
- }else if( pSetting->def ){
4487
- if( pSetting->width==0 ){
4488
- if( is_false(zVal) && is_false(pSetting->def) ) noShow = 1;
4489
- }else{
4490
- if( fossil_strcmp(zVal, pSetting->def)==0 ) noShow = 1;
4491
- }
4492
- }
4493
- }
4494
- if( noShow ){
4497
+ if( bIfChng && setting_has_default_value(pSetting,zVal) ){
44954498
if( versioned ){
44964499
fossil_print("%-24s (versioned)\n", pSetting->name);
44974500
versioned = 0;
44984501
}
44994502
}else if( valueOnly ){
45004503
--- src/db.c
+++ src/db.c
@@ -4428,10 +4428,26 @@
4428 }
4429 }
4430 g.argc = 2;
4431 info_cmd();
4432 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4433
4434 /*
4435 ** Print the current value of a setting identified by the pSetting
4436 ** pointer.
4437 **
@@ -4476,24 +4492,11 @@
4476 pSetting->name
4477 );
4478 }
4479 if( db_step(&q)==SQLITE_ROW ){
4480 const char *zVal = db_column_text(&q,1);
4481 int noShow = 0;
4482 if( bIfChng ){
4483 /* Don't display the value is equal to the default */
4484 if( zVal==0 ){
4485 noShow = 1;
4486 }else if( pSetting->def ){
4487 if( pSetting->width==0 ){
4488 if( is_false(zVal) && is_false(pSetting->def) ) noShow = 1;
4489 }else{
4490 if( fossil_strcmp(zVal, pSetting->def)==0 ) noShow = 1;
4491 }
4492 }
4493 }
4494 if( noShow ){
4495 if( versioned ){
4496 fossil_print("%-24s (versioned)\n", pSetting->name);
4497 versioned = 0;
4498 }
4499 }else if( valueOnly ){
4500
--- src/db.c
+++ src/db.c
@@ -4428,10 +4428,26 @@
4428 }
4429 }
4430 g.argc = 2;
4431 info_cmd();
4432 }
4433
4434 /*
4435 ** Return true if pSetting has its default value assuming its
4436 ** current value is zVal.
4437 */
4438 int setting_has_default_value(const Setting *pSetting, const char *zVal){
4439 if( zVal==0 ) return 1;
4440 if( pSetting->def==0 ) return 0;
4441 if( pSetting->width==0 ){
4442 return is_false(pSetting->def)==is_false(zVal);
4443 }
4444 if( fossil_strcmp(pSetting->def, zVal)==0 ) return 1;
4445 if( is_false(zVal) && is_false(pSetting->def) ) return 1;
4446 if( is_truth(zVal) && is_truth(pSetting->def) ) return 1;
4447 return 0;
4448 }
4449
4450 /*
4451 ** Print the current value of a setting identified by the pSetting
4452 ** pointer.
4453 **
@@ -4476,24 +4492,11 @@
4492 pSetting->name
4493 );
4494 }
4495 if( db_step(&q)==SQLITE_ROW ){
4496 const char *zVal = db_column_text(&q,1);
4497 if( bIfChng && setting_has_default_value(pSetting,zVal) ){
 
 
 
 
 
 
 
 
 
 
 
 
 
4498 if( versioned ){
4499 fossil_print("%-24s (versioned)\n", pSetting->name);
4500 versioned = 0;
4501 }
4502 }else if( valueOnly ){
4503
+6 -9
--- src/setup.c
+++ src/setup.c
@@ -1149,13 +1149,12 @@
11491149
login_insert_csrf_secret();
11501150
for(i=0, pSet=aSetting; i<nSetting; i++, pSet++){
11511151
if( pSet->width==0 ){
11521152
int hasVersionableValue = pSet->versionable &&
11531153
(db_get_versioned(pSet->name, NULL, NULL)!=0);
1154
- if( bIfChng ){
1155
- const char *zVal = db_get(pSet->name, 0);
1156
- if( zVal==0 || is_false(zVal)==is_false(pSet->def) ) continue;
1154
+ if( bIfChng && setting_has_default_value(pSet, db_get(pSet->name,0)) ){
1155
+ continue;
11571156
}
11581157
onoff_attribute("", pSet->name,
11591158
pSet->var!=0 ? pSet->var : pSet->name /*works-like:"x"*/,
11601159
is_truth(pSet->def), hasVersionableValue);
11611160
@ <a href='%R/help?cmd=%s(pSet->name)'>%h(pSet->name)</a>
@@ -1171,13 +1170,12 @@
11711170
@ <table>
11721171
for(i=0, pSet=aSetting; i<nSetting; i++, pSet++){
11731172
if( pSet->width>0 && !pSet->forceTextArea ){
11741173
int hasVersionableValue = pSet->versionable &&
11751174
(db_get_versioned(pSet->name, NULL, NULL)!=0);
1176
- if( bIfChng ){
1177
- const char *zVal = db_get(pSet->name, 0);
1178
- if( zVal==0 || fossil_strcmp(zVal,pSet->def)==0 ) continue;
1175
+ if( bIfChng && setting_has_default_value(pSet, db_get(pSet->name,0)) ){
1176
+ continue;
11791177
}
11801178
@ <tr><td>
11811179
@ <a href='%R/help?cmd=%s(pSet->name)'>%h(pSet->name)</a>
11821180
if( pSet->versionable ){
11831181
@ (v)
@@ -1194,13 +1192,12 @@
11941192
@</table>
11951193
@ </td><td style="width:50px;"></td><td valign="top">
11961194
for(i=0, pSet=aSetting; i<nSetting; i++, pSet++){
11971195
if( pSet->width>0 && pSet->forceTextArea ){
11981196
int hasVersionableValue = db_get_versioned(pSet->name, NULL, NULL)!=0;
1199
- if( bIfChng ){
1200
- const char *zVal = db_get(pSet->name, 0);
1201
- if( zVal==0 || fossil_strcmp(zVal,pSet->def)==0 ) continue;
1197
+ if( bIfChng && setting_has_default_value(pSet, db_get(pSet->name,0)) ){
1198
+ continue;
12021199
}
12031200
@ <a href='%R/help?cmd=%s(pSet->name)'>%s(pSet->name)</a>
12041201
if( pSet->versionable ){
12051202
@ (v)<br>
12061203
} else {
12071204
--- src/setup.c
+++ src/setup.c
@@ -1149,13 +1149,12 @@
1149 login_insert_csrf_secret();
1150 for(i=0, pSet=aSetting; i<nSetting; i++, pSet++){
1151 if( pSet->width==0 ){
1152 int hasVersionableValue = pSet->versionable &&
1153 (db_get_versioned(pSet->name, NULL, NULL)!=0);
1154 if( bIfChng ){
1155 const char *zVal = db_get(pSet->name, 0);
1156 if( zVal==0 || is_false(zVal)==is_false(pSet->def) ) continue;
1157 }
1158 onoff_attribute("", pSet->name,
1159 pSet->var!=0 ? pSet->var : pSet->name /*works-like:"x"*/,
1160 is_truth(pSet->def), hasVersionableValue);
1161 @ <a href='%R/help?cmd=%s(pSet->name)'>%h(pSet->name)</a>
@@ -1171,13 +1170,12 @@
1171 @ <table>
1172 for(i=0, pSet=aSetting; i<nSetting; i++, pSet++){
1173 if( pSet->width>0 && !pSet->forceTextArea ){
1174 int hasVersionableValue = pSet->versionable &&
1175 (db_get_versioned(pSet->name, NULL, NULL)!=0);
1176 if( bIfChng ){
1177 const char *zVal = db_get(pSet->name, 0);
1178 if( zVal==0 || fossil_strcmp(zVal,pSet->def)==0 ) continue;
1179 }
1180 @ <tr><td>
1181 @ <a href='%R/help?cmd=%s(pSet->name)'>%h(pSet->name)</a>
1182 if( pSet->versionable ){
1183 @ (v)
@@ -1194,13 +1192,12 @@
1194 @</table>
1195 @ </td><td style="width:50px;"></td><td valign="top">
1196 for(i=0, pSet=aSetting; i<nSetting; i++, pSet++){
1197 if( pSet->width>0 && pSet->forceTextArea ){
1198 int hasVersionableValue = db_get_versioned(pSet->name, NULL, NULL)!=0;
1199 if( bIfChng ){
1200 const char *zVal = db_get(pSet->name, 0);
1201 if( zVal==0 || fossil_strcmp(zVal,pSet->def)==0 ) continue;
1202 }
1203 @ <a href='%R/help?cmd=%s(pSet->name)'>%s(pSet->name)</a>
1204 if( pSet->versionable ){
1205 @ (v)<br>
1206 } else {
1207
--- src/setup.c
+++ src/setup.c
@@ -1149,13 +1149,12 @@
1149 login_insert_csrf_secret();
1150 for(i=0, pSet=aSetting; i<nSetting; i++, pSet++){
1151 if( pSet->width==0 ){
1152 int hasVersionableValue = pSet->versionable &&
1153 (db_get_versioned(pSet->name, NULL, NULL)!=0);
1154 if( bIfChng && setting_has_default_value(pSet, db_get(pSet->name,0)) ){
1155 continue;
 
1156 }
1157 onoff_attribute("", pSet->name,
1158 pSet->var!=0 ? pSet->var : pSet->name /*works-like:"x"*/,
1159 is_truth(pSet->def), hasVersionableValue);
1160 @ <a href='%R/help?cmd=%s(pSet->name)'>%h(pSet->name)</a>
@@ -1171,13 +1170,12 @@
1170 @ <table>
1171 for(i=0, pSet=aSetting; i<nSetting; i++, pSet++){
1172 if( pSet->width>0 && !pSet->forceTextArea ){
1173 int hasVersionableValue = pSet->versionable &&
1174 (db_get_versioned(pSet->name, NULL, NULL)!=0);
1175 if( bIfChng && setting_has_default_value(pSet, db_get(pSet->name,0)) ){
1176 continue;
 
1177 }
1178 @ <tr><td>
1179 @ <a href='%R/help?cmd=%s(pSet->name)'>%h(pSet->name)</a>
1180 if( pSet->versionable ){
1181 @ (v)
@@ -1194,13 +1192,12 @@
1192 @</table>
1193 @ </td><td style="width:50px;"></td><td valign="top">
1194 for(i=0, pSet=aSetting; i<nSetting; i++, pSet++){
1195 if( pSet->width>0 && pSet->forceTextArea ){
1196 int hasVersionableValue = db_get_versioned(pSet->name, NULL, NULL)!=0;
1197 if( bIfChng && setting_has_default_value(pSet, db_get(pSet->name,0)) ){
1198 continue;
 
1199 }
1200 @ <a href='%R/help?cmd=%s(pSet->name)'>%s(pSet->name)</a>
1201 if( pSet->versionable ){
1202 @ (v)<br>
1203 } else {
1204

Keyboard Shortcuts

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