Fossil SCM
Remove the seperate versionable version of db_get(), which now uses ctrlSettings to determine whether a setting is versionable or not.
Commit
3113f7b18f672ee31cdeef429809b9de375f1438
Parent
246ac307bb0438c…
8 files changed
+3
-3
+5
-5
+1
-1
+21
-17
+1
-1
+1
-1
+1
-1
+1
-1
+3
-3
| --- src/add.c | ||
| +++ src/add.c | ||
| @@ -60,11 +60,11 @@ | ||
| 60 | 60 | "manifest.uuid", |
| 61 | 61 | }; |
| 62 | 62 | |
| 63 | 63 | if( N>=0 && N<count(azName) ) return azName[N]; |
| 64 | 64 | if( N>=count(azName) && N<count(azName)+count(azManifest) |
| 65 | - && db_get_versionable_setting_boolean("manifest",0) ){ | |
| 65 | + && db_get_boolean("manifest",0) ){ | |
| 66 | 66 | return azManifest[N-count(azName)]; |
| 67 | 67 | } |
| 68 | 68 | return 0; |
| 69 | 69 | } |
| 70 | 70 | |
| @@ -198,11 +198,11 @@ | ||
| 198 | 198 | includeDotFiles = find_option("dotfiles",0,0)!=0; |
| 199 | 199 | capture_case_sensitive_option(); |
| 200 | 200 | db_must_be_within_tree(); |
| 201 | 201 | caseSensitive = filenames_are_case_sensitive(); |
| 202 | 202 | if( zIgnoreFlag==0 ){ |
| 203 | - zIgnoreFlag = db_get_versionable_setting("ignore-glob", 0); | |
| 203 | + zIgnoreFlag = db_get("ignore-glob", 0); | |
| 204 | 204 | } |
| 205 | 205 | vid = db_lget_int("checkout",0); |
| 206 | 206 | if( vid==0 ){ |
| 207 | 207 | fossil_panic("no checkout to add to"); |
| 208 | 208 | } |
| @@ -390,11 +390,11 @@ | ||
| 390 | 390 | |
| 391 | 391 | capture_case_sensitive_option(); |
| 392 | 392 | db_must_be_within_tree(); |
| 393 | 393 | caseSensitive = filenames_are_case_sensitive(); |
| 394 | 394 | if( zIgnoreFlag==0 ){ |
| 395 | - zIgnoreFlag = db_get_versionable_setting("ignore-glob", 0); | |
| 395 | + zIgnoreFlag = db_get("ignore-glob", 0); | |
| 396 | 396 | } |
| 397 | 397 | vid = db_lget_int("checkout",0); |
| 398 | 398 | if( vid==0 ){ |
| 399 | 399 | fossil_panic("no checkout to add to"); |
| 400 | 400 | } |
| 401 | 401 |
| --- src/add.c | |
| +++ src/add.c | |
| @@ -60,11 +60,11 @@ | |
| 60 | "manifest.uuid", |
| 61 | }; |
| 62 | |
| 63 | if( N>=0 && N<count(azName) ) return azName[N]; |
| 64 | if( N>=count(azName) && N<count(azName)+count(azManifest) |
| 65 | && db_get_versionable_setting_boolean("manifest",0) ){ |
| 66 | return azManifest[N-count(azName)]; |
| 67 | } |
| 68 | return 0; |
| 69 | } |
| 70 | |
| @@ -198,11 +198,11 @@ | |
| 198 | includeDotFiles = find_option("dotfiles",0,0)!=0; |
| 199 | capture_case_sensitive_option(); |
| 200 | db_must_be_within_tree(); |
| 201 | caseSensitive = filenames_are_case_sensitive(); |
| 202 | if( zIgnoreFlag==0 ){ |
| 203 | zIgnoreFlag = db_get_versionable_setting("ignore-glob", 0); |
| 204 | } |
| 205 | vid = db_lget_int("checkout",0); |
| 206 | if( vid==0 ){ |
| 207 | fossil_panic("no checkout to add to"); |
| 208 | } |
| @@ -390,11 +390,11 @@ | |
| 390 | |
| 391 | capture_case_sensitive_option(); |
| 392 | db_must_be_within_tree(); |
| 393 | caseSensitive = filenames_are_case_sensitive(); |
| 394 | if( zIgnoreFlag==0 ){ |
| 395 | zIgnoreFlag = db_get_versionable_setting("ignore-glob", 0); |
| 396 | } |
| 397 | vid = db_lget_int("checkout",0); |
| 398 | if( vid==0 ){ |
| 399 | fossil_panic("no checkout to add to"); |
| 400 | } |
| 401 |
| --- src/add.c | |
| +++ src/add.c | |
| @@ -60,11 +60,11 @@ | |
| 60 | "manifest.uuid", |
| 61 | }; |
| 62 | |
| 63 | if( N>=0 && N<count(azName) ) return azName[N]; |
| 64 | if( N>=count(azName) && N<count(azName)+count(azManifest) |
| 65 | && db_get_boolean("manifest",0) ){ |
| 66 | return azManifest[N-count(azName)]; |
| 67 | } |
| 68 | return 0; |
| 69 | } |
| 70 | |
| @@ -198,11 +198,11 @@ | |
| 198 | includeDotFiles = find_option("dotfiles",0,0)!=0; |
| 199 | capture_case_sensitive_option(); |
| 200 | db_must_be_within_tree(); |
| 201 | caseSensitive = filenames_are_case_sensitive(); |
| 202 | if( zIgnoreFlag==0 ){ |
| 203 | zIgnoreFlag = db_get("ignore-glob", 0); |
| 204 | } |
| 205 | vid = db_lget_int("checkout",0); |
| 206 | if( vid==0 ){ |
| 207 | fossil_panic("no checkout to add to"); |
| 208 | } |
| @@ -390,11 +390,11 @@ | |
| 390 | |
| 391 | capture_case_sensitive_option(); |
| 392 | db_must_be_within_tree(); |
| 393 | caseSensitive = filenames_are_case_sensitive(); |
| 394 | if( zIgnoreFlag==0 ){ |
| 395 | zIgnoreFlag = db_get("ignore-glob", 0); |
| 396 | } |
| 397 | vid = db_lget_int("checkout",0); |
| 398 | if( vid==0 ){ |
| 399 | fossil_panic("no checkout to add to"); |
| 400 | } |
| 401 |
+5
-5
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -289,16 +289,16 @@ | ||
| 289 | 289 | Blob rewrittenPathname; |
| 290 | 290 | const char *zPathname, *zDisplayName; |
| 291 | 291 | |
| 292 | 292 | db_must_be_within_tree(); |
| 293 | 293 | cwdRelative = determine_cwd_relative_option(); |
| 294 | - outputManifest = db_get_versionable_setting_boolean("manifest",0); | |
| 294 | + outputManifest = db_get_boolean("manifest",0); | |
| 295 | 295 | db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); |
| 296 | 296 | n = strlen(g.zLocalRoot); |
| 297 | 297 | blob_init(&path, g.zLocalRoot, n-1); |
| 298 | 298 | if( zIgnoreFlag==0 ){ |
| 299 | - zIgnoreFlag = db_get_versionable_setting("ignore-glob", 0); | |
| 299 | + zIgnoreFlag = db_get("ignore-glob", 0); | |
| 300 | 300 | } |
| 301 | 301 | pIgnore = glob_create(zIgnoreFlag); |
| 302 | 302 | vfile_scan(&path, blob_size(&path), allFlag, pIgnore); |
| 303 | 303 | glob_free(pIgnore); |
| 304 | 304 | db_prepare(&q, |
| @@ -360,11 +360,11 @@ | ||
| 360 | 360 | allFlag = find_option("force","f",0)!=0; |
| 361 | 361 | dotfilesFlag = find_option("dotfiles",0,0)!=0; |
| 362 | 362 | zIgnoreFlag = find_option("ignore",0,1); |
| 363 | 363 | db_must_be_within_tree(); |
| 364 | 364 | if( zIgnoreFlag==0 ){ |
| 365 | - zIgnoreFlag = db_get_versionable_setting("ignore-glob", 0); | |
| 365 | + zIgnoreFlag = db_get("ignore-glob", 0); | |
| 366 | 366 | } |
| 367 | 367 | db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); |
| 368 | 368 | n = strlen(g.zLocalRoot); |
| 369 | 369 | blob_init(&path, g.zLocalRoot, n-1); |
| 370 | 370 | pIgnore = glob_create(zIgnoreFlag); |
| @@ -908,11 +908,11 @@ | ||
| 908 | 908 | zUserOvrd = find_option("user-override",0,1); |
| 909 | 909 | db_must_be_within_tree(); |
| 910 | 910 | noSign = db_get_boolean("omitsign", 0)|noSign; |
| 911 | 911 | if( db_get_boolean("clearsign", 0)==0 ){ noSign = 1; } |
| 912 | 912 | useCksum = db_get_boolean("repo-cksum", 1); |
| 913 | - outputManifest = db_get_versionable_setting_boolean("manifest", 0); | |
| 913 | + outputManifest = db_get_boolean("manifest", 0); | |
| 914 | 914 | verify_all_options(); |
| 915 | 915 | |
| 916 | 916 | /* So that older versions of Fossil (that do not understand delta- |
| 917 | 917 | ** manifest) can continue to use this repository, do not create a new |
| 918 | 918 | ** delta-manifest unless this repository already contains one or more |
| @@ -1049,11 +1049,11 @@ | ||
| 1049 | 1049 | ** the identified fils are inserted (if they have been modified). |
| 1050 | 1050 | */ |
| 1051 | 1051 | db_prepare(&q, |
| 1052 | 1052 | "SELECT id, %Q || pathname, mrid, %s FROM vfile " |
| 1053 | 1053 | "WHERE chnged==1 AND NOT deleted AND file_is_selected(id)", |
| 1054 | - g.zLocalRoot, glob_expr("pathname", db_get_versionable_setting("crnl-glob","")) | |
| 1054 | + g.zLocalRoot, glob_expr("pathname", db_get("crnl-glob","")) | |
| 1055 | 1055 | ); |
| 1056 | 1056 | while( db_step(&q)==SQLITE_ROW ){ |
| 1057 | 1057 | int id, rid; |
| 1058 | 1058 | const char *zFullname; |
| 1059 | 1059 | Blob content; |
| 1060 | 1060 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -289,16 +289,16 @@ | |
| 289 | Blob rewrittenPathname; |
| 290 | const char *zPathname, *zDisplayName; |
| 291 | |
| 292 | db_must_be_within_tree(); |
| 293 | cwdRelative = determine_cwd_relative_option(); |
| 294 | outputManifest = db_get_versionable_setting_boolean("manifest",0); |
| 295 | db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); |
| 296 | n = strlen(g.zLocalRoot); |
| 297 | blob_init(&path, g.zLocalRoot, n-1); |
| 298 | if( zIgnoreFlag==0 ){ |
| 299 | zIgnoreFlag = db_get_versionable_setting("ignore-glob", 0); |
| 300 | } |
| 301 | pIgnore = glob_create(zIgnoreFlag); |
| 302 | vfile_scan(&path, blob_size(&path), allFlag, pIgnore); |
| 303 | glob_free(pIgnore); |
| 304 | db_prepare(&q, |
| @@ -360,11 +360,11 @@ | |
| 360 | allFlag = find_option("force","f",0)!=0; |
| 361 | dotfilesFlag = find_option("dotfiles",0,0)!=0; |
| 362 | zIgnoreFlag = find_option("ignore",0,1); |
| 363 | db_must_be_within_tree(); |
| 364 | if( zIgnoreFlag==0 ){ |
| 365 | zIgnoreFlag = db_get_versionable_setting("ignore-glob", 0); |
| 366 | } |
| 367 | db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); |
| 368 | n = strlen(g.zLocalRoot); |
| 369 | blob_init(&path, g.zLocalRoot, n-1); |
| 370 | pIgnore = glob_create(zIgnoreFlag); |
| @@ -908,11 +908,11 @@ | |
| 908 | zUserOvrd = find_option("user-override",0,1); |
| 909 | db_must_be_within_tree(); |
| 910 | noSign = db_get_boolean("omitsign", 0)|noSign; |
| 911 | if( db_get_boolean("clearsign", 0)==0 ){ noSign = 1; } |
| 912 | useCksum = db_get_boolean("repo-cksum", 1); |
| 913 | outputManifest = db_get_versionable_setting_boolean("manifest", 0); |
| 914 | verify_all_options(); |
| 915 | |
| 916 | /* So that older versions of Fossil (that do not understand delta- |
| 917 | ** manifest) can continue to use this repository, do not create a new |
| 918 | ** delta-manifest unless this repository already contains one or more |
| @@ -1049,11 +1049,11 @@ | |
| 1049 | ** the identified fils are inserted (if they have been modified). |
| 1050 | */ |
| 1051 | db_prepare(&q, |
| 1052 | "SELECT id, %Q || pathname, mrid, %s FROM vfile " |
| 1053 | "WHERE chnged==1 AND NOT deleted AND file_is_selected(id)", |
| 1054 | g.zLocalRoot, glob_expr("pathname", db_get_versionable_setting("crnl-glob","")) |
| 1055 | ); |
| 1056 | while( db_step(&q)==SQLITE_ROW ){ |
| 1057 | int id, rid; |
| 1058 | const char *zFullname; |
| 1059 | Blob content; |
| 1060 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -289,16 +289,16 @@ | |
| 289 | Blob rewrittenPathname; |
| 290 | const char *zPathname, *zDisplayName; |
| 291 | |
| 292 | db_must_be_within_tree(); |
| 293 | cwdRelative = determine_cwd_relative_option(); |
| 294 | outputManifest = db_get_boolean("manifest",0); |
| 295 | db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); |
| 296 | n = strlen(g.zLocalRoot); |
| 297 | blob_init(&path, g.zLocalRoot, n-1); |
| 298 | if( zIgnoreFlag==0 ){ |
| 299 | zIgnoreFlag = db_get("ignore-glob", 0); |
| 300 | } |
| 301 | pIgnore = glob_create(zIgnoreFlag); |
| 302 | vfile_scan(&path, blob_size(&path), allFlag, pIgnore); |
| 303 | glob_free(pIgnore); |
| 304 | db_prepare(&q, |
| @@ -360,11 +360,11 @@ | |
| 360 | allFlag = find_option("force","f",0)!=0; |
| 361 | dotfilesFlag = find_option("dotfiles",0,0)!=0; |
| 362 | zIgnoreFlag = find_option("ignore",0,1); |
| 363 | db_must_be_within_tree(); |
| 364 | if( zIgnoreFlag==0 ){ |
| 365 | zIgnoreFlag = db_get("ignore-glob", 0); |
| 366 | } |
| 367 | db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); |
| 368 | n = strlen(g.zLocalRoot); |
| 369 | blob_init(&path, g.zLocalRoot, n-1); |
| 370 | pIgnore = glob_create(zIgnoreFlag); |
| @@ -908,11 +908,11 @@ | |
| 908 | zUserOvrd = find_option("user-override",0,1); |
| 909 | db_must_be_within_tree(); |
| 910 | noSign = db_get_boolean("omitsign", 0)|noSign; |
| 911 | if( db_get_boolean("clearsign", 0)==0 ){ noSign = 1; } |
| 912 | useCksum = db_get_boolean("repo-cksum", 1); |
| 913 | outputManifest = db_get_boolean("manifest", 0); |
| 914 | verify_all_options(); |
| 915 | |
| 916 | /* So that older versions of Fossil (that do not understand delta- |
| 917 | ** manifest) can continue to use this repository, do not create a new |
| 918 | ** delta-manifest unless this repository already contains one or more |
| @@ -1049,11 +1049,11 @@ | |
| 1049 | ** the identified fils are inserted (if they have been modified). |
| 1050 | */ |
| 1051 | db_prepare(&q, |
| 1052 | "SELECT id, %Q || pathname, mrid, %s FROM vfile " |
| 1053 | "WHERE chnged==1 AND NOT deleted AND file_is_selected(id)", |
| 1054 | g.zLocalRoot, glob_expr("pathname", db_get("crnl-glob","")) |
| 1055 | ); |
| 1056 | while( db_step(&q)==SQLITE_ROW ){ |
| 1057 | int id, rid; |
| 1058 | const char *zFullname; |
| 1059 | Blob content; |
| 1060 |
+1
-1
| --- src/checkout.c | ||
| +++ src/checkout.c | ||
| @@ -131,11 +131,11 @@ | ||
| 131 | 131 | void manifest_to_disk(int vid){ |
| 132 | 132 | char *zManFile; |
| 133 | 133 | Blob manifest; |
| 134 | 134 | Blob hash; |
| 135 | 135 | |
| 136 | - if( db_get_versionable_setting_boolean("manifest",0) ){ | |
| 136 | + if( db_get_boolean("manifest",0) ){ | |
| 137 | 137 | blob_zero(&manifest); |
| 138 | 138 | content_get(vid, &manifest); |
| 139 | 139 | zManFile = mprintf("%smanifest", g.zLocalRoot); |
| 140 | 140 | blob_write_to_file(&manifest, zManFile); |
| 141 | 141 | free(zManFile); |
| 142 | 142 |
| --- src/checkout.c | |
| +++ src/checkout.c | |
| @@ -131,11 +131,11 @@ | |
| 131 | void manifest_to_disk(int vid){ |
| 132 | char *zManFile; |
| 133 | Blob manifest; |
| 134 | Blob hash; |
| 135 | |
| 136 | if( db_get_versionable_setting_boolean("manifest",0) ){ |
| 137 | blob_zero(&manifest); |
| 138 | content_get(vid, &manifest); |
| 139 | zManFile = mprintf("%smanifest", g.zLocalRoot); |
| 140 | blob_write_to_file(&manifest, zManFile); |
| 141 | free(zManFile); |
| 142 |
| --- src/checkout.c | |
| +++ src/checkout.c | |
| @@ -131,11 +131,11 @@ | |
| 131 | void manifest_to_disk(int vid){ |
| 132 | char *zManFile; |
| 133 | Blob manifest; |
| 134 | Blob hash; |
| 135 | |
| 136 | if( db_get_boolean("manifest",0) ){ |
| 137 | blob_zero(&manifest); |
| 138 | content_get(vid, &manifest); |
| 139 | zManFile = mprintf("%smanifest", g.zLocalRoot); |
| 140 | blob_write_to_file(&manifest, zManFile); |
| 141 | free(zManFile); |
| 142 |
M
src/db.c
+21
-17
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -1401,20 +1401,19 @@ | ||
| 1401 | 1401 | g.dbConfig = dbTemp; |
| 1402 | 1402 | } |
| 1403 | 1403 | } |
| 1404 | 1404 | |
| 1405 | 1405 | /* |
| 1406 | -** Get a potentially versioned setting - either from .fossil-settings/<name> | |
| 1407 | -** if we have a local checkout and that file exists, or from the | |
| 1408 | -** CONFIG or GLOBAL_CONFIG tables if we are running in server mode | |
| 1409 | -** (without a local checkout) or if the file does not exist. | |
| 1406 | +** Logic for reading potentially versioned settings from | |
| 1407 | +** .fossil-settings/<name> , and emits warnings if necessary. | |
| 1408 | +** Returns the non-versioned value without modification if there is no | |
| 1409 | +** versioned value. | |
| 1410 | 1410 | */ |
| 1411 | -char *db_get_versionable_setting(const char *zName, char *zDefault){ | |
| 1411 | +static char *db_get_do_versionable(const char *zName, char *zNonVersionedSetting){ | |
| 1412 | 1412 | /* Attempt to load the versioned setting from a checked out file */ |
| 1413 | 1413 | char *zVersionedSetting = 0; |
| 1414 | 1414 | int noWarn = 0; |
| 1415 | - char *zSetting = 0; | |
| 1416 | 1415 | |
| 1417 | 1416 | if( db_open_local() ){ |
| 1418 | 1417 | Blob versionedPathname; |
| 1419 | 1418 | char *zVersionedPathname; |
| 1420 | 1419 | blob_zero(&versionedPathname); |
| @@ -1438,15 +1437,13 @@ | ||
| 1438 | 1437 | noWarn = 1; |
| 1439 | 1438 | } |
| 1440 | 1439 | } |
| 1441 | 1440 | blob_reset(&versionedPathname); |
| 1442 | 1441 | } |
| 1443 | - /* Load the normal, non-versioned setting */ | |
| 1444 | - zSetting = db_get(zName, zDefault); | |
| 1445 | 1442 | /* Display a warning? */ |
| 1446 | - if( zVersionedSetting!=0 && zSetting!=0 && zSetting[0]!='\0' | |
| 1447 | - && zSetting!=zDefault && !noWarn | |
| 1443 | + if( zVersionedSetting!=0 && zNonVersionedSetting!=0 | |
| 1444 | + && zNonVersionedSetting[0]!='\0' && !noWarn | |
| 1448 | 1445 | ){ |
| 1449 | 1446 | /* There's a versioned setting, and a non-versioned setting. Tell |
| 1450 | 1447 | ** the user about the conflict */ |
| 1451 | 1448 | fossil_warning( |
| 1452 | 1449 | "setting %s has both versioned and non-versioned values: using " |
| @@ -1455,33 +1452,40 @@ | ||
| 1455 | 1452 | ".fossil-settings/%s.no-warn or delete the non-versioned setting " |
| 1456 | 1453 | " with \"fossil unset %s\")", zName, zName, zName, zName |
| 1457 | 1454 | ); |
| 1458 | 1455 | } |
| 1459 | 1456 | /* Prefer the versioned setting */ |
| 1460 | - return ( zVersionedSetting!=0 ) ? zVersionedSetting : zSetting; | |
| 1461 | -} | |
| 1462 | -int db_get_versionable_setting_boolean(const char *zName, int dflt){ | |
| 1463 | - char *zVal = db_get_versionable_setting(zName, dflt ? "on" : "off"); | |
| 1464 | - if( is_truth(zVal) ) return 1; | |
| 1465 | - if( is_false(zVal) ) return 0; | |
| 1466 | - return dflt; | |
| 1457 | + return ( zVersionedSetting!=0 ) ? zVersionedSetting : zNonVersionedSetting; | |
| 1467 | 1458 | } |
| 1468 | 1459 | |
| 1469 | 1460 | |
| 1470 | 1461 | /* |
| 1471 | 1462 | ** Get and set values from the CONFIG, GLOBAL_CONFIG and VVAR table in the |
| 1472 | 1463 | ** repository and local databases. |
| 1473 | 1464 | */ |
| 1474 | 1465 | char *db_get(const char *zName, char *zDefault){ |
| 1475 | 1466 | char *z = 0; |
| 1467 | + int i; | |
| 1468 | + const struct stControlSettings *ctrlSetting = 0; | |
| 1469 | + /* Is this a setting? */ | |
| 1470 | + for(i=0; ctrlSettings[i].name; i++){ | |
| 1471 | + if( strcmp(ctrlSettings[i].name, zName)==0 ){ | |
| 1472 | + ctrlSetting = &(ctrlSettings[i]); | |
| 1473 | + break; | |
| 1474 | + } | |
| 1475 | + } | |
| 1476 | 1476 | if( g.repositoryOpen ){ |
| 1477 | 1477 | z = db_text(0, "SELECT value FROM config WHERE name=%Q", zName); |
| 1478 | 1478 | } |
| 1479 | 1479 | if( z==0 && g.configOpen ){ |
| 1480 | 1480 | db_swap_connections(); |
| 1481 | 1481 | z = db_text(0, "SELECT value FROM global_config WHERE name=%Q", zName); |
| 1482 | 1482 | db_swap_connections(); |
| 1483 | + } | |
| 1484 | + if( ctrlSetting!=0 && ctrlSetting->versionable ){ | |
| 1485 | + /* This is a versionable setting, try and get the info from a checked out file */ | |
| 1486 | + z = db_get_do_versionable(zName, z); | |
| 1483 | 1487 | } |
| 1484 | 1488 | if( z==0 ){ |
| 1485 | 1489 | z = zDefault; |
| 1486 | 1490 | } |
| 1487 | 1491 | return z; |
| 1488 | 1492 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -1401,20 +1401,19 @@ | |
| 1401 | g.dbConfig = dbTemp; |
| 1402 | } |
| 1403 | } |
| 1404 | |
| 1405 | /* |
| 1406 | ** Get a potentially versioned setting - either from .fossil-settings/<name> |
| 1407 | ** if we have a local checkout and that file exists, or from the |
| 1408 | ** CONFIG or GLOBAL_CONFIG tables if we are running in server mode |
| 1409 | ** (without a local checkout) or if the file does not exist. |
| 1410 | */ |
| 1411 | char *db_get_versionable_setting(const char *zName, char *zDefault){ |
| 1412 | /* Attempt to load the versioned setting from a checked out file */ |
| 1413 | char *zVersionedSetting = 0; |
| 1414 | int noWarn = 0; |
| 1415 | char *zSetting = 0; |
| 1416 | |
| 1417 | if( db_open_local() ){ |
| 1418 | Blob versionedPathname; |
| 1419 | char *zVersionedPathname; |
| 1420 | blob_zero(&versionedPathname); |
| @@ -1438,15 +1437,13 @@ | |
| 1438 | noWarn = 1; |
| 1439 | } |
| 1440 | } |
| 1441 | blob_reset(&versionedPathname); |
| 1442 | } |
| 1443 | /* Load the normal, non-versioned setting */ |
| 1444 | zSetting = db_get(zName, zDefault); |
| 1445 | /* Display a warning? */ |
| 1446 | if( zVersionedSetting!=0 && zSetting!=0 && zSetting[0]!='\0' |
| 1447 | && zSetting!=zDefault && !noWarn |
| 1448 | ){ |
| 1449 | /* There's a versioned setting, and a non-versioned setting. Tell |
| 1450 | ** the user about the conflict */ |
| 1451 | fossil_warning( |
| 1452 | "setting %s has both versioned and non-versioned values: using " |
| @@ -1455,33 +1452,40 @@ | |
| 1455 | ".fossil-settings/%s.no-warn or delete the non-versioned setting " |
| 1456 | " with \"fossil unset %s\")", zName, zName, zName, zName |
| 1457 | ); |
| 1458 | } |
| 1459 | /* Prefer the versioned setting */ |
| 1460 | return ( zVersionedSetting!=0 ) ? zVersionedSetting : zSetting; |
| 1461 | } |
| 1462 | int db_get_versionable_setting_boolean(const char *zName, int dflt){ |
| 1463 | char *zVal = db_get_versionable_setting(zName, dflt ? "on" : "off"); |
| 1464 | if( is_truth(zVal) ) return 1; |
| 1465 | if( is_false(zVal) ) return 0; |
| 1466 | return dflt; |
| 1467 | } |
| 1468 | |
| 1469 | |
| 1470 | /* |
| 1471 | ** Get and set values from the CONFIG, GLOBAL_CONFIG and VVAR table in the |
| 1472 | ** repository and local databases. |
| 1473 | */ |
| 1474 | char *db_get(const char *zName, char *zDefault){ |
| 1475 | char *z = 0; |
| 1476 | if( g.repositoryOpen ){ |
| 1477 | z = db_text(0, "SELECT value FROM config WHERE name=%Q", zName); |
| 1478 | } |
| 1479 | if( z==0 && g.configOpen ){ |
| 1480 | db_swap_connections(); |
| 1481 | z = db_text(0, "SELECT value FROM global_config WHERE name=%Q", zName); |
| 1482 | db_swap_connections(); |
| 1483 | } |
| 1484 | if( z==0 ){ |
| 1485 | z = zDefault; |
| 1486 | } |
| 1487 | return z; |
| 1488 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -1401,20 +1401,19 @@ | |
| 1401 | g.dbConfig = dbTemp; |
| 1402 | } |
| 1403 | } |
| 1404 | |
| 1405 | /* |
| 1406 | ** Logic for reading potentially versioned settings from |
| 1407 | ** .fossil-settings/<name> , and emits warnings if necessary. |
| 1408 | ** Returns the non-versioned value without modification if there is no |
| 1409 | ** versioned value. |
| 1410 | */ |
| 1411 | static char *db_get_do_versionable(const char *zName, char *zNonVersionedSetting){ |
| 1412 | /* Attempt to load the versioned setting from a checked out file */ |
| 1413 | char *zVersionedSetting = 0; |
| 1414 | int noWarn = 0; |
| 1415 | |
| 1416 | if( db_open_local() ){ |
| 1417 | Blob versionedPathname; |
| 1418 | char *zVersionedPathname; |
| 1419 | blob_zero(&versionedPathname); |
| @@ -1438,15 +1437,13 @@ | |
| 1437 | noWarn = 1; |
| 1438 | } |
| 1439 | } |
| 1440 | blob_reset(&versionedPathname); |
| 1441 | } |
| 1442 | /* Display a warning? */ |
| 1443 | if( zVersionedSetting!=0 && zNonVersionedSetting!=0 |
| 1444 | && zNonVersionedSetting[0]!='\0' && !noWarn |
| 1445 | ){ |
| 1446 | /* There's a versioned setting, and a non-versioned setting. Tell |
| 1447 | ** the user about the conflict */ |
| 1448 | fossil_warning( |
| 1449 | "setting %s has both versioned and non-versioned values: using " |
| @@ -1455,33 +1452,40 @@ | |
| 1452 | ".fossil-settings/%s.no-warn or delete the non-versioned setting " |
| 1453 | " with \"fossil unset %s\")", zName, zName, zName, zName |
| 1454 | ); |
| 1455 | } |
| 1456 | /* Prefer the versioned setting */ |
| 1457 | return ( zVersionedSetting!=0 ) ? zVersionedSetting : zNonVersionedSetting; |
| 1458 | } |
| 1459 | |
| 1460 | |
| 1461 | /* |
| 1462 | ** Get and set values from the CONFIG, GLOBAL_CONFIG and VVAR table in the |
| 1463 | ** repository and local databases. |
| 1464 | */ |
| 1465 | char *db_get(const char *zName, char *zDefault){ |
| 1466 | char *z = 0; |
| 1467 | int i; |
| 1468 | const struct stControlSettings *ctrlSetting = 0; |
| 1469 | /* Is this a setting? */ |
| 1470 | for(i=0; ctrlSettings[i].name; i++){ |
| 1471 | if( strcmp(ctrlSettings[i].name, zName)==0 ){ |
| 1472 | ctrlSetting = &(ctrlSettings[i]); |
| 1473 | break; |
| 1474 | } |
| 1475 | } |
| 1476 | if( g.repositoryOpen ){ |
| 1477 | z = db_text(0, "SELECT value FROM config WHERE name=%Q", zName); |
| 1478 | } |
| 1479 | if( z==0 && g.configOpen ){ |
| 1480 | db_swap_connections(); |
| 1481 | z = db_text(0, "SELECT value FROM global_config WHERE name=%Q", zName); |
| 1482 | db_swap_connections(); |
| 1483 | } |
| 1484 | if( ctrlSetting!=0 && ctrlSetting->versionable ){ |
| 1485 | /* This is a versionable setting, try and get the info from a checked out file */ |
| 1486 | z = db_get_do_versionable(zName, z); |
| 1487 | } |
| 1488 | if( z==0 ){ |
| 1489 | z = zDefault; |
| 1490 | } |
| 1491 | return z; |
| 1492 |
+1
-1
| --- src/merge.c | ||
| +++ src/merge.c | ||
| @@ -98,11 +98,11 @@ | ||
| 98 | 98 | if( g.argc!=3 ){ |
| 99 | 99 | usage("VERSION"); |
| 100 | 100 | } |
| 101 | 101 | db_must_be_within_tree(); |
| 102 | 102 | caseSensitive = filenames_are_case_sensitive(); |
| 103 | - if( zBinGlob==0 ) zBinGlob = db_get_versionable_setting("binary-glob",0); | |
| 103 | + if( zBinGlob==0 ) zBinGlob = db_get("binary-glob",0); | |
| 104 | 104 | vid = db_lget_int("checkout", 0); |
| 105 | 105 | if( vid==0 ){ |
| 106 | 106 | fossil_fatal("nothing is checked out"); |
| 107 | 107 | } |
| 108 | 108 | mid = name_to_typed_rid(g.argv[2], "ci"); |
| 109 | 109 |
| --- src/merge.c | |
| +++ src/merge.c | |
| @@ -98,11 +98,11 @@ | |
| 98 | if( g.argc!=3 ){ |
| 99 | usage("VERSION"); |
| 100 | } |
| 101 | db_must_be_within_tree(); |
| 102 | caseSensitive = filenames_are_case_sensitive(); |
| 103 | if( zBinGlob==0 ) zBinGlob = db_get_versionable_setting("binary-glob",0); |
| 104 | vid = db_lget_int("checkout", 0); |
| 105 | if( vid==0 ){ |
| 106 | fossil_fatal("nothing is checked out"); |
| 107 | } |
| 108 | mid = name_to_typed_rid(g.argv[2], "ci"); |
| 109 |
| --- src/merge.c | |
| +++ src/merge.c | |
| @@ -98,11 +98,11 @@ | |
| 98 | if( g.argc!=3 ){ |
| 99 | usage("VERSION"); |
| 100 | } |
| 101 | db_must_be_within_tree(); |
| 102 | caseSensitive = filenames_are_case_sensitive(); |
| 103 | if( zBinGlob==0 ) zBinGlob = db_get("binary-glob",0); |
| 104 | vid = db_lget_int("checkout", 0); |
| 105 | if( vid==0 ){ |
| 106 | fossil_fatal("nothing is checked out"); |
| 107 | } |
| 108 | mid = name_to_typed_rid(g.argv[2], "ci"); |
| 109 |
+1
-1
| --- src/tar.c | ||
| +++ src/tar.c | ||
| @@ -466,11 +466,11 @@ | ||
| 466 | 466 | nPrefix = blob_size(&filename); |
| 467 | 467 | |
| 468 | 468 | pManifest = manifest_get(rid, CFTYPE_MANIFEST); |
| 469 | 469 | if( pManifest ){ |
| 470 | 470 | mTime = (pManifest->rDate - 2440587.5)*86400.0; |
| 471 | - if( db_get_versionable_setting_boolean("manifest", 0) ){ | |
| 471 | + if( db_get_boolean("manifest", 0) ){ | |
| 472 | 472 | blob_append(&filename, "manifest", -1); |
| 473 | 473 | zName = blob_str(&filename); |
| 474 | 474 | tar_add_file(zName, &mfile, 0, mTime); |
| 475 | 475 | sha1sum_blob(&mfile, &hash); |
| 476 | 476 | blob_reset(&mfile); |
| 477 | 477 |
| --- src/tar.c | |
| +++ src/tar.c | |
| @@ -466,11 +466,11 @@ | |
| 466 | nPrefix = blob_size(&filename); |
| 467 | |
| 468 | pManifest = manifest_get(rid, CFTYPE_MANIFEST); |
| 469 | if( pManifest ){ |
| 470 | mTime = (pManifest->rDate - 2440587.5)*86400.0; |
| 471 | if( db_get_versionable_setting_boolean("manifest", 0) ){ |
| 472 | blob_append(&filename, "manifest", -1); |
| 473 | zName = blob_str(&filename); |
| 474 | tar_add_file(zName, &mfile, 0, mTime); |
| 475 | sha1sum_blob(&mfile, &hash); |
| 476 | blob_reset(&mfile); |
| 477 |
| --- src/tar.c | |
| +++ src/tar.c | |
| @@ -466,11 +466,11 @@ | |
| 466 | nPrefix = blob_size(&filename); |
| 467 | |
| 468 | pManifest = manifest_get(rid, CFTYPE_MANIFEST); |
| 469 | if( pManifest ){ |
| 470 | mTime = (pManifest->rDate - 2440587.5)*86400.0; |
| 471 | if( db_get_boolean("manifest", 0) ){ |
| 472 | blob_append(&filename, "manifest", -1); |
| 473 | zName = blob_str(&filename); |
| 474 | tar_add_file(zName, &mfile, 0, mTime); |
| 475 | sha1sum_blob(&mfile, &hash); |
| 476 | blob_reset(&mfile); |
| 477 |
+1
-1
| --- src/update.c | ||
| +++ src/update.c | ||
| @@ -466,11 +466,11 @@ | ||
| 466 | 466 | /* |
| 467 | 467 | ** Make sure empty directories are created |
| 468 | 468 | */ |
| 469 | 469 | void ensure_empty_dirs_created(void){ |
| 470 | 470 | /* Make empty directories? */ |
| 471 | - char *zEmptyDirs = db_get_versionable_setting("empty-dirs", 0); | |
| 471 | + char *zEmptyDirs = db_get("empty-dirs", 0); | |
| 472 | 472 | if( zEmptyDirs!=0 ){ |
| 473 | 473 | char *bc; |
| 474 | 474 | Blob dirName; |
| 475 | 475 | Blob dirsList; |
| 476 | 476 | |
| 477 | 477 |
| --- src/update.c | |
| +++ src/update.c | |
| @@ -466,11 +466,11 @@ | |
| 466 | /* |
| 467 | ** Make sure empty directories are created |
| 468 | */ |
| 469 | void ensure_empty_dirs_created(void){ |
| 470 | /* Make empty directories? */ |
| 471 | char *zEmptyDirs = db_get_versionable_setting("empty-dirs", 0); |
| 472 | if( zEmptyDirs!=0 ){ |
| 473 | char *bc; |
| 474 | Blob dirName; |
| 475 | Blob dirsList; |
| 476 | |
| 477 |
| --- src/update.c | |
| +++ src/update.c | |
| @@ -466,11 +466,11 @@ | |
| 466 | /* |
| 467 | ** Make sure empty directories are created |
| 468 | */ |
| 469 | void ensure_empty_dirs_created(void){ |
| 470 | /* Make empty directories? */ |
| 471 | char *zEmptyDirs = db_get("empty-dirs", 0); |
| 472 | if( zEmptyDirs!=0 ){ |
| 473 | char *bc; |
| 474 | Blob dirName; |
| 475 | Blob dirsList; |
| 476 | |
| 477 |
+1
-1
| --- src/zip.c | ||
| +++ src/zip.c | ||
| @@ -337,11 +337,11 @@ | ||
| 337 | 337 | |
| 338 | 338 | pManifest = manifest_get(rid, CFTYPE_MANIFEST); |
| 339 | 339 | if( pManifest ){ |
| 340 | 340 | char *zName; |
| 341 | 341 | zip_set_timedate(pManifest->rDate); |
| 342 | - if( db_get_versionable_setting_boolean("manifest", 0) ){ | |
| 342 | + if( db_get_boolean("manifest", 0) ){ | |
| 343 | 343 | blob_append(&filename, "manifest", -1); |
| 344 | 344 | zName = blob_str(&filename); |
| 345 | 345 | zip_add_folders(zName); |
| 346 | 346 | zip_add_file(zName, &mfile, 0); |
| 347 | 347 | sha1sum_blob(&mfile, &hash); |
| 348 | 348 |
| --- src/zip.c | |
| +++ src/zip.c | |
| @@ -337,11 +337,11 @@ | |
| 337 | |
| 338 | pManifest = manifest_get(rid, CFTYPE_MANIFEST); |
| 339 | if( pManifest ){ |
| 340 | char *zName; |
| 341 | zip_set_timedate(pManifest->rDate); |
| 342 | if( db_get_versionable_setting_boolean("manifest", 0) ){ |
| 343 | blob_append(&filename, "manifest", -1); |
| 344 | zName = blob_str(&filename); |
| 345 | zip_add_folders(zName); |
| 346 | zip_add_file(zName, &mfile, 0); |
| 347 | sha1sum_blob(&mfile, &hash); |
| 348 |
| --- src/zip.c | |
| +++ src/zip.c | |
| @@ -337,11 +337,11 @@ | |
| 337 | |
| 338 | pManifest = manifest_get(rid, CFTYPE_MANIFEST); |
| 339 | if( pManifest ){ |
| 340 | char *zName; |
| 341 | zip_set_timedate(pManifest->rDate); |
| 342 | if( db_get_boolean("manifest", 0) ){ |
| 343 | blob_append(&filename, "manifest", -1); |
| 344 | zName = blob_str(&filename); |
| 345 | zip_add_folders(zName); |
| 346 | zip_add_file(zName, &mfile, 0); |
| 347 | sha1sum_blob(&mfile, &hash); |
| 348 |