Fossil

Check-in [09a21409f5]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Change the name of the configuration database to "fossil.db" if the database is found in the XDG_CONFIG_HOME directory. Otherwise, the configdb is still called ".fossil" on unix systems.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | xdg-aware-config-db
Files: files | file ages | folders
SHA3-256: 09a21409f53247b07eb76fcc4a2af2a460d46d791f1b72fa0ebf0831296b8ad1
User & Date: drh 2020-04-18 18:55:04.097
Context
2020-04-18
18:56
Use the XDG_CONFIG_HOME environment variable (if it exists) to locate the configuration database on unix. check-in: 22f879dde6 user: drh tags: trunk
18:55
Change the name of the configuration database to "fossil.db" if the database is found in the XDG_CONFIG_HOME directory. Otherwise, the configdb is still called ".fossil" on unix systems. Closed-Leaf check-in: 09a21409f5 user: drh tags: xdg-aware-config-db
00:12
Look in the XDG_CONFIG_HOME environment variable before looking in HOME for the location of the ".fossil" configuration database. check-in: 4de54b1d98 user: drh tags: xdg-aware-config-db
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/db.c.
1405
1406
1407
1408
1409
1410
1411

1412
1413
1414
1415
1416
1417
1418

1419
1420
1421
1422
1423
1424
1425
** it is convenient for the ~/.fossil to be attached to the main database
** connection so that we can join between the various databases.  In that
** case, invoke this routine with useAttach as 1.
*/
int db_open_config(int useAttach, int isOptional){
  char *zDbName;
  char *zHome;

  if( g.zConfigDbName ){
    int alreadyAttached = db_database_slot("configdb")>0;
    if( useAttach==alreadyAttached ) return 1; /* Already open. */
    db_close_config();
  }
  zHome = fossil_getenv("FOSSIL_HOME");
#if defined(_WIN32) || defined(__CYGWIN__)

  if( zHome==0 ){
    zHome = fossil_getenv("LOCALAPPDATA");
    if( zHome==0 ){
      zHome = fossil_getenv("APPDATA");
      if( zHome==0 ){
        zHome = fossil_getenv("USERPROFILE");
        if( zHome==0 ){







>







>







1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
** it is convenient for the ~/.fossil to be attached to the main database
** connection so that we can join between the various databases.  In that
** case, invoke this routine with useAttach as 1.
*/
int db_open_config(int useAttach, int isOptional){
  char *zDbName;
  char *zHome;
  const char *zRoot;
  if( g.zConfigDbName ){
    int alreadyAttached = db_database_slot("configdb")>0;
    if( useAttach==alreadyAttached ) return 1; /* Already open. */
    db_close_config();
  }
  zHome = fossil_getenv("FOSSIL_HOME");
#if defined(_WIN32) || defined(__CYGWIN__)
  zRoot = "_fossil";
  if( zHome==0 ){
    zHome = fossil_getenv("LOCALAPPDATA");
    if( zHome==0 ){
      zHome = fossil_getenv("APPDATA");
      if( zHome==0 ){
        zHome = fossil_getenv("USERPROFILE");
        if( zHome==0 ){
1433
1434
1435
1436
1437
1438
1439

1440
1441
1442
1443


1444
1445
1446
1447
1448
1449
1450


1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
  if( zHome==0 ){
    if( isOptional ) return 0;
    fossil_panic("cannot locate home directory - please set the "
                 "FOSSIL_HOME, LOCALAPPDATA, APPDATA, USERPROFILE, "
                 "or HOMEDRIVE / HOMEPATH environment variables");
  }
#else

  if( zHome==0 ){
    zHome = fossil_getenv("XDG_CONFIG_HOME");
  }
  if( zHome==0 ){


    zHome = fossil_getenv("HOME");
  }
  if( zHome==0 ){
    if( isOptional ) return 0;
    fossil_panic("cannot locate home directory - please set one of the "
                 "FOSSIL_HOME, XDG_CONFIG_HOME, or HOME environment "
                 "variables");


  }
#endif
  if( file_isdir(zHome, ExtFILE)!=1 ){
    if( isOptional ) return 0;
    fossil_panic("invalid home directory: %s", zHome);
  }
#if defined(_WIN32) || defined(__CYGWIN__)
  /* . filenames give some window systems problems and many apps problems */
  zDbName = mprintf("%//_fossil", zHome);
#else
  zDbName = mprintf("%s/.fossil", zHome);
#endif
  if( file_size(zDbName, ExtFILE)<1024*3 ){
    if( file_access(zHome, W_OK) ){
      if( isOptional ) return 0;
      fossil_panic("home directory %s must be writeable", zHome);
    }
    db_init_database(zDbName, zConfigSchema, (char*)0);







>


<
|
>
>
|
<
|
|
|
|
|
>
>








|

|







1435
1436
1437
1438
1439
1440
1441
1442
1443
1444

1445
1446
1447
1448

1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
  if( zHome==0 ){
    if( isOptional ) return 0;
    fossil_panic("cannot locate home directory - please set the "
                 "FOSSIL_HOME, LOCALAPPDATA, APPDATA, USERPROFILE, "
                 "or HOMEDRIVE / HOMEPATH environment variables");
  }
#else
  zRoot = ".fossil";
  if( zHome==0 ){
    zHome = fossil_getenv("XDG_CONFIG_HOME");

    if( zHome ){
      zRoot = "fossil.db";
    }else{
      zHome = fossil_getenv("HOME");

      if( zHome==0 ){
        if( isOptional ) return 0;
        fossil_panic("cannot locate home directory - please set one of the "
                     "FOSSIL_HOME, XDG_CONFIG_HOME, or HOME environment "
                     "variables");
      }
    }
  }
#endif
  if( file_isdir(zHome, ExtFILE)!=1 ){
    if( isOptional ) return 0;
    fossil_panic("invalid home directory: %s", zHome);
  }
#if defined(_WIN32) || defined(__CYGWIN__)
  /* . filenames give some window systems problems and many apps problems */
  zDbName = mprintf("%//%s", zHome, zRoot);
#else
  zDbName = mprintf("%s/%s", zHome, zRoot);
#endif
  if( file_size(zDbName, ExtFILE)<1024*3 ){
    if( file_access(zHome, W_OK) ){
      if( isOptional ) return 0;
      fossil_panic("home directory %s must be writeable", zHome);
    }
    db_init_database(zDbName, zConfigSchema, (char*)0);
Changes to www/env-opts.md.
110
111
112
113
114
115
116
117

118
119
120
121
122
123



124
125
126
127
128
129
130

`--vfs VFSNAME`: Load the named VFS into SQLite.


Environment Variables
---------------------

On most platforms, the location of the user’s account-wide `.fossil`

file is either `FOSSIL_HOME`, `XDG_CONFIG_HOME`, or `HOME`, in that order. 
This ordering lets you put this file somewhere other than at the top 
of your user’s home directory by defining `FOSSIL_HOME` to mask 
the always-defined `HOME`.  The `XDG_CONFIG_HOME` setting is defined
by some desktop environments to be the preferred "modern" directory
in which to store configuration files.




For native Windows builds and for Cygwin builds, the file is called
`_fossil` instead of `.fossil` to avoid problems with old programs that 
assume file names cannot begin with a dot, as was true in old versions 
of Windows and in MS-DOS. (Newer Microsoft OSes and file systems don’t have a
problem with such files, but still we take the safe path in case you’re
on a system with software that can’t cope.) We start our search with







|
>




|
|
>
>
>







110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134

`--vfs VFSNAME`: Load the named VFS into SQLite.


Environment Variables
---------------------

On most platforms, the location of the user’s account-wide
[configuration database][configdb]
file is either `FOSSIL_HOME`, `XDG_CONFIG_HOME`, or `HOME`, in that order. 
This ordering lets you put this file somewhere other than at the top 
of your user’s home directory by defining `FOSSIL_HOME` to mask 
the always-defined `HOME`.  The `XDG_CONFIG_HOME` setting is defined
by some desktop environments as an alternative location for
configuration files.  If the `XDG_CONFIG_HOME` location is used, then
the name of the configuration database is `fossil.db` instead of
`.fossil`.  See the [configuration database location][configloc] discussion
for additional information.

For native Windows builds and for Cygwin builds, the file is called
`_fossil` instead of `.fossil` to avoid problems with old programs that 
assume file names cannot begin with a dot, as was true in old versions 
of Windows and in MS-DOS. (Newer Microsoft OSes and file systems don’t have a
problem with such files, but still we take the safe path in case you’re
on a system with software that can’t cope.) We start our search with
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
`FOSSIL_FORCE_WIKI_MODERATION`: If set, *ALL* changes for wiki pages
will be required to go through moderation (even those performed by the
local interactive user via the command line).  This can be useful for
local (or remote) testing of the moderation subsystem and its impact
on the contents and status of wiki pages.


`FOSSIL_HOME`: Location of the `~/.fossil` file. The first environment
variable found in the environment from the list `FOSSIL_HOME`,
`LOCALAPPDATA` (Windows), `APPDATA` (Windows), `HOMEDRIVE` and
`HOMEPATH` (Windows, used together), `XDG_CONFIG_HOME` (unix) and 
`HOME` is used as the
location of the `~/.fossil` file.


`FOSSIL_USE_SEE_TEXTKEY`: If set, treat the encryption key string for
SEE as text to be hashed into the actual encryption key.  This has no
effect if Fossil was not compiled with SEE support enabled.


`FOSSIL_USER`: Name of the default user account if the checkout, local







|
<
<
<
<
|
|







153
154
155
156
157
158
159
160




161
162
163
164
165
166
167
168
169
`FOSSIL_FORCE_WIKI_MODERATION`: If set, *ALL* changes for wiki pages
will be required to go through moderation (even those performed by the
local interactive user via the command line).  This can be useful for
local (or remote) testing of the moderation subsystem and its impact
on the contents and status of wiki pages.


`FOSSIL_HOME`: Location of [configuration database][configdb].




See the [configuration database location][configloc] description
for additional information.

`FOSSIL_USE_SEE_TEXTKEY`: If set, treat the encryption key string for
SEE as text to be hashed into the actual encryption key.  This has no
effect if Fossil was not compiled with SEE support enabled.


`FOSSIL_USER`: Name of the default user account if the checkout, local
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214

`FOSSIL_VFS`: Name a VFS to load into SQLite.

`GATEWAY_INTERFACE`: If present and the `--nocgi` option is not, assume
fossil is invoked from a web server as a CGI command, and act
accordingly.

`HOME`: Location of the `~/.fossil` file. The first environment
variable found in the environment from the list `FOSSIL_HOME`,
`LOCALAPPDATA` (Windows), `APPDATA` (Windows), `HOMEDRIVE` and
`HOMEPATH` (Windows, used together), `XDG_CONFIG_HOME` (unix)
and `HOME` is used as the location of the `~/.fossil` file.

`HOMEDRIVE`, `HOMEPATH`: (Windows) Location of the `~/.fossil` file.
The first environment variable found in the environment from the list
`FOSSIL_HOME`, `LOCALAPPDATA` (Windows), `APPDATA` (Windows),
`HOMEDRIVE` and `HOMEPATH` (Windows, used together), and `HOME` is
used as the location of the `~/.fossil` file.








|
<
<
<
|







196
197
198
199
200
201
202
203



204
205
206
207
208
209
210
211

`FOSSIL_VFS`: Name a VFS to load into SQLite.

`GATEWAY_INTERFACE`: If present and the `--nocgi` option is not, assume
fossil is invoked from a web server as a CGI command, and act
accordingly.

`HOME`: Potential location of the [configuration database][configdb].



See the [configuration database location][configloc] description for details.

`HOMEDRIVE`, `HOMEPATH`: (Windows) Location of the `~/.fossil` file.
The first environment variable found in the environment from the list
`FOSSIL_HOME`, `LOCALAPPDATA` (Windows), `APPDATA` (Windows),
`HOMEDRIVE` and `HOMEPATH` (Windows, used together), and `HOME` is
used as the location of the `~/.fossil` file.

405
406
407
408
409
410
411
412
413

414
415


416
417
418


419


420
421
422
423





424
425


426



427


428
429
430
431
432
433
434
first found environment variable from the list `FOSSIL_USER`, `USER`,
`LOGNAME`, and `USERNAME`, is the user name. As a final fallback, if
none of those are set, then the default user name is "root".


### Configuration Directory (often the Home Directory)

Fossil keeps some information interesting to each user in the user's
configuration file directory. This includes the global settings and the list of

repositories and checkouts used by `fossil all`.  On many,
but not all, systems the configuration file directory is the home directory



The user's configuration file directory is specified by the first environment
variable found in the environment from the list `FOSSIL_HOME`,


`LOCALAPPDATA` (Windows), `APPDATA` (Windows), `HOMEDRIVE` and


`HOMEPATH` (Windows, used together), `XDG_CONFIG_HOME` (unix), and `HOME`.

SQLite has its own notion of the user's configuration file directory, 
which is only exposed if the interactive SQL shell is run with the "fossil





sqlite3" command. Being a separate library, SQLite uses many of the
same variables to find the home directory, but uses them in a


different order, and does not use the `FOSSIL_HOME` nor



`XDG_CONFIG_HOME` variables.




### SQLite VFS to use

See [the SQLite documentation](http://www.sqlite.org/vfs.html) for an
explanation of what a VFS actually is and what it does.








|
|
>
|
|
>
>

<
|
>
>
|
>
>
|

|
|
>
>
>
>
>
|
<
>
>
|
>
>
>
|
>
>







402
403
404
405
406
407
408
409
410
411
412
413
414
415
416

417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432

433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
first found environment variable from the list `FOSSIL_USER`, `USER`,
`LOGNAME`, and `USERNAME`, is the user name. As a final fallback, if
none of those are set, then the default user name is "root".


### Configuration Directory (often the Home Directory)

Fossil keeps some information pertinent to each user in the user's
[configuration database file][configdb]. 
The configuration database file includes the global settings
and the list of repositories and checkouts used by `fossil all`.

On Unix systems, the configuration database is called by one of the
following names (in order):


  * `$FOSSIL_HOME/.fossil`
  * `$XDG_CONFIG_HOME/fossil.db`
  * `$HOME/.fossil`

The name used is the first in the above list for which the corresponding
environment varible is defined. On most systems, the third name is the
one that is used.

On Windows, the configuration database is called one of these (in order)

  *  `%FOSSIL_HOME%/_fossil`
  *  `%LOCALAPPDATA%/_fossil`
  *  `%APPDATA%/_fossil`
  *  `%USERPROFILES%/_fossil`
  *  `%HOMEDRIVE%%HOMEPATH%/_fossil`


As before, the first case in when the corresponding environment variables
exist is the one used.  This is ususally the second case.  Note that the
`FOSSIL_HOME` environment variable can always be set to determine the 
location of the configuration database.  Note also that the configuration
database file itself is called `.fossil` or `fossil.db` on unix but
`_fossil` on windows.

You can run the "[fossil info](/help?cmd=info)" command from an open
check-out to see the location of the configuration database.


### SQLite VFS to use

See [the SQLite documentation](http://www.sqlite.org/vfs.html) for an
explanation of what a VFS actually is and what it does.

493
494
495
496
497
498
499



`google-chrome` that it can find on the `PATH`.

On Apple platforms, it assumes that `open` is the command to open an
URL in the user's configured default browser.

On Windows platforms, it assumes that `start` is the command to open
an URL in the user's configured default browser.










>
>
>
507
508
509
510
511
512
513
514
515
516
`google-chrome` that it can find on the `PATH`.

On Apple platforms, it assumes that `open` is the command to open an
URL in the user's configured default browser.

On Windows platforms, it assumes that `start` is the command to open
an URL in the user's configured default browser.

[configdb]: ./tech_overview.wiki#configdb
[configloc]: ./tech_overview.wiki#configloc
Changes to www/tech_overview.wiki.
66
67
68
69
70
71
72
73

74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99

The chart below provides a quick summary of how each of these
database files are used by Fossil, with detailed discussion following.

<table border="1" width="80%" cellpadding="0" align="center">
<tr>
<td width="33%" valign="top">
<h3 align="center">Configuration Database<br>"~/.fossil"</h3>

<ul>
<li>Global [/help/settings |settings]
<li>List of active repositories used by the [/help/all | all] command
</ul>
</td>
<td width="34%" valign="top">
<h3 align="center">Repository Database<br>"<i>project</i>.fossil"</h3>
<ul>
<li>[./fileformat.wiki | Global state of the project]
    encoded using delta-compression
<li>Local [/help/settings|settings]
<li>Web interface display preferences
<li>User credentials and permissions
<li>Metadata about the global state to facilitate rapid
    queries
</ul>
</td>
<td width="33%" valign="top">
<h3 align="center">Checkout Database<br>"_FOSSIL_"</h3>
<ul>
<li>The repository database used by this checkout
<li>The version currently checked out
<li>Other versions [/help/merge | merged] in but not
    yet [/help/commit | committed]
<li>Changes from the [/help/add | add], [/help/delete | delete],
    and [/help/rename | rename] commands that have not yet been committed







|
>


















|







66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100

The chart below provides a quick summary of how each of these
database files are used by Fossil, with detailed discussion following.

<table border="1" width="80%" cellpadding="0" align="center">
<tr>
<td width="33%" valign="top">
<h3 align="center">Configuration Database<br>"~/.fossil" or<br>
"~/.config/fossil.conf"</h3>
<ul>
<li>Global [/help/settings |settings]
<li>List of active repositories used by the [/help/all | all] command
</ul>
</td>
<td width="34%" valign="top">
<h3 align="center">Repository Database<br>"<i>project</i>.fossil"</h3>
<ul>
<li>[./fileformat.wiki | Global state of the project]
    encoded using delta-compression
<li>Local [/help/settings|settings]
<li>Web interface display preferences
<li>User credentials and permissions
<li>Metadata about the global state to facilitate rapid
    queries
</ul>
</td>
<td width="33%" valign="top">
<h3 align="center">Checkout Database<br>"_FOSSIL_" or ".fslckout"</h3>
<ul>
<li>The repository database used by this checkout
<li>The version currently checked out
<li>Other versions [/help/merge | merged] in but not
    yet [/help/commit | committed]
<li>Changes from the [/help/add | add], [/help/delete | delete],
    and [/help/rename | rename] commands that have not yet been committed
122
123
124
125
126
127
128



129

130
131
132


133
134

135

136
137

138





139


140



141


142
143
144
145
146
147
148
a way to change settings for all repositories with a single command, rather
than having to change the setting individually on each repository.

The configuration database also maintains a list of repositories.  This
list is used by the [/help/all | fossil all] command in order to run various
operations such as "sync" or "rebuild" on all repositories managed by a user.




On Unix systems, the configuration database is named ".fossil" and is

located in the user's configuration file directory, which on most older
unix systems is the user's home directory but on some "desktop" linux
environments is the "~/.config" directory.  On Windows, the configuration


database is named "_fossil" (using an underscore as the first character
instead of a dot) and is located in the directory specified by the

LOCALAPPDATA, APPDATA, or HOMEPATH environment variables, in that order.

You can run the [/help?cmd=info|fossil info] command from an open
check-out to see the location of the configuration database.







You can override this default location by defining the environment


variable FOSSIL_HOME pointing to an appropriate (writable) directory.







<h3>2.2 Repository Databases</h3>

The repository database is the file that is commonly referred to as
"the repository".  This is because the repository database contains,
among other things, the complete revision, ticket, and wiki history for
a project.  It is customary to name the repository database after then







>
>
>
|
>
|
<
<
>
>
|
|
>
|
>
|
|
>

>
>
>
>
>
|
>
>
|
>
>
>

>
>







123
124
125
126
127
128
129
130
131
132
133
134
135


136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
a way to change settings for all repositories with a single command, rather
than having to change the setting individually on each repository.

The configuration database also maintains a list of repositories.  This
list is used by the [/help/all | fossil all] command in order to run various
operations such as "sync" or "rebuild" on all repositories managed by a user.

<a name='configloc'></a>
<h4>2.1.1 Location Of The Configuration Database</h4>

On Unix systems, the configuration database is called by one of the
following names (in order):



  *  $FOSSIL_HOME/.fossil
  *  $XDG_CONFIG_HOME/fossil.db
  *  $HOME/.fossil

The name used is the first in the above list for which the corresponding
environment varible is defined. On most systems, the third name is the
one that is used.

On Windows, the configuration database is called one of these
names (in order):

  *  %FOSSIL_HOME%/_fossil
  *  %LOCALAPPDATA%/_fossil
  *  %APPDATA%/_fossil
  *  %USERPROFILES%/_fossil
  *  %HOMEDRIVE%%HOMEPATH%/_fossil

As before, the first case in when the corresponding environment variables
exist is the one used.  This is ususally the second case.  Note that the
FOSSIL_HOME environment variable can always be set to determine the 
location of the configuration database.  Note also that the configuration
database file itself is called ".fossil" or "fossil.db" on unix but
"_fossil" on windows.

You can run the [/help?cmd=info|fossil info] command from an open
check-out to see the location of the configuration database.

<h3>2.2 Repository Databases</h3>

The repository database is the file that is commonly referred to as
"the repository".  This is because the repository database contains,
among other things, the complete revision, ticket, and wiki history for
a project.  It is customary to name the repository database after then