Fossil SCM
merge in fossil-settings-value-only
Commit
0d4a31a9f536cde490f86647c0e9db0ae50023f391b11a5a8c6be2ccf257a676
Parent
ad0b5f0e2da8eab…
2 files changed
+2
-2
+38
-16
+2
-2
| --- src/alerts.c | ||
| +++ src/alerts.c | ||
| @@ -1257,11 +1257,11 @@ | ||
| 1257 | 1257 | g.argc = 3; |
| 1258 | 1258 | } |
| 1259 | 1259 | pSetting = setting_info(&nSetting); |
| 1260 | 1260 | for(; nSetting>0; nSetting--, pSetting++ ){ |
| 1261 | 1261 | if( strncmp(pSetting->name,"email-",6)!=0 ) continue; |
| 1262 | - print_setting(pSetting); | |
| 1262 | + print_setting(pSetting, 0); | |
| 1263 | 1263 | } |
| 1264 | 1264 | }else |
| 1265 | 1265 | if( strncmp(zCmd, "status", nCmd)==0 ){ |
| 1266 | 1266 | Stmt q; |
| 1267 | 1267 | int iCutoff; |
| @@ -1272,11 +1272,11 @@ | ||
| 1272 | 1272 | verify_all_options(); |
| 1273 | 1273 | if( g.argc!=3 ) usage("status"); |
| 1274 | 1274 | pSetting = setting_info(&nSetting); |
| 1275 | 1275 | for(; nSetting>0; nSetting--, pSetting++ ){ |
| 1276 | 1276 | if( strncmp(pSetting->name,"email-",6)!=0 ) continue; |
| 1277 | - print_setting(pSetting); | |
| 1277 | + print_setting(pSetting, 0); | |
| 1278 | 1278 | } |
| 1279 | 1279 | n = db_int(0,"SELECT count(*) FROM pending_alert WHERE NOT sentSep"); |
| 1280 | 1280 | fossil_print(zFmt/*works-like:"%s%d"*/, "pending-alerts", n); |
| 1281 | 1281 | n = db_int(0,"SELECT count(*) FROM pending_alert WHERE NOT sentDigest"); |
| 1282 | 1282 | fossil_print(zFmt/*works-like:"%s%d"*/, "pending-digest-alerts", n); |
| 1283 | 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); |
| 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 |
M
src/db.c
+38
-16
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -4296,12 +4296,28 @@ | ||
| 4296 | 4296 | |
| 4297 | 4297 | /* |
| 4298 | 4298 | ** Print the current value of a setting identified by the pSetting |
| 4299 | 4299 | ** pointer. |
| 4300 | 4300 | */ |
| 4301 | -void print_setting(const Setting *pSetting){ | |
| 4301 | +void print_setting(const Setting *pSetting, int valueOnly){ | |
| 4302 | 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 | + } | |
| 4303 | 4319 | if( g.repositoryOpen ){ |
| 4304 | 4320 | db_prepare(&q, |
| 4305 | 4321 | "SELECT '(local)', value FROM config WHERE name=%Q" |
| 4306 | 4322 | " UNION ALL " |
| 4307 | 4323 | "SELECT '(global)', value FROM global_config WHERE name=%Q", |
| @@ -4312,26 +4328,24 @@ | ||
| 4312 | 4328 | "SELECT '(global)', value FROM global_config WHERE name=%Q", |
| 4313 | 4329 | pSetting->name |
| 4314 | 4330 | ); |
| 4315 | 4331 | } |
| 4316 | 4332 | 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"); | |
| 4319 | 4341 | }else{ |
| 4320 | 4342 | fossil_print("%-20s\n", pSetting->name); |
| 4321 | 4343 | } |
| 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); | |
| 4333 | 4347 | } |
| 4334 | 4348 | db_finalize(&q); |
| 4335 | 4349 | } |
| 4336 | 4350 | |
| 4337 | 4351 | #if INTERFACE |
| @@ -5063,17 +5077,19 @@ | ||
| 5063 | 5077 | ** |
| 5064 | 5078 | ** Options: |
| 5065 | 5079 | ** --global Set or unset the given property globally instead of |
| 5066 | 5080 | ** setting or unsetting it for the open repository only |
| 5067 | 5081 | ** --exact Only consider exact name matches |
| 5082 | +** --value Only show the value of a given property (implies --exact) | |
| 5068 | 5083 | ** |
| 5069 | 5084 | ** See also: [[configuration]] |
| 5070 | 5085 | */ |
| 5071 | 5086 | void setting_cmd(void){ |
| 5072 | 5087 | int i; |
| 5073 | 5088 | int globalFlag = find_option("global","g",0)!=0; |
| 5074 | 5089 | int exactFlag = find_option("exact",0,0)!=0; |
| 5090 | + int valueFlag = find_option("value",0,0)!=0; | |
| 5075 | 5091 | /* Undocumented "--test-for-subsystem SUBSYS" option used to test |
| 5076 | 5092 | ** the db_get_for_subsystem() interface: */ |
| 5077 | 5093 | const char *zSubsys = find_option("test-for-subsystem",0,1); |
| 5078 | 5094 | int unsetFlag = g.argv[1][0]=='u'; |
| 5079 | 5095 | int nSetting; |
| @@ -5088,14 +5104,20 @@ | ||
| 5088 | 5104 | globalFlag = 1; |
| 5089 | 5105 | } |
| 5090 | 5106 | if( unsetFlag && g.argc!=3 ){ |
| 5091 | 5107 | usage("PROPERTY ?-global?"); |
| 5092 | 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 | + } | |
| 5093 | 5115 | |
| 5094 | 5116 | if( g.argc==2 ){ |
| 5095 | 5117 | for(i=0; i<nSetting; i++){ |
| 5096 | - print_setting(&aSetting[i]); | |
| 5118 | + print_setting(&aSetting[i], 0); | |
| 5097 | 5119 | } |
| 5098 | 5120 | }else if( g.argc==3 || g.argc==4 ){ |
| 5099 | 5121 | const char *zName = g.argv[2]; |
| 5100 | 5122 | int n = (int)strlen(zName); |
| 5101 | 5123 | const Setting *pSetting = db_find_setting(zName, !exactFlag); |
| @@ -5146,11 +5168,11 @@ | ||
| 5146 | 5168 | fossil_print(" [%s]", zValue); |
| 5147 | 5169 | fossil_free(zValue); |
| 5148 | 5170 | } |
| 5149 | 5171 | fossil_print("\n"); |
| 5150 | 5172 | }else{ |
| 5151 | - print_setting(pSetting); | |
| 5173 | + print_setting(pSetting, valueFlag); | |
| 5152 | 5174 | } |
| 5153 | 5175 | pSetting++; |
| 5154 | 5176 | } |
| 5155 | 5177 | } |
| 5156 | 5178 | }else{ |
| 5157 | 5179 |
| --- 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 |