| ︙ | | | ︙ | |
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
|
g.argc = 2;
info_cmd();
}
/*
** Print the current value of a setting identified by the pSetting
** pointer.
*/
void print_setting(const Setting *pSetting, int valueOnly, int bAlways){
Stmt q;
int versioned = 0;
if( !pSetting->bIfChng ) bAlways = 1;
if( pSetting->versionable && g.localOpen ){
/* Check to see if this is overridden by a versionable settings file */
Blob versionedPathname;
blob_zero(&versionedPathname);
blob_appendf(&versionedPathname, "%s.fossil-settings/%s",
g.zLocalRoot, pSetting->name);
if( file_size(blob_str(&versionedPathname), ExtFILE)>=0 ){
versioned = 1;
}
blob_reset(&versionedPathname);
}
if( valueOnly && versioned ){
const char *zVal = db_get_versioned(pSetting->name, NULL, NULL);
if( bAlways || (zVal!=0 && fossil_strcmp(zVal, pSetting->def)!=0) ){
fossil_print("%s\n", db_get_versioned(pSetting->name, NULL, NULL));
}else{
versioned = 0;
}
return;
}
if( g.repositoryOpen ){
|
>
>
>
>
>
|
<
|
|
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
|
g.argc = 2;
info_cmd();
}
/*
** Print the current value of a setting identified by the pSetting
** pointer.
**
** Only show the value, not the setting name, if valueOnly is true.
**
** Show nothing if bIfChng is true and the setting is not currently set
** or is set to its default value.
*/
void print_setting(const Setting *pSetting, int valueOnly, int bIfChng){
Stmt q;
int versioned = 0;
if( pSetting->versionable && g.localOpen ){
/* Check to see if this is overridden by a versionable settings file */
Blob versionedPathname;
blob_zero(&versionedPathname);
blob_appendf(&versionedPathname, "%s.fossil-settings/%s",
g.zLocalRoot, pSetting->name);
if( file_size(blob_str(&versionedPathname), ExtFILE)>=0 ){
versioned = 1;
}
blob_reset(&versionedPathname);
}
if( valueOnly && versioned ){
const char *zVal = db_get_versioned(pSetting->name, NULL, NULL);
if( !bIfChng || (zVal!=0 && fossil_strcmp(zVal, pSetting->def)!=0) ){
fossil_print("%s\n", db_get_versioned(pSetting->name, NULL, NULL));
}else{
versioned = 0;
}
return;
}
if( g.repositoryOpen ){
|
| ︙ | | | ︙ | |
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
|
db_prepare(&q,
"SELECT '(global)', value FROM global_config WHERE name=%Q",
pSetting->name
);
}
if( db_step(&q)==SQLITE_ROW ){
const char *zVal = db_column_text(&q,1);
if( !bAlways && (zVal==0 || fossil_strcmp(zVal, pSetting->def)==0) ){
/* Don't display because the value is equal to the default */
}else if( valueOnly ){
fossil_print("%s\n", db_column_text(&q, 1));
}else{
fossil_print("%-20s %-8s %s\n", pSetting->name, db_column_text(&q, 0),
db_column_text(&q, 1));
}
}else if( !bAlways ){
/* Display nothing */
}else if( valueOnly ){
fossil_print("\n");
}else{
fossil_print("%-20s\n", pSetting->name);
}
if( versioned ){
fossil_print(" (overridden by contents of file .fossil-settings/%s)\n",
pSetting->name);
}
db_finalize(&q);
}
|
>
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
|
>
|
|
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
|
db_prepare(&q,
"SELECT '(global)', value FROM global_config WHERE name=%Q",
pSetting->name
);
}
if( db_step(&q)==SQLITE_ROW ){
const char *zVal = db_column_text(&q,1);
int noShow = 0;
if( bIfChng ){
/* Don't display the value is equal to the default */
if( zVal==0 ){
noShow = 1;
}else if( pSetting->def ){
if( pSetting->width==0 ){
if( is_false(zVal) && is_false(pSetting->def) ) noShow = 1;
}else{
if( fossil_strcmp(zVal, pSetting->def)==0 ) noShow = 1;
}
}
}
if( noShow ){
fossil_print("%-24s (versioned)\n", pSetting->name);
versioned = 0;
}else if( valueOnly ){
fossil_print("%s\n", db_column_text(&q, 1));
}else{
const char *zVal = (const char*)db_column_text(&q,1);
const char *zName = (const char*)db_column_text(&q,0);
if( zVal==0 ) zVal = "NULL";
if( strchr(zVal,'\n')==0 ){
fossil_print("%-24s %-11s %s\n", pSetting->name, zName, zVal);
}else{
fossil_print("%-24s %-11s\n", pSetting->name, zName);
while( zVal[0] ){
char *zNL = strchr(zVal, '\n');
if( zNL==0 ){
fossil_print(" %s\n", zVal);
break;
}else{
int n = (int)(zNL - zVal);
while( n>0 && fossil_isspace(zVal[n-1]) ){ n--; }
fossil_print(" %.*s\n", n, zVal);
zVal = zNL+1;
}
}
}
}
}else if( bIfChng ){
/* Display nothing */
versioned = 0;
}else if( valueOnly ){
fossil_print("\n");
}else{
fossil_print("%-24s\n", pSetting->name);
}
if( versioned ){
fossil_print(" (overridden by contents of file .fossil-settings/%s)\n",
pSetting->name);
}
db_finalize(&q);
}
|
| ︙ | | | ︙ | |
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
|
const char *var; /* Internal variable name used by db_set() */
int width; /* Width of display. 0 for boolean values and
** negative for values which should not appear
** on the /setup_settings page. */
char versionable; /* Is this setting versionable? */
char forceTextArea; /* Force using a text area for display? */
char sensitive; /* True if this a security-sensitive setting */
char bIfChng; /* Only display if value differs from default */
const char *def; /* Default value */
};
#endif /* INTERFACE */
/*
** SETTING: access-log boolean default=off
|
<
|
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
|
const char *var; /* Internal variable name used by db_set() */
int width; /* Width of display. 0 for boolean values and
** negative for values which should not appear
** on the /setup_settings page. */
char versionable; /* Is this setting versionable? */
char forceTextArea; /* Force using a text area for display? */
char sensitive; /* True if this a security-sensitive setting */
const char *def; /* Default value */
};
#endif /* INTERFACE */
/*
** SETTING: access-log boolean default=off
|
| ︙ | | | ︙ | |
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
|
** that applies to all repositories. The local values are stored in the
** "config" table of the repository and the global values are stored in the
** configuration database. If both a local and a global value exists for a
** setting, the local value takes precedence. This command normally operates
** on the local settings. Use the --global option to change global settings.
**
** Options:
** --exact Only consider exact name matches
** --extra When listing settings, show them all, even those that are
** normally only shown if there values are different from default
** --global Set or unset the given property globally instead of
** setting or unsetting it for the open repository only
** --value Only show the value of a given property (implies --exact)
**
** See also: [[configuration]]
*/
void setting_cmd(void){
int i;
int globalFlag = find_option("global","g",0)!=0;
int exactFlag = find_option("exact",0,0)!=0;
int extraFlag = find_option("extra",0,0)!=0;
int valueFlag = find_option("value",0,0)!=0;
/* Undocumented "--test-for-subsystem SUBSYS" option used to test
** the db_get_for_subsystem() interface: */
const char *zSubsys = find_option("test-for-subsystem",0,1);
int unsetFlag = g.argv[1][0]=='u';
int nSetting;
const Setting *aSetting = setting_info(&nSetting);
|
>
<
<
>
<
|
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
|
** that applies to all repositories. The local values are stored in the
** "config" table of the repository and the global values are stored in the
** configuration database. If both a local and a global value exists for a
** setting, the local value takes precedence. This command normally operates
** on the local settings. Use the --global option to change global settings.
**
** Options:
** --changed Only show settings if the value differs from the default
** --exact Only consider exact name matches
** --global Set or unset the given property globally instead of
** setting or unsetting it for the open repository only
** --value Only show the value of a given property (implies --exact)
**
** See also: [[configuration]]
*/
void setting_cmd(void){
int i;
int globalFlag = find_option("global","g",0)!=0;
int bIfChng = find_option("changed",0,0)!=0;
int exactFlag = find_option("exact",0,0)!=0;
int valueFlag = find_option("value",0,0)!=0;
/* Undocumented "--test-for-subsystem SUBSYS" option used to test
** the db_get_for_subsystem() interface: */
const char *zSubsys = find_option("test-for-subsystem",0,1);
int unsetFlag = g.argv[1][0]=='u';
int nSetting;
const Setting *aSetting = setting_info(&nSetting);
|
| ︙ | | | ︙ | |
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
|
if( unsetFlag && g.argc!=3 ){
usage("PROPERTY ?-global?");
}
if( valueFlag ){
if( g.argc!=3 ){
fossil_fatal("--value is only supported when qurying a given property");
}
exactFlag = 1;
}
if( g.argc==2 ){
for(i=0; i<nSetting; i++){
print_setting(&aSetting[i], 0, extraFlag);
}
}else if( g.argc==3 || g.argc==4 ){
const char *zName = g.argv[2];
int n = (int)strlen(zName);
const Setting *pSetting = db_find_setting(zName, !exactFlag);
if( pSetting==0 ){
fossil_fatal("no such setting: %s", zName);
|
<
|
|
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
|
if( unsetFlag && g.argc!=3 ){
usage("PROPERTY ?-global?");
}
if( valueFlag ){
if( g.argc!=3 ){
fossil_fatal("--value is only supported when qurying a given property");
}
}
if( g.argc==2 ){
for(i=0; i<nSetting; i++){
print_setting(&aSetting[i], 0, bIfChng);
}
}else if( g.argc==3 || g.argc==4 ){
const char *zName = g.argv[2];
int n = (int)strlen(zName);
const Setting *pSetting = db_find_setting(zName, !exactFlag);
if( pSetting==0 ){
fossil_fatal("no such setting: %s", zName);
|
| ︙ | | | ︙ | |
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
|
fossil_print("%s (subsystem %s) ->", pSetting->name, zSubsys);
if( zValue ){
fossil_print(" [%s]", zValue);
fossil_free(zValue);
}
fossil_print("\n");
}else{
print_setting(pSetting, valueFlag, extraFlag);
}
pSetting++;
}
}
}else{
usage("?PROPERTY? ?VALUE? ?-global?");
}
|
|
|
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
|
fossil_print("%s (subsystem %s) ->", pSetting->name, zSubsys);
if( zValue ){
fossil_print(" [%s]", zValue);
fossil_free(zValue);
}
fossil_print("\n");
}else{
print_setting(pSetting, valueFlag, bIfChng);
}
pSetting++;
}
}
}else{
usage("?PROPERTY? ?VALUE? ?-global?");
}
|
| ︙ | | | ︙ | |