Fossil SCM
More accurate determination of whether or not a setting is set to its default value, for display purpose with the --changes option.
Commit
bff93fc819b904d659192be643b6df2693348bdd8bb0f9724aa4b485f34ba760
Parent
ea37cc8ed2f0f86…
2 files changed
+17
-14
+6
-9
M
src/db.c
+17
-14
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -4428,10 +4428,26 @@ | ||
| 4428 | 4428 | } |
| 4429 | 4429 | } |
| 4430 | 4430 | g.argc = 2; |
| 4431 | 4431 | info_cmd(); |
| 4432 | 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 | +} | |
| 4433 | 4449 | |
| 4434 | 4450 | /* |
| 4435 | 4451 | ** Print the current value of a setting identified by the pSetting |
| 4436 | 4452 | ** pointer. |
| 4437 | 4453 | ** |
| @@ -4476,24 +4492,11 @@ | ||
| 4476 | 4492 | pSetting->name |
| 4477 | 4493 | ); |
| 4478 | 4494 | } |
| 4479 | 4495 | if( db_step(&q)==SQLITE_ROW ){ |
| 4480 | 4496 | 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) ){ | |
| 4495 | 4498 | if( versioned ){ |
| 4496 | 4499 | fossil_print("%-24s (versioned)\n", pSetting->name); |
| 4497 | 4500 | versioned = 0; |
| 4498 | 4501 | } |
| 4499 | 4502 | }else if( valueOnly ){ |
| 4500 | 4503 |
| --- 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 @@ | ||
| 1149 | 1149 | login_insert_csrf_secret(); |
| 1150 | 1150 | for(i=0, pSet=aSetting; i<nSetting; i++, pSet++){ |
| 1151 | 1151 | if( pSet->width==0 ){ |
| 1152 | 1152 | int hasVersionableValue = pSet->versionable && |
| 1153 | 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; | |
| 1154 | + if( bIfChng && setting_has_default_value(pSet, db_get(pSet->name,0)) ){ | |
| 1155 | + continue; | |
| 1157 | 1156 | } |
| 1158 | 1157 | onoff_attribute("", pSet->name, |
| 1159 | 1158 | pSet->var!=0 ? pSet->var : pSet->name /*works-like:"x"*/, |
| 1160 | 1159 | is_truth(pSet->def), hasVersionableValue); |
| 1161 | 1160 | @ <a href='%R/help?cmd=%s(pSet->name)'>%h(pSet->name)</a> |
| @@ -1171,13 +1170,12 @@ | ||
| 1171 | 1170 | @ <table> |
| 1172 | 1171 | for(i=0, pSet=aSetting; i<nSetting; i++, pSet++){ |
| 1173 | 1172 | if( pSet->width>0 && !pSet->forceTextArea ){ |
| 1174 | 1173 | int hasVersionableValue = pSet->versionable && |
| 1175 | 1174 | (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; | |
| 1179 | 1177 | } |
| 1180 | 1178 | @ <tr><td> |
| 1181 | 1179 | @ <a href='%R/help?cmd=%s(pSet->name)'>%h(pSet->name)</a> |
| 1182 | 1180 | if( pSet->versionable ){ |
| 1183 | 1181 | @ (v) |
| @@ -1194,13 +1192,12 @@ | ||
| 1194 | 1192 | @</table> |
| 1195 | 1193 | @ </td><td style="width:50px;"></td><td valign="top"> |
| 1196 | 1194 | for(i=0, pSet=aSetting; i<nSetting; i++, pSet++){ |
| 1197 | 1195 | if( pSet->width>0 && pSet->forceTextArea ){ |
| 1198 | 1196 | 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; | |
| 1202 | 1199 | } |
| 1203 | 1200 | @ <a href='%R/help?cmd=%s(pSet->name)'>%s(pSet->name)</a> |
| 1204 | 1201 | if( pSet->versionable ){ |
| 1205 | 1202 | @ (v)<br> |
| 1206 | 1203 | } else { |
| 1207 | 1204 |
| --- 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 |