Fossil SCM

Revise the algorithm for finding the configuration database on unix. The algorithm is now approximately this: (1) Use the ~/.fossil name if such a file exists. (2) Use ~/.config/fossil.db if the ~/.config directory exists (3) Otherwise use ~/.fossil See [/doc/$CURRENT/www/tech_overview.wiki#configloc|www/tech_overview.wiki] for details.

drh 2020-04-19 14:06 trunk
Commit 4645e9bb1aaaf0cc66e4aaa77ad63efa2aaa7ceef3dbb0f2115b808be6f5cb7b
3 files changed +109 -69 +18 -51 +28 -16
+109 -69
--- src/db.c
+++ src/db.c
@@ -18,11 +18,12 @@
1818
** Code for interfacing to the various databases.
1919
**
2020
** There are three separate database files that fossil interacts
2121
** with:
2222
**
23
-** (1) The "user" database in ~/.fossil
23
+** (1) The "configdb" database in ~/.fossil or ~/.config/fossil.db
24
+** or in %LOCALAPPDATA%/_fossil
2425
**
2526
** (2) The "repository" database
2627
**
2728
** (3) A local checkout database named "_FOSSIL_" or ".fslckout"
2829
** and located at the root of the local copy of the source tree.
@@ -1369,11 +1370,11 @@
13691370
db_attach(zDbName, zLabel);
13701371
}
13711372
}
13721373
13731374
/*
1374
-** Close the per-user database file in ~/.fossil
1375
+** Close the per-user configuration database file
13751376
*/
13761377
void db_close_config(){
13771378
int iSlot = db_database_slot("configdb");
13781379
if( iSlot>0 ){
13791380
db_detach("configdb");
@@ -1393,33 +1394,30 @@
13931394
fossil_free(g.zConfigDbName);
13941395
g.zConfigDbName = 0;
13951396
}
13961397
13971398
/*
1398
-** Open the user database in "~/.fossil". Create the database anew if
1399
-** it does not already exist.
1399
+** Compute the name of the configuration database. If unable to find the
1400
+** database, return 0 if isOptional is true, or panic if isOptional is false.
14001401
**
1401
-** If the useAttach flag is 0 (the usual case) then the user database is
1402
-** opened on a separate database connection g.dbConfig. This prevents
1403
-** the ~/.fossil database from becoming locked on long check-in or sync
1404
-** operations which hold an exclusive transaction. In a few cases, though,
1405
-** it is convenient for the ~/.fossil to be attached to the main database
1406
-** connection so that we can join between the various databases. In that
1407
-** case, invoke this routine with useAttach as 1.
1402
+** Space to hold the result comes from fossil_malloc().
14081403
*/
1409
-int db_open_config(int useAttach, int isOptional){
1410
- char *zDbName;
1411
- char *zHome;
1412
- const char *zRoot;
1413
- if( g.zConfigDbName ){
1414
- int alreadyAttached = db_database_slot("configdb")>0;
1415
- if( useAttach==alreadyAttached ) return 1; /* Already open. */
1416
- db_close_config();
1417
- }
1418
- zHome = fossil_getenv("FOSSIL_HOME");
1404
+static char *db_configdb_name(int isOptional){
1405
+ char *zHome; /* Home directory */
1406
+ char *zDbName; /* Name of the database file */
1407
+
1408
+
1409
+ /* On Windows, look for these directories, in order:
1410
+ **
1411
+ ** FOSSIL_HOME
1412
+ ** LOCALAPPDATA
1413
+ ** APPDATA
1414
+ ** USERPROFILE
1415
+ ** HOMEDRIVE HOMEPATH
1416
+ */
14191417
#if defined(_WIN32) || defined(__CYGWIN__)
1420
- zRoot = "_fossil";
1418
+ zHome = fossil_getenv("FOSSIL_HOME");
14211419
if( zHome==0 ){
14221420
zHome = fossil_getenv("LOCALAPPDATA");
14231421
if( zHome==0 ){
14241422
zHome = fossil_getenv("APPDATA");
14251423
if( zHome==0 ){
@@ -1430,47 +1428,90 @@
14301428
if( zDrive && zPath ) zHome = mprintf("%s%s", zDrive, zPath);
14311429
}
14321430
}
14331431
}
14341432
}
1435
- if( zHome==0 ){
1436
- if( isOptional ) return 0;
1437
- fossil_panic("cannot locate home directory - please set the "
1438
- "FOSSIL_HOME, LOCALAPPDATA, APPDATA, USERPROFILE, "
1439
- "or HOMEDRIVE / HOMEPATH environment variables");
1440
- }
1441
-#else
1442
- zRoot = ".fossil";
1443
- if( zHome==0 ){
1444
- zHome = fossil_getenv("XDG_CONFIG_HOME");
1445
- if( zHome ){
1446
- zRoot = "fossil.db";
1447
- }else{
1448
- zHome = fossil_getenv("HOME");
1449
- if( zHome==0 ){
1450
- if( isOptional ) return 0;
1451
- fossil_panic("cannot locate home directory - please set one of the "
1452
- "FOSSIL_HOME, XDG_CONFIG_HOME, or HOME environment "
1453
- "variables");
1454
- }
1455
- }
1456
- }
1457
-#endif
1458
- if( file_isdir(zHome, ExtFILE)!=1 ){
1459
- if( isOptional ) return 0;
1460
- fossil_panic("invalid home directory: %s", zHome);
1461
- }
1462
-#if defined(_WIN32) || defined(__CYGWIN__)
1463
- /* . filenames give some window systems problems and many apps problems */
1464
- zDbName = mprintf("%//%s", zHome, zRoot);
1465
-#else
1466
- zDbName = mprintf("%s/%s", zHome, zRoot);
1467
-#endif
1468
- if( file_size(zDbName, ExtFILE)<1024*3 ){
1469
- if( file_access(zHome, W_OK) ){
1470
- if( isOptional ) return 0;
1471
- fossil_panic("home directory %s must be writeable", zHome);
1433
+ zDbName = mprintf("%//_fossil", zHome);
1434
+ fossil_free(zHome);
1435
+ return zDbName;
1436
+
1437
+#else /* if unix */
1438
+ char *zXdgHome;
1439
+
1440
+ /* For unix. a 5-step algorithm is used.
1441
+ ** See ../www/tech_overview.wiki for discussion.
1442
+ **
1443
+ ** Step 1: If FOSSIL_HOME exists -> $FOSSIL_HOME/.fossil
1444
+ */
1445
+ zHome = fossil_getenv("FOSSIL_HOME");
1446
+ if( zHome!=0 ) return mprintf("%s/.fossil", zHome);
1447
+
1448
+ /* Step 2: If HOME exists and file $HOME/.fossil exists -> $HOME/.fossil
1449
+ */
1450
+ zHome = fossil_getenv("HOME");
1451
+ if( zHome ){
1452
+ zDbName = mprintf("%s/.fossil", zHome);
1453
+ if( file_size(zDbName, ExtFILE)>1024*3 ){
1454
+ return zDbName;
1455
+ }
1456
+ fossil_free(zDbName);
1457
+ }
1458
+
1459
+ /* Step 3: if XDG_CONFIG_HOME exists -> $XDG_CONFIG_HOME/fossil.db
1460
+ */
1461
+ zXdgHome = fossil_getenv("XDG_CONFIG_HOME");
1462
+ if( zXdgHome!=0 ){
1463
+ return mprintf("%s/fossil.db", zXdgHome);
1464
+ }
1465
+
1466
+ /* Step 4: If HOME does not exist -> ERROR
1467
+ */
1468
+ if( zHome==0 ){
1469
+ if( isOptional ) return 0;
1470
+ fossil_panic("cannot locate home directory - please set one of the "
1471
+ "FOSSIL_HOME, XDG_CONFIG_HOME, or HOME environment "
1472
+ "variables");
1473
+ }
1474
+
1475
+ /* Step 5: Otherwise -> $HOME/.config/fossil.db
1476
+ */
1477
+ return mprintf("%s/.config/fossil.db", zHome);
1478
+#endif /* unix */
1479
+}
1480
+
1481
+/*
1482
+** Open the configuration database. Create the database anew if
1483
+** it does not already exist.
1484
+**
1485
+** If the useAttach flag is 0 (the usual case) then the configuration
1486
+** database is opened on a separate database connection g.dbConfig.
1487
+** This prevents the database from becoming locked on long check-in or sync
1488
+** operations which hold an exclusive transaction. In a few cases, though,
1489
+** it is convenient for the database to be attached to the main database
1490
+** connection so that we can join between the various databases. In that
1491
+** case, invoke this routine with useAttach as 1.
1492
+*/
1493
+int db_open_config(int useAttach, int isOptional){
1494
+ char *zDbName;
1495
+ if( g.zConfigDbName ){
1496
+ int alreadyAttached = db_database_slot("configdb")>0;
1497
+ if( useAttach==alreadyAttached ) return 1; /* Already open. */
1498
+ db_close_config();
1499
+ }
1500
+ zDbName = db_configdb_name(isOptional);
1501
+ if( zDbName==0 ) return 0;
1502
+ if( file_size(zDbName, ExtFILE)<1024*3 ){
1503
+ char *zHome = file_dirname(zDbName);
1504
+ int rc;
1505
+ if( file_isdir(zHome, ExtFILE)==0 ){
1506
+ file_mkdir(zHome, ExtFILE, 0);
1507
+ }
1508
+ rc = file_access(zHome, W_OK);
1509
+ fossil_free(zHome);
1510
+ if( rc ){
1511
+ if( isOptional ) return 0;
1512
+ fossil_panic("home directory \"%s\" must be writeable", zHome);
14721513
}
14731514
db_init_database(zDbName, zConfigSchema, (char*)0);
14741515
}
14751516
if( file_access(zDbName, W_OK) ){
14761517
if( isOptional ) return 0;
@@ -2515,16 +2556,16 @@
25152556
return 0;
25162557
}
25172558
25182559
/*
25192560
** Swap the g.db and g.dbConfig connections so that the various db_* routines
2520
-** work on the ~/.fossil database instead of on the repository database.
2561
+** work on the configuration database instead of on the repository database.
25212562
** Be sure to swap them back after doing the operation.
25222563
**
2523
-** If the ~/.fossil database has already been opened as the main database or
2524
-** is attached to the main database, no connection swaps are required so this
2525
-** routine is a no-op.
2564
+** If the configuration database has already been opened as the main database
2565
+** or is attached to the main database, no connection swaps are required so
2566
+** this routine is a no-op.
25262567
*/
25272568
void db_swap_connections(void){
25282569
/*
25292570
** When swapping the main database connection with the config database
25302571
** connection, the config database connection must be open (not simply
@@ -3729,14 +3770,13 @@
37293770
** The "unset" command clears a setting.
37303771
**
37313772
** Settings can have both a "local" repository-only value and "global" value
37323773
** that applies to all repositories. The local values are stored in the
37333774
** "config" table of the repository and the global values are stored in the
3734
-** $HOME/.fossil file on unix or in the %LOCALAPPDATA%/_fossil file on Windows.
3735
-** If both a local and a global value exists for a setting, the local value
3736
-** takes precedence. This command normally operates on the local settings.
3737
-** Use the --global option to change global settings.
3775
+** configuration database. If both a local and a global value exists for a
3776
+** setting, the local value takes precedence. This command normally operates
3777
+** on the local settings. Use the --global option to change global settings.
37383778
**
37393779
** Options:
37403780
** --global set or unset the given property globally instead of
37413781
** setting or unsetting it for the open repository only.
37423782
**
@@ -3867,12 +3907,12 @@
38673907
** COMMAND: test-without-rowid
38683908
**
38693909
** Usage: %fossil test-without-rowid FILENAME...
38703910
**
38713911
** Change the Fossil repository FILENAME to make use of the WITHOUT ROWID
3872
-** optimization. FILENAME can also be the ~/.fossil file or a local
3873
-** .fslckout or _FOSSIL_ file.
3912
+** optimization. FILENAME can also be the configuration database file
3913
+** (~/.fossil or ~/.config/fossil.db) or a local .fslckout or _FOSSIL_ file.
38743914
**
38753915
** The purpose of this command is for testing the WITHOUT ROWID capabilities
38763916
** of SQLite. There is no big advantage to using WITHOUT ROWID in Fossil.
38773917
**
38783918
** Options:
38793919
--- src/db.c
+++ src/db.c
@@ -18,11 +18,12 @@
18 ** Code for interfacing to the various databases.
19 **
20 ** There are three separate database files that fossil interacts
21 ** with:
22 **
23 ** (1) The "user" database in ~/.fossil
 
24 **
25 ** (2) The "repository" database
26 **
27 ** (3) A local checkout database named "_FOSSIL_" or ".fslckout"
28 ** and located at the root of the local copy of the source tree.
@@ -1369,11 +1370,11 @@
1369 db_attach(zDbName, zLabel);
1370 }
1371 }
1372
1373 /*
1374 ** Close the per-user database file in ~/.fossil
1375 */
1376 void db_close_config(){
1377 int iSlot = db_database_slot("configdb");
1378 if( iSlot>0 ){
1379 db_detach("configdb");
@@ -1393,33 +1394,30 @@
1393 fossil_free(g.zConfigDbName);
1394 g.zConfigDbName = 0;
1395 }
1396
1397 /*
1398 ** Open the user database in "~/.fossil". Create the database anew if
1399 ** it does not already exist.
1400 **
1401 ** If the useAttach flag is 0 (the usual case) then the user database is
1402 ** opened on a separate database connection g.dbConfig. This prevents
1403 ** the ~/.fossil database from becoming locked on long check-in or sync
1404 ** operations which hold an exclusive transaction. In a few cases, though,
1405 ** it is convenient for the ~/.fossil to be attached to the main database
1406 ** connection so that we can join between the various databases. In that
1407 ** case, invoke this routine with useAttach as 1.
1408 */
1409 int db_open_config(int useAttach, int isOptional){
1410 char *zDbName;
1411 char *zHome;
1412 const char *zRoot;
1413 if( g.zConfigDbName ){
1414 int alreadyAttached = db_database_slot("configdb")>0;
1415 if( useAttach==alreadyAttached ) return 1; /* Already open. */
1416 db_close_config();
1417 }
1418 zHome = fossil_getenv("FOSSIL_HOME");
 
 
 
1419 #if defined(_WIN32) || defined(__CYGWIN__)
1420 zRoot = "_fossil";
1421 if( zHome==0 ){
1422 zHome = fossil_getenv("LOCALAPPDATA");
1423 if( zHome==0 ){
1424 zHome = fossil_getenv("APPDATA");
1425 if( zHome==0 ){
@@ -1430,47 +1428,90 @@
1430 if( zDrive && zPath ) zHome = mprintf("%s%s", zDrive, zPath);
1431 }
1432 }
1433 }
1434 }
1435 if( zHome==0 ){
1436 if( isOptional ) return 0;
1437 fossil_panic("cannot locate home directory - please set the "
1438 "FOSSIL_HOME, LOCALAPPDATA, APPDATA, USERPROFILE, "
1439 "or HOMEDRIVE / HOMEPATH environment variables");
1440 }
1441 #else
1442 zRoot = ".fossil";
1443 if( zHome==0 ){
1444 zHome = fossil_getenv("XDG_CONFIG_HOME");
1445 if( zHome ){
1446 zRoot = "fossil.db";
1447 }else{
1448 zHome = fossil_getenv("HOME");
1449 if( zHome==0 ){
1450 if( isOptional ) return 0;
1451 fossil_panic("cannot locate home directory - please set one of the "
1452 "FOSSIL_HOME, XDG_CONFIG_HOME, or HOME environment "
1453 "variables");
1454 }
1455 }
1456 }
1457 #endif
1458 if( file_isdir(zHome, ExtFILE)!=1 ){
1459 if( isOptional ) return 0;
1460 fossil_panic("invalid home directory: %s", zHome);
1461 }
1462 #if defined(_WIN32) || defined(__CYGWIN__)
1463 /* . filenames give some window systems problems and many apps problems */
1464 zDbName = mprintf("%//%s", zHome, zRoot);
1465 #else
1466 zDbName = mprintf("%s/%s", zHome, zRoot);
1467 #endif
1468 if( file_size(zDbName, ExtFILE)<1024*3 ){
1469 if( file_access(zHome, W_OK) ){
1470 if( isOptional ) return 0;
1471 fossil_panic("home directory %s must be writeable", zHome);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1472 }
1473 db_init_database(zDbName, zConfigSchema, (char*)0);
1474 }
1475 if( file_access(zDbName, W_OK) ){
1476 if( isOptional ) return 0;
@@ -2515,16 +2556,16 @@
2515 return 0;
2516 }
2517
2518 /*
2519 ** Swap the g.db and g.dbConfig connections so that the various db_* routines
2520 ** work on the ~/.fossil database instead of on the repository database.
2521 ** Be sure to swap them back after doing the operation.
2522 **
2523 ** If the ~/.fossil database has already been opened as the main database or
2524 ** is attached to the main database, no connection swaps are required so this
2525 ** routine is a no-op.
2526 */
2527 void db_swap_connections(void){
2528 /*
2529 ** When swapping the main database connection with the config database
2530 ** connection, the config database connection must be open (not simply
@@ -3729,14 +3770,13 @@
3729 ** The "unset" command clears a setting.
3730 **
3731 ** Settings can have both a "local" repository-only value and "global" value
3732 ** that applies to all repositories. The local values are stored in the
3733 ** "config" table of the repository and the global values are stored in the
3734 ** $HOME/.fossil file on unix or in the %LOCALAPPDATA%/_fossil file on Windows.
3735 ** If both a local and a global value exists for a setting, the local value
3736 ** takes precedence. This command normally operates on the local settings.
3737 ** Use the --global option to change global settings.
3738 **
3739 ** Options:
3740 ** --global set or unset the given property globally instead of
3741 ** setting or unsetting it for the open repository only.
3742 **
@@ -3867,12 +3907,12 @@
3867 ** COMMAND: test-without-rowid
3868 **
3869 ** Usage: %fossil test-without-rowid FILENAME...
3870 **
3871 ** Change the Fossil repository FILENAME to make use of the WITHOUT ROWID
3872 ** optimization. FILENAME can also be the ~/.fossil file or a local
3873 ** .fslckout or _FOSSIL_ file.
3874 **
3875 ** The purpose of this command is for testing the WITHOUT ROWID capabilities
3876 ** of SQLite. There is no big advantage to using WITHOUT ROWID in Fossil.
3877 **
3878 ** Options:
3879
--- src/db.c
+++ src/db.c
@@ -18,11 +18,12 @@
18 ** Code for interfacing to the various databases.
19 **
20 ** There are three separate database files that fossil interacts
21 ** with:
22 **
23 ** (1) The "configdb" database in ~/.fossil or ~/.config/fossil.db
24 ** or in %LOCALAPPDATA%/_fossil
25 **
26 ** (2) The "repository" database
27 **
28 ** (3) A local checkout database named "_FOSSIL_" or ".fslckout"
29 ** and located at the root of the local copy of the source tree.
@@ -1369,11 +1370,11 @@
1370 db_attach(zDbName, zLabel);
1371 }
1372 }
1373
1374 /*
1375 ** Close the per-user configuration database file
1376 */
1377 void db_close_config(){
1378 int iSlot = db_database_slot("configdb");
1379 if( iSlot>0 ){
1380 db_detach("configdb");
@@ -1393,33 +1394,30 @@
1394 fossil_free(g.zConfigDbName);
1395 g.zConfigDbName = 0;
1396 }
1397
1398 /*
1399 ** Compute the name of the configuration database. If unable to find the
1400 ** database, return 0 if isOptional is true, or panic if isOptional is false.
1401 **
1402 ** Space to hold the result comes from fossil_malloc().
 
 
 
 
 
 
1403 */
1404 static char *db_configdb_name(int isOptional){
1405 char *zHome; /* Home directory */
1406 char *zDbName; /* Name of the database file */
1407
1408
1409 /* On Windows, look for these directories, in order:
1410 **
1411 ** FOSSIL_HOME
1412 ** LOCALAPPDATA
1413 ** APPDATA
1414 ** USERPROFILE
1415 ** HOMEDRIVE HOMEPATH
1416 */
1417 #if defined(_WIN32) || defined(__CYGWIN__)
1418 zHome = fossil_getenv("FOSSIL_HOME");
1419 if( zHome==0 ){
1420 zHome = fossil_getenv("LOCALAPPDATA");
1421 if( zHome==0 ){
1422 zHome = fossil_getenv("APPDATA");
1423 if( zHome==0 ){
@@ -1430,47 +1428,90 @@
1428 if( zDrive && zPath ) zHome = mprintf("%s%s", zDrive, zPath);
1429 }
1430 }
1431 }
1432 }
1433 zDbName = mprintf("%//_fossil", zHome);
1434 fossil_free(zHome);
1435 return zDbName;
1436
1437 #else /* if unix */
1438 char *zXdgHome;
1439
1440 /* For unix. a 5-step algorithm is used.
1441 ** See ../www/tech_overview.wiki for discussion.
1442 **
1443 ** Step 1: If FOSSIL_HOME exists -> $FOSSIL_HOME/.fossil
1444 */
1445 zHome = fossil_getenv("FOSSIL_HOME");
1446 if( zHome!=0 ) return mprintf("%s/.fossil", zHome);
1447
1448 /* Step 2: If HOME exists and file $HOME/.fossil exists -> $HOME/.fossil
1449 */
1450 zHome = fossil_getenv("HOME");
1451 if( zHome ){
1452 zDbName = mprintf("%s/.fossil", zHome);
1453 if( file_size(zDbName, ExtFILE)>1024*3 ){
1454 return zDbName;
1455 }
1456 fossil_free(zDbName);
1457 }
1458
1459 /* Step 3: if XDG_CONFIG_HOME exists -> $XDG_CONFIG_HOME/fossil.db
1460 */
1461 zXdgHome = fossil_getenv("XDG_CONFIG_HOME");
1462 if( zXdgHome!=0 ){
1463 return mprintf("%s/fossil.db", zXdgHome);
1464 }
1465
1466 /* Step 4: If HOME does not exist -> ERROR
1467 */
1468 if( zHome==0 ){
1469 if( isOptional ) return 0;
1470 fossil_panic("cannot locate home directory - please set one of the "
1471 "FOSSIL_HOME, XDG_CONFIG_HOME, or HOME environment "
1472 "variables");
1473 }
1474
1475 /* Step 5: Otherwise -> $HOME/.config/fossil.db
1476 */
1477 return mprintf("%s/.config/fossil.db", zHome);
1478 #endif /* unix */
1479 }
1480
1481 /*
1482 ** Open the configuration database. Create the database anew if
1483 ** it does not already exist.
1484 **
1485 ** If the useAttach flag is 0 (the usual case) then the configuration
1486 ** database is opened on a separate database connection g.dbConfig.
1487 ** This prevents the database from becoming locked on long check-in or sync
1488 ** operations which hold an exclusive transaction. In a few cases, though,
1489 ** it is convenient for the database to be attached to the main database
1490 ** connection so that we can join between the various databases. In that
1491 ** case, invoke this routine with useAttach as 1.
1492 */
1493 int db_open_config(int useAttach, int isOptional){
1494 char *zDbName;
1495 if( g.zConfigDbName ){
1496 int alreadyAttached = db_database_slot("configdb")>0;
1497 if( useAttach==alreadyAttached ) return 1; /* Already open. */
1498 db_close_config();
1499 }
1500 zDbName = db_configdb_name(isOptional);
1501 if( zDbName==0 ) return 0;
1502 if( file_size(zDbName, ExtFILE)<1024*3 ){
1503 char *zHome = file_dirname(zDbName);
1504 int rc;
1505 if( file_isdir(zHome, ExtFILE)==0 ){
1506 file_mkdir(zHome, ExtFILE, 0);
1507 }
1508 rc = file_access(zHome, W_OK);
1509 fossil_free(zHome);
1510 if( rc ){
1511 if( isOptional ) return 0;
1512 fossil_panic("home directory \"%s\" must be writeable", zHome);
1513 }
1514 db_init_database(zDbName, zConfigSchema, (char*)0);
1515 }
1516 if( file_access(zDbName, W_OK) ){
1517 if( isOptional ) return 0;
@@ -2515,16 +2556,16 @@
2556 return 0;
2557 }
2558
2559 /*
2560 ** Swap the g.db and g.dbConfig connections so that the various db_* routines
2561 ** work on the configuration database instead of on the repository database.
2562 ** Be sure to swap them back after doing the operation.
2563 **
2564 ** If the configuration database has already been opened as the main database
2565 ** or is attached to the main database, no connection swaps are required so
2566 ** this routine is a no-op.
2567 */
2568 void db_swap_connections(void){
2569 /*
2570 ** When swapping the main database connection with the config database
2571 ** connection, the config database connection must be open (not simply
@@ -3729,14 +3770,13 @@
3770 ** The "unset" command clears a setting.
3771 **
3772 ** Settings can have both a "local" repository-only value and "global" value
3773 ** that applies to all repositories. The local values are stored in the
3774 ** "config" table of the repository and the global values are stored in the
3775 ** configuration database. If both a local and a global value exists for a
3776 ** setting, the local value takes precedence. This command normally operates
3777 ** on the local settings. Use the --global option to change global settings.
 
3778 **
3779 ** Options:
3780 ** --global set or unset the given property globally instead of
3781 ** setting or unsetting it for the open repository only.
3782 **
@@ -3867,12 +3907,12 @@
3907 ** COMMAND: test-without-rowid
3908 **
3909 ** Usage: %fossil test-without-rowid FILENAME...
3910 **
3911 ** Change the Fossil repository FILENAME to make use of the WITHOUT ROWID
3912 ** optimization. FILENAME can also be the configuration database file
3913 ** (~/.fossil or ~/.config/fossil.db) or a local .fslckout or _FOSSIL_ file.
3914 **
3915 ** The purpose of this command is for testing the WITHOUT ROWID capabilities
3916 ** of SQLite. There is no big advantage to using WITHOUT ROWID in Fossil.
3917 **
3918 ** Options:
3919
+18 -51
--- www/env-opts.md
+++ www/env-opts.md
@@ -112,31 +112,14 @@
112112
113113
114114
Environment Variables
115115
---------------------
116116
117
-On most platforms, the location of the user’s account-wide
118
-[configuration database][configdb]
119
-file is either `FOSSIL_HOME`, `XDG_CONFIG_HOME`, or `HOME`, in that order.
120
-This ordering lets you put this file somewhere other than at the top
121
-of your user’s home directory by defining `FOSSIL_HOME` to mask
122
-the always-defined `HOME`. The `XDG_CONFIG_HOME` setting is defined
123
-by some desktop environments as an alternative location for
124
-configuration files. If the `XDG_CONFIG_HOME` location is used, then
125
-the name of the configuration database is `fossil.db` instead of
126
-`.fossil`. See the [configuration database location][configloc] discussion
127
-for additional information.
128
-
129
-For native Windows builds and for Cygwin builds, the file is called
130
-`_fossil` instead of `.fossil` to avoid problems with old programs that
131
-assume file names cannot begin with a dot, as was true in old versions
132
-of Windows and in MS-DOS. (Newer Microsoft OSes and file systems don’t have a
133
-problem with such files, but still we take the safe path in case you’re
134
-on a system with software that can’t cope.) We start our search with
135
-`FOSSIL_HOME` again, but instead of falling back to `HOME`, we instead
136
-try `USERPROFILE`, then `LOCALAPPDATA`, then `APPDATA`, and finally we
137
-concatenate `HOMEDRIVE` + `HOMEPATH`.
117
+The location of the user's account-wide [configuration database][configdb]
118
+depends on the operating system and on the existance of various
119
+environment variables and/or files. See the discussion of the
120
+[configuration database location algorithm][configloc] for details.
138121
139122
`EDITOR`: Name the editor to use for check-in and stash comments.
140123
Overridden by the local or global `editor` setting or the `VISUAL`
141124
environment variable.
142125
@@ -402,46 +385,30 @@
402385
first found environment variable from the list `FOSSIL_USER`, `USER`,
403386
`LOGNAME`, and `USERNAME`, is the user name. As a final fallback, if
404387
none of those are set, then the default user name is "root".
405388
406389
407
-### Configuration Directory (often the Home Directory)
390
+### Configuration Database Location
408391
409392
Fossil keeps some information pertinent to each user in the user's
410393
[configuration database file][configdb].
411394
The configuration database file includes the global settings
412395
and the list of repositories and checkouts used by `fossil all`.
413396
414
-On Unix systems, the configuration database is called by one of the
415
-following names (in order):
416
-
417
- * `$FOSSIL_HOME/.fossil`
418
- * `$XDG_CONFIG_HOME/fossil.db`
419
- * `$HOME/.fossil`
420
-
421
-The name used is the first in the above list for which the corresponding
422
-environment varible is defined. On most systems, the third name is the
423
-one that is used.
424
-
425
-On Windows, the configuration database is called one of these (in order)
426
-
427
- * `%FOSSIL_HOME%/_fossil`
428
- * `%LOCALAPPDATA%/_fossil`
429
- * `%APPDATA%/_fossil`
430
- * `%USERPROFILES%/_fossil`
431
- * `%HOMEDRIVE%%HOMEPATH%/_fossil`
432
-
433
-As before, the first case in when the corresponding environment variables
434
-exist is the one used. This is ususally the second case. Note that the
435
-`FOSSIL_HOME` environment variable can always be set to determine the
436
-location of the configuration database. Note also that the configuration
437
-database file itself is called `.fossil` or `fossil.db` on unix but
438
-`_fossil` on windows.
439
-
440
-You can run the "[fossil info](/help?cmd=info)" command from an open
441
-check-out to see the location of the configuration database.
442
-
397
+The location of the configuration database file depends on the
398
+operating system and on the existance of various environment
399
+variables and/or files. In brief, the configuration database is
400
+usually:
401
+
402
+ * Traditional unix &rarr; "`$HOME/.fossil`"
403
+ * Windows &rarr; "`%LOCALAPPDATA%/_fossil`"
404
+ * [XDG-unix][xdg] &rarr; "`$HOME/.config/fossil.db`"
405
+
406
+[xdg]: https://www.freedesktop.org/wiki/
407
+
408
+See the [configuration database location
409
+algorithm][configloc] discussion for full information.
443410
444411
### SQLite VFS to use
445412
446413
See [the SQLite documentation](http://www.sqlite.org/vfs.html) for an
447414
explanation of what a VFS actually is and what it does.
448415
--- www/env-opts.md
+++ www/env-opts.md
@@ -112,31 +112,14 @@
112
113
114 Environment Variables
115 ---------------------
116
117 On most platforms, the location of the user’s account-wide
118 [configuration database][configdb]
119 file is either `FOSSIL_HOME`, `XDG_CONFIG_HOME`, or `HOME`, in that order.
120 This ordering lets you put this file somewhere other than at the top
121 of your user’s home directory by defining `FOSSIL_HOME` to mask
122 the always-defined `HOME`. The `XDG_CONFIG_HOME` setting is defined
123 by some desktop environments as an alternative location for
124 configuration files. If the `XDG_CONFIG_HOME` location is used, then
125 the name of the configuration database is `fossil.db` instead of
126 `.fossil`. See the [configuration database location][configloc] discussion
127 for additional information.
128
129 For native Windows builds and for Cygwin builds, the file is called
130 `_fossil` instead of `.fossil` to avoid problems with old programs that
131 assume file names cannot begin with a dot, as was true in old versions
132 of Windows and in MS-DOS. (Newer Microsoft OSes and file systems don’t have a
133 problem with such files, but still we take the safe path in case you’re
134 on a system with software that can’t cope.) We start our search with
135 `FOSSIL_HOME` again, but instead of falling back to `HOME`, we instead
136 try `USERPROFILE`, then `LOCALAPPDATA`, then `APPDATA`, and finally we
137 concatenate `HOMEDRIVE` + `HOMEPATH`.
138
139 `EDITOR`: Name the editor to use for check-in and stash comments.
140 Overridden by the local or global `editor` setting or the `VISUAL`
141 environment variable.
142
@@ -402,46 +385,30 @@
402 first found environment variable from the list `FOSSIL_USER`, `USER`,
403 `LOGNAME`, and `USERNAME`, is the user name. As a final fallback, if
404 none of those are set, then the default user name is "root".
405
406
407 ### Configuration Directory (often the Home Directory)
408
409 Fossil keeps some information pertinent to each user in the user's
410 [configuration database file][configdb].
411 The configuration database file includes the global settings
412 and the list of repositories and checkouts used by `fossil all`.
413
414 On Unix systems, the configuration database is called by one of the
415 following names (in order):
416
417 * `$FOSSIL_HOME/.fossil`
418 * `$XDG_CONFIG_HOME/fossil.db`
419 * `$HOME/.fossil`
420
421 The name used is the first in the above list for which the corresponding
422 environment varible is defined. On most systems, the third name is the
423 one that is used.
424
425 On Windows, the configuration database is called one of these (in order)
426
427 * `%FOSSIL_HOME%/_fossil`
428 * `%LOCALAPPDATA%/_fossil`
429 * `%APPDATA%/_fossil`
430 * `%USERPROFILES%/_fossil`
431 * `%HOMEDRIVE%%HOMEPATH%/_fossil`
432
433 As before, the first case in when the corresponding environment variables
434 exist is the one used. This is ususally the second case. Note that the
435 `FOSSIL_HOME` environment variable can always be set to determine the
436 location of the configuration database. Note also that the configuration
437 database file itself is called `.fossil` or `fossil.db` on unix but
438 `_fossil` on windows.
439
440 You can run the "[fossil info](/help?cmd=info)" command from an open
441 check-out to see the location of the configuration database.
442
443
444 ### SQLite VFS to use
445
446 See [the SQLite documentation](http://www.sqlite.org/vfs.html) for an
447 explanation of what a VFS actually is and what it does.
448
--- www/env-opts.md
+++ www/env-opts.md
@@ -112,31 +112,14 @@
112
113
114 Environment Variables
115 ---------------------
116
117 The location of the user's account-wide [configuration database][configdb]
118 depends on the operating system and on the existance of various
119 environment variables and/or files. See the discussion of the
120 [configuration database location algorithm][configloc] for details.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
122 `EDITOR`: Name the editor to use for check-in and stash comments.
123 Overridden by the local or global `editor` setting or the `VISUAL`
124 environment variable.
125
@@ -402,46 +385,30 @@
385 first found environment variable from the list `FOSSIL_USER`, `USER`,
386 `LOGNAME`, and `USERNAME`, is the user name. As a final fallback, if
387 none of those are set, then the default user name is "root".
388
389
390 ### Configuration Database Location
391
392 Fossil keeps some information pertinent to each user in the user's
393 [configuration database file][configdb].
394 The configuration database file includes the global settings
395 and the list of repositories and checkouts used by `fossil all`.
396
397 The location of the configuration database file depends on the
398 operating system and on the existance of various environment
399 variables and/or files. In brief, the configuration database is
400 usually:
401
402 * Traditional unix &rarr; "`$HOME/.fossil`"
403 * Windows &rarr; "`%LOCALAPPDATA%/_fossil`"
404 * [XDG-unix][xdg] &rarr; "`$HOME/.config/fossil.db`"
405
406 [xdg]: https://www.freedesktop.org/wiki/
407
408 See the [configuration database location
409 algorithm][configloc] discussion for full information.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
410
411 ### SQLite VFS to use
412
413 See [the SQLite documentation](http://www.sqlite.org/vfs.html) for an
414 explanation of what a VFS actually is and what it does.
415
--- www/tech_overview.wiki
+++ www/tech_overview.wiki
@@ -69,11 +69,11 @@
6969
7070
<table border="1" width="80%" cellpadding="0" align="center">
7171
<tr>
7272
<td width="33%" valign="top">
7373
<h3 align="center">Configuration Database<br>"~/.fossil" or<br>
74
-"~/.config/fossil.conf"</h3>
74
+"~/.config/fossil.db"</h3>
7575
<ul>
7676
<li>Global [/help/settings |settings]
7777
<li>List of active repositories used by the [/help/all | all] command
7878
</ul>
7979
</td>
@@ -128,32 +128,44 @@
128128
operations such as "sync" or "rebuild" on all repositories managed by a user.
129129
130130
<a name='configloc'></a>
131131
<h4>2.1.1 Location Of The Configuration Database</h4>
132132
133
-On Unix systems, the configuration database is called by one of the
134
-following names (in order):
135
-
136
- * $FOSSIL_HOME/.fossil
137
- * $XDG_CONFIG_HOME/fossil.db
138
- * $HOME/.fossil
139
-
140
-The name used is the first in the above list for which the corresponding
141
-environment varible is defined. On most systems, the third name is the
142
-one that is used.
143
-
144
-On Windows, the configuration database is called one of these
145
-names (in order):
133
+On Unix systems, the configuration database is named by the following
134
+algorithm:
135
+
136
+ * if environment variable FOSSIL_HOME exists &rarr; $FOSSIL_HOME/.fossil
137
+ * if environment variable HOME exists and
138
+ if file $HOME/fossil exists &rarr; $HOME/.fossil
139
+ * if environment variable XDG_CONFIG_HOME exists
140
+ &rarr; $XDG_CONFIG_HOME/fossil.db
141
+ * if environment variable HOME does not exist &rarr; <i>ERROR</i>
142
+ * Otherwise $HOME/.config/fossil.db
143
+
144
+Another way of thinking of this algorithm is the following:
145
+
146
+ * Use "$FOSSIL_HOME/.fossil" if the FOSSIL_HOME variable is defined
147
+ * Use the traditional unix configuration file name of
148
+ "$HOME/.fossil" if HOME is defined and if that file exists.
149
+ * Use an XDG compatible name otherwise.
150
+
151
+This algorithm is complex due to the need for historical compatibility.
152
+Originally, the database was always named "$HOME/.fossil". Then support
153
+for the FOSSIL_HOME environment variable as added. Later, support for the
154
+[https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html|XDG-compatible configation filenames]
155
+was added. Each of these changes needed to continue to support legacy installs.
156
+
157
+On Windows, the configuration database is the first of the following
158
+for which the corresponding environment variables exist:
146159
147160
* %FOSSIL_HOME%/_fossil
148161
* %LOCALAPPDATA%/_fossil
149162
* %APPDATA%/_fossil
150163
* %USERPROFILES%/_fossil
151164
* %HOMEDRIVE%%HOMEPATH%/_fossil
152165
153
-As before, the first case in when the corresponding environment variables
154
-exist is the one used. This is ususally the second case. Note that the
166
+The second case is the one that usually determines the name Note that the
155167
FOSSIL_HOME environment variable can always be set to determine the
156168
location of the configuration database. Note also that the configuration
157169
database file itself is called ".fossil" or "fossil.db" on unix but
158170
"_fossil" on windows.
159171
160172
--- www/tech_overview.wiki
+++ www/tech_overview.wiki
@@ -69,11 +69,11 @@
69
70 <table border="1" width="80%" cellpadding="0" align="center">
71 <tr>
72 <td width="33%" valign="top">
73 <h3 align="center">Configuration Database<br>"~/.fossil" or<br>
74 "~/.config/fossil.conf"</h3>
75 <ul>
76 <li>Global [/help/settings |settings]
77 <li>List of active repositories used by the [/help/all | all] command
78 </ul>
79 </td>
@@ -128,32 +128,44 @@
128 operations such as "sync" or "rebuild" on all repositories managed by a user.
129
130 <a name='configloc'></a>
131 <h4>2.1.1 Location Of The Configuration Database</h4>
132
133 On Unix systems, the configuration database is called by one of the
134 following names (in order):
135
136 * $FOSSIL_HOME/.fossil
137 * $XDG_CONFIG_HOME/fossil.db
138 * $HOME/.fossil
139
140 The name used is the first in the above list for which the corresponding
141 environment varible is defined. On most systems, the third name is the
142 one that is used.
143
144 On Windows, the configuration database is called one of these
145 names (in order):
 
 
 
 
 
 
 
 
 
 
 
 
 
146
147 * %FOSSIL_HOME%/_fossil
148 * %LOCALAPPDATA%/_fossil
149 * %APPDATA%/_fossil
150 * %USERPROFILES%/_fossil
151 * %HOMEDRIVE%%HOMEPATH%/_fossil
152
153 As before, the first case in when the corresponding environment variables
154 exist is the one used. This is ususally the second case. Note that the
155 FOSSIL_HOME environment variable can always be set to determine the
156 location of the configuration database. Note also that the configuration
157 database file itself is called ".fossil" or "fossil.db" on unix but
158 "_fossil" on windows.
159
160
--- www/tech_overview.wiki
+++ www/tech_overview.wiki
@@ -69,11 +69,11 @@
69
70 <table border="1" width="80%" cellpadding="0" align="center">
71 <tr>
72 <td width="33%" valign="top">
73 <h3 align="center">Configuration Database<br>"~/.fossil" or<br>
74 "~/.config/fossil.db"</h3>
75 <ul>
76 <li>Global [/help/settings |settings]
77 <li>List of active repositories used by the [/help/all | all] command
78 </ul>
79 </td>
@@ -128,32 +128,44 @@
128 operations such as "sync" or "rebuild" on all repositories managed by a user.
129
130 <a name='configloc'></a>
131 <h4>2.1.1 Location Of The Configuration Database</h4>
132
133 On Unix systems, the configuration database is named by the following
134 algorithm:
135
136 * if environment variable FOSSIL_HOME exists &rarr; $FOSSIL_HOME/.fossil
137 * if environment variable HOME exists and
138 if file $HOME/fossil exists &rarr; $HOME/.fossil
139 * if environment variable XDG_CONFIG_HOME exists
140 &rarr; $XDG_CONFIG_HOME/fossil.db
141 * if environment variable HOME does not exist &rarr; <i>ERROR</i>
142 * Otherwise $HOME/.config/fossil.db
143
144 Another way of thinking of this algorithm is the following:
145
146 * Use "$FOSSIL_HOME/.fossil" if the FOSSIL_HOME variable is defined
147 * Use the traditional unix configuration file name of
148 "$HOME/.fossil" if HOME is defined and if that file exists.
149 * Use an XDG compatible name otherwise.
150
151 This algorithm is complex due to the need for historical compatibility.
152 Originally, the database was always named "$HOME/.fossil". Then support
153 for the FOSSIL_HOME environment variable as added. Later, support for the
154 [https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html|XDG-compatible configation filenames]
155 was added. Each of these changes needed to continue to support legacy installs.
156
157 On Windows, the configuration database is the first of the following
158 for which the corresponding environment variables exist:
159
160 * %FOSSIL_HOME%/_fossil
161 * %LOCALAPPDATA%/_fossil
162 * %APPDATA%/_fossil
163 * %USERPROFILES%/_fossil
164 * %HOMEDRIVE%%HOMEPATH%/_fossil
165
166 The second case is the one that usually determines the name Note that the
 
167 FOSSIL_HOME environment variable can always be set to determine the
168 location of the configuration database. Note also that the configuration
169 database file itself is called ".fossil" or "fossil.db" on unix but
170 "_fossil" on windows.
171
172

Keyboard Shortcuts

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