Fossil SCM

merge in fossil-settings-value-only

preben 2023-09-29 13:35 trunk
Commit 0d4a31a9f536cde490f86647c0e9db0ae50023f391b11a5a8c6be2ccf257a676
2 files changed +2 -2 +38 -16
+2 -2
--- src/alerts.c
+++ src/alerts.c
@@ -1257,11 +1257,11 @@
12571257
g.argc = 3;
12581258
}
12591259
pSetting = setting_info(&nSetting);
12601260
for(; nSetting>0; nSetting--, pSetting++ ){
12611261
if( strncmp(pSetting->name,"email-",6)!=0 ) continue;
1262
- print_setting(pSetting);
1262
+ print_setting(pSetting, 0);
12631263
}
12641264
}else
12651265
if( strncmp(zCmd, "status", nCmd)==0 ){
12661266
Stmt q;
12671267
int iCutoff;
@@ -1272,11 +1272,11 @@
12721272
verify_all_options();
12731273
if( g.argc!=3 ) usage("status");
12741274
pSetting = setting_info(&nSetting);
12751275
for(; nSetting>0; nSetting--, pSetting++ ){
12761276
if( strncmp(pSetting->name,"email-",6)!=0 ) continue;
1277
- print_setting(pSetting);
1277
+ print_setting(pSetting, 0);
12781278
}
12791279
n = db_int(0,"SELECT count(*) FROM pending_alert WHERE NOT sentSep");
12801280
fossil_print(zFmt/*works-like:"%s%d"*/, "pending-alerts", n);
12811281
n = db_int(0,"SELECT count(*) FROM pending_alert WHERE NOT sentDigest");
12821282
fossil_print(zFmt/*works-like:"%s%d"*/, "pending-digest-alerts", n);
12831283
--- src/alerts.c
+++ src/alerts.c
@@ -1257,11 +1257,11 @@
1257 g.argc = 3;
1258 }
1259 pSetting = setting_info(&nSetting);
1260 for(; nSetting>0; nSetting--, pSetting++ ){
1261 if( strncmp(pSetting->name,"email-",6)!=0 ) continue;
1262 print_setting(pSetting);
1263 }
1264 }else
1265 if( strncmp(zCmd, "status", nCmd)==0 ){
1266 Stmt q;
1267 int iCutoff;
@@ -1272,11 +1272,11 @@
1272 verify_all_options();
1273 if( g.argc!=3 ) usage("status");
1274 pSetting = setting_info(&nSetting);
1275 for(; nSetting>0; nSetting--, pSetting++ ){
1276 if( strncmp(pSetting->name,"email-",6)!=0 ) continue;
1277 print_setting(pSetting);
1278 }
1279 n = db_int(0,"SELECT count(*) FROM pending_alert WHERE NOT sentSep");
1280 fossil_print(zFmt/*works-like:"%s%d"*/, "pending-alerts", n);
1281 n = db_int(0,"SELECT count(*) FROM pending_alert WHERE NOT sentDigest");
1282 fossil_print(zFmt/*works-like:"%s%d"*/, "pending-digest-alerts", n);
1283
--- src/alerts.c
+++ src/alerts.c
@@ -1257,11 +1257,11 @@
1257 g.argc = 3;
1258 }
1259 pSetting = setting_info(&nSetting);
1260 for(; nSetting>0; nSetting--, pSetting++ ){
1261 if( strncmp(pSetting->name,"email-",6)!=0 ) continue;
1262 print_setting(pSetting, 0);
1263 }
1264 }else
1265 if( strncmp(zCmd, "status", nCmd)==0 ){
1266 Stmt q;
1267 int iCutoff;
@@ -1272,11 +1272,11 @@
1272 verify_all_options();
1273 if( g.argc!=3 ) usage("status");
1274 pSetting = setting_info(&nSetting);
1275 for(; nSetting>0; nSetting--, pSetting++ ){
1276 if( strncmp(pSetting->name,"email-",6)!=0 ) continue;
1277 print_setting(pSetting, 0);
1278 }
1279 n = db_int(0,"SELECT count(*) FROM pending_alert WHERE NOT sentSep");
1280 fossil_print(zFmt/*works-like:"%s%d"*/, "pending-alerts", n);
1281 n = db_int(0,"SELECT count(*) FROM pending_alert WHERE NOT sentDigest");
1282 fossil_print(zFmt/*works-like:"%s%d"*/, "pending-digest-alerts", n);
1283
+38 -16
--- src/db.c
+++ src/db.c
@@ -4296,12 +4296,28 @@
42964296
42974297
/*
42984298
** Print the current value of a setting identified by the pSetting
42994299
** pointer.
43004300
*/
4301
-void print_setting(const Setting *pSetting){
4301
+void print_setting(const Setting *pSetting, int valueOnly){
43024302
Stmt q;
4303
+ int versioned = 0;
4304
+ if( pSetting->versionable && g.localOpen ){
4305
+ /* Check to see if this is overridden by a versionable settings file */
4306
+ Blob versionedPathname;
4307
+ blob_zero(&versionedPathname);
4308
+ blob_appendf(&versionedPathname, "%s.fossil-settings/%s",
4309
+ g.zLocalRoot, pSetting->name);
4310
+ if( file_size(blob_str(&versionedPathname), ExtFILE)>=0 ){
4311
+ versioned = 1;
4312
+ }
4313
+ blob_reset(&versionedPathname);
4314
+ }
4315
+ if( valueOnly && versioned ){
4316
+ fossil_print("%s\n", db_get_versioned(pSetting->name, NULL));
4317
+ return;
4318
+ }
43034319
if( g.repositoryOpen ){
43044320
db_prepare(&q,
43054321
"SELECT '(local)', value FROM config WHERE name=%Q"
43064322
" UNION ALL "
43074323
"SELECT '(global)', value FROM global_config WHERE name=%Q",
@@ -4312,26 +4328,24 @@
43124328
"SELECT '(global)', value FROM global_config WHERE name=%Q",
43134329
pSetting->name
43144330
);
43154331
}
43164332
if( db_step(&q)==SQLITE_ROW ){
4317
- fossil_print("%-20s %-8s %s\n", pSetting->name, db_column_text(&q, 0),
4318
- db_column_text(&q, 1));
4333
+ if( valueOnly ){
4334
+ fossil_print("%s\n", db_column_text(&q, 1));
4335
+ }else{
4336
+ fossil_print("%-20s %-8s %s\n", pSetting->name, db_column_text(&q, 0),
4337
+ db_column_text(&q, 1));
4338
+ }
4339
+ }else if( valueOnly ){
4340
+ fossil_print("\n");
43194341
}else{
43204342
fossil_print("%-20s\n", pSetting->name);
43214343
}
4322
- if( pSetting->versionable && g.localOpen ){
4323
- /* Check to see if this is overridden by a versionable settings file */
4324
- Blob versionedPathname;
4325
- blob_zero(&versionedPathname);
4326
- blob_appendf(&versionedPathname, "%s.fossil-settings/%s",
4327
- g.zLocalRoot, pSetting->name);
4328
- if( file_size(blob_str(&versionedPathname), ExtFILE)>=0 ){
4329
- fossil_print(" (overridden by contents of file .fossil-settings/%s)\n",
4330
- pSetting->name);
4331
- }
4332
- blob_reset(&versionedPathname);
4344
+ if( versioned ){
4345
+ fossil_print(" (overridden by contents of file .fossil-settings/%s)\n",
4346
+ pSetting->name);
43334347
}
43344348
db_finalize(&q);
43354349
}
43364350
43374351
#if INTERFACE
@@ -5063,17 +5077,19 @@
50635077
**
50645078
** Options:
50655079
** --global Set or unset the given property globally instead of
50665080
** setting or unsetting it for the open repository only
50675081
** --exact Only consider exact name matches
5082
+** --value Only show the value of a given property (implies --exact)
50685083
**
50695084
** See also: [[configuration]]
50705085
*/
50715086
void setting_cmd(void){
50725087
int i;
50735088
int globalFlag = find_option("global","g",0)!=0;
50745089
int exactFlag = find_option("exact",0,0)!=0;
5090
+ int valueFlag = find_option("value",0,0)!=0;
50755091
/* Undocumented "--test-for-subsystem SUBSYS" option used to test
50765092
** the db_get_for_subsystem() interface: */
50775093
const char *zSubsys = find_option("test-for-subsystem",0,1);
50785094
int unsetFlag = g.argv[1][0]=='u';
50795095
int nSetting;
@@ -5088,14 +5104,20 @@
50885104
globalFlag = 1;
50895105
}
50905106
if( unsetFlag && g.argc!=3 ){
50915107
usage("PROPERTY ?-global?");
50925108
}
5109
+ if( valueFlag ){
5110
+ if( g.argc!=3 ){
5111
+ fossil_fatal("--value is only supported when qurying a given property");
5112
+ }
5113
+ exactFlag = 1;
5114
+ }
50935115
50945116
if( g.argc==2 ){
50955117
for(i=0; i<nSetting; i++){
5096
- print_setting(&aSetting[i]);
5118
+ print_setting(&aSetting[i], 0);
50975119
}
50985120
}else if( g.argc==3 || g.argc==4 ){
50995121
const char *zName = g.argv[2];
51005122
int n = (int)strlen(zName);
51015123
const Setting *pSetting = db_find_setting(zName, !exactFlag);
@@ -5146,11 +5168,11 @@
51465168
fossil_print(" [%s]", zValue);
51475169
fossil_free(zValue);
51485170
}
51495171
fossil_print("\n");
51505172
}else{
5151
- print_setting(pSetting);
5173
+ print_setting(pSetting, valueFlag);
51525174
}
51535175
pSetting++;
51545176
}
51555177
}
51565178
}else{
51575179
--- src/db.c
+++ src/db.c
@@ -4296,12 +4296,28 @@
4296
4297 /*
4298 ** Print the current value of a setting identified by the pSetting
4299 ** pointer.
4300 */
4301 void print_setting(const Setting *pSetting){
4302 Stmt q;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4303 if( g.repositoryOpen ){
4304 db_prepare(&q,
4305 "SELECT '(local)', value FROM config WHERE name=%Q"
4306 " UNION ALL "
4307 "SELECT '(global)', value FROM global_config WHERE name=%Q",
@@ -4312,26 +4328,24 @@
4312 "SELECT '(global)', value FROM global_config WHERE name=%Q",
4313 pSetting->name
4314 );
4315 }
4316 if( db_step(&q)==SQLITE_ROW ){
4317 fossil_print("%-20s %-8s %s\n", pSetting->name, db_column_text(&q, 0),
4318 db_column_text(&q, 1));
 
 
 
 
 
 
4319 }else{
4320 fossil_print("%-20s\n", pSetting->name);
4321 }
4322 if( pSetting->versionable && g.localOpen ){
4323 /* Check to see if this is overridden by a versionable settings file */
4324 Blob versionedPathname;
4325 blob_zero(&versionedPathname);
4326 blob_appendf(&versionedPathname, "%s.fossil-settings/%s",
4327 g.zLocalRoot, pSetting->name);
4328 if( file_size(blob_str(&versionedPathname), ExtFILE)>=0 ){
4329 fossil_print(" (overridden by contents of file .fossil-settings/%s)\n",
4330 pSetting->name);
4331 }
4332 blob_reset(&versionedPathname);
4333 }
4334 db_finalize(&q);
4335 }
4336
4337 #if INTERFACE
@@ -5063,17 +5077,19 @@
5063 **
5064 ** Options:
5065 ** --global Set or unset the given property globally instead of
5066 ** setting or unsetting it for the open repository only
5067 ** --exact Only consider exact name matches
 
5068 **
5069 ** See also: [[configuration]]
5070 */
5071 void setting_cmd(void){
5072 int i;
5073 int globalFlag = find_option("global","g",0)!=0;
5074 int exactFlag = find_option("exact",0,0)!=0;
 
5075 /* Undocumented "--test-for-subsystem SUBSYS" option used to test
5076 ** the db_get_for_subsystem() interface: */
5077 const char *zSubsys = find_option("test-for-subsystem",0,1);
5078 int unsetFlag = g.argv[1][0]=='u';
5079 int nSetting;
@@ -5088,14 +5104,20 @@
5088 globalFlag = 1;
5089 }
5090 if( unsetFlag && g.argc!=3 ){
5091 usage("PROPERTY ?-global?");
5092 }
 
 
 
 
 
 
5093
5094 if( g.argc==2 ){
5095 for(i=0; i<nSetting; i++){
5096 print_setting(&aSetting[i]);
5097 }
5098 }else if( g.argc==3 || g.argc==4 ){
5099 const char *zName = g.argv[2];
5100 int n = (int)strlen(zName);
5101 const Setting *pSetting = db_find_setting(zName, !exactFlag);
@@ -5146,11 +5168,11 @@
5146 fossil_print(" [%s]", zValue);
5147 fossil_free(zValue);
5148 }
5149 fossil_print("\n");
5150 }else{
5151 print_setting(pSetting);
5152 }
5153 pSetting++;
5154 }
5155 }
5156 }else{
5157
--- src/db.c
+++ src/db.c
@@ -4296,12 +4296,28 @@
4296
4297 /*
4298 ** Print the current value of a setting identified by the pSetting
4299 ** pointer.
4300 */
4301 void print_setting(const Setting *pSetting, int valueOnly){
4302 Stmt q;
4303 int versioned = 0;
4304 if( pSetting->versionable && g.localOpen ){
4305 /* Check to see if this is overridden by a versionable settings file */
4306 Blob versionedPathname;
4307 blob_zero(&versionedPathname);
4308 blob_appendf(&versionedPathname, "%s.fossil-settings/%s",
4309 g.zLocalRoot, pSetting->name);
4310 if( file_size(blob_str(&versionedPathname), ExtFILE)>=0 ){
4311 versioned = 1;
4312 }
4313 blob_reset(&versionedPathname);
4314 }
4315 if( valueOnly && versioned ){
4316 fossil_print("%s\n", db_get_versioned(pSetting->name, NULL));
4317 return;
4318 }
4319 if( g.repositoryOpen ){
4320 db_prepare(&q,
4321 "SELECT '(local)', value FROM config WHERE name=%Q"
4322 " UNION ALL "
4323 "SELECT '(global)', value FROM global_config WHERE name=%Q",
@@ -4312,26 +4328,24 @@
4328 "SELECT '(global)', value FROM global_config WHERE name=%Q",
4329 pSetting->name
4330 );
4331 }
4332 if( db_step(&q)==SQLITE_ROW ){
4333 if( valueOnly ){
4334 fossil_print("%s\n", db_column_text(&q, 1));
4335 }else{
4336 fossil_print("%-20s %-8s %s\n", pSetting->name, db_column_text(&q, 0),
4337 db_column_text(&q, 1));
4338 }
4339 }else if( valueOnly ){
4340 fossil_print("\n");
4341 }else{
4342 fossil_print("%-20s\n", pSetting->name);
4343 }
4344 if( versioned ){
4345 fossil_print(" (overridden by contents of file .fossil-settings/%s)\n",
4346 pSetting->name);
 
 
 
 
 
 
 
 
4347 }
4348 db_finalize(&q);
4349 }
4350
4351 #if INTERFACE
@@ -5063,17 +5077,19 @@
5077 **
5078 ** Options:
5079 ** --global Set or unset the given property globally instead of
5080 ** setting or unsetting it for the open repository only
5081 ** --exact Only consider exact name matches
5082 ** --value Only show the value of a given property (implies --exact)
5083 **
5084 ** See also: [[configuration]]
5085 */
5086 void setting_cmd(void){
5087 int i;
5088 int globalFlag = find_option("global","g",0)!=0;
5089 int exactFlag = find_option("exact",0,0)!=0;
5090 int valueFlag = find_option("value",0,0)!=0;
5091 /* Undocumented "--test-for-subsystem SUBSYS" option used to test
5092 ** the db_get_for_subsystem() interface: */
5093 const char *zSubsys = find_option("test-for-subsystem",0,1);
5094 int unsetFlag = g.argv[1][0]=='u';
5095 int nSetting;
@@ -5088,14 +5104,20 @@
5104 globalFlag = 1;
5105 }
5106 if( unsetFlag && g.argc!=3 ){
5107 usage("PROPERTY ?-global?");
5108 }
5109 if( valueFlag ){
5110 if( g.argc!=3 ){
5111 fossil_fatal("--value is only supported when qurying a given property");
5112 }
5113 exactFlag = 1;
5114 }
5115
5116 if( g.argc==2 ){
5117 for(i=0; i<nSetting; i++){
5118 print_setting(&aSetting[i], 0);
5119 }
5120 }else if( g.argc==3 || g.argc==4 ){
5121 const char *zName = g.argv[2];
5122 int n = (int)strlen(zName);
5123 const Setting *pSetting = db_find_setting(zName, !exactFlag);
@@ -5146,11 +5168,11 @@
5168 fossil_print(" [%s]", zValue);
5169 fossil_free(zValue);
5170 }
5171 fossil_print("\n");
5172 }else{
5173 print_setting(pSetting, valueFlag);
5174 }
5175 pSetting++;
5176 }
5177 }
5178 }else{
5179

Keyboard Shortcuts

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