Fossil SCM

Improved documentation of the latest configuration database locator algorithm. No code changes.

drh 2020-04-19 15:20 trunk
Commit 9cb8194da651637e8afd2d630cc3f6362e777c33ae4ab65a32a343bae4388998
2 files changed +3 -3 +14 -11
+3 -3
--- src/db.c
+++ src/db.c
@@ -1461,28 +1461,28 @@
14611461
zXdgHome = fossil_getenv("XDG_CONFIG_HOME");
14621462
if( zXdgHome!=0 ){
14631463
return mprintf("%s/fossil.db", zXdgHome);
14641464
}
14651465
1466
- /* Step 4: If HOME does not exist -> ERROR
1466
+ /* The HOME variable is required in order to continue.
14671467
*/
14681468
if( zHome==0 ){
14691469
if( isOptional ) return 0;
14701470
fossil_panic("cannot locate home directory - please set one of the "
14711471
"FOSSIL_HOME, XDG_CONFIG_HOME, or HOME environment "
14721472
"variables");
14731473
}
14741474
1475
- /* Step 5: If $HOME/.config is a directory -> $HOME/.config/fossil.db
1475
+ /* Step 4: If $HOME/.config is a directory -> $HOME/.config/fossil.db
14761476
*/
14771477
zXdgHome = mprintf("%s/.config", zHome);
14781478
if( file_isdir(zXdgHome, ExtFILE)==1 ){
14791479
fossil_free(zXdgHome);
14801480
return mprintf("%s/.config/fossil.db", zHome);
14811481
}
14821482
1483
- /* Step 6: Otherwise -> $HOME/.fossil
1483
+ /* Step 5: Otherwise -> $HOME/.fossil
14841484
*/
14851485
return mprintf("%s/.fossil", zHome);
14861486
#endif /* unix */
14871487
}
14881488
14891489
--- src/db.c
+++ src/db.c
@@ -1461,28 +1461,28 @@
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: If $HOME/.config is a directory -> $HOME/.config/fossil.db
1476 */
1477 zXdgHome = mprintf("%s/.config", zHome);
1478 if( file_isdir(zXdgHome, ExtFILE)==1 ){
1479 fossil_free(zXdgHome);
1480 return mprintf("%s/.config/fossil.db", zHome);
1481 }
1482
1483 /* Step 6: Otherwise -> $HOME/.fossil
1484 */
1485 return mprintf("%s/.fossil", zHome);
1486 #endif /* unix */
1487 }
1488
1489
--- src/db.c
+++ src/db.c
@@ -1461,28 +1461,28 @@
1461 zXdgHome = fossil_getenv("XDG_CONFIG_HOME");
1462 if( zXdgHome!=0 ){
1463 return mprintf("%s/fossil.db", zXdgHome);
1464 }
1465
1466 /* The HOME variable is required in order to continue.
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 4: If $HOME/.config is a directory -> $HOME/.config/fossil.db
1476 */
1477 zXdgHome = mprintf("%s/.config", zHome);
1478 if( file_isdir(zXdgHome, ExtFILE)==1 ){
1479 fossil_free(zXdgHome);
1480 return mprintf("%s/.config/fossil.db", zHome);
1481 }
1482
1483 /* Step 5: Otherwise -> $HOME/.fossil
1484 */
1485 return mprintf("%s/.fossil", zHome);
1486 #endif /* unix */
1487 }
1488
1489
--- www/tech_overview.wiki
+++ www/tech_overview.wiki
@@ -131,31 +131,34 @@
131131
<h4>2.1.1 Location Of The Configuration Database</h4>
132132
133133
On Unix systems, the configuration database is named by the following
134134
algorithm:
135135
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
- * if a directory named $HOME/.config exists &rarr; $HOME/.config/fossil.db
143
- * Otherwise $HOME/.fossil
136
+<blockquote><table border="0">
137
+<tr><td>1. if environment variable FOSSIL_HOME exists
138
+<td>&nbsp;&rarr;&nbsp;<td>$FOSSIL_HOME/.fossil
139
+<tr><td>2. if file ~/.fossil exists<td>&nbsp;&rarr;<td>~/.fossil
140
+<tr><td>3. if environment variable XDG_CONFIG_HOME exists
141
+ <td>&nbsp;&rarr;<td>$XDG_CONFIG_HOME/fossil.db
142
+<tr><td>4. if a directory ~/.config exists
143
+ <td>&nbsp;&rarr;<td>~/.config/fossil.db
144
+<tr><td>5. Otherwise<td>&nbsp;&rarr;<td>~/.fossil
145
+</table></blockquote>
144146
145147
Another way of thinking of this algorithm is the following:
146148
147149
* Use "$FOSSIL_HOME/.fossil" if the FOSSIL_HOME variable is defined
148
- * Use the XDG-compatible name (~/.config/fossil.db) on XDG systems
150
+ * Use the XDG-compatible name (usually ~/.config/fossil.db) on XDG systems
149151
if the ~/.fossil file does not already exist
150152
* Otherwise, use the traditional unix name of "~/.fossil"
151153
152154
This algorithm is complex due to the need for historical compatibility.
153
-Originally, the database was always just "$HOME/.fossil". Then support
155
+Originally, the database was always just "~/.fossil". Then support
154156
for the FOSSIL_HOME environment variable as added. Later, support for the
155157
[https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html|XDG-compatible configation filenames]
156
-was added. Each of these changes needed to continue to support legacy installs.
158
+was added. Each of these changes needed to continue to support legacy
159
+installations.
157160
158161
On Windows, the configuration database is the first of the following
159162
for which the corresponding environment variables exist:
160163
161164
* %FOSSIL_HOME%/_fossil
162165
--- www/tech_overview.wiki
+++ www/tech_overview.wiki
@@ -131,31 +131,34 @@
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 * if a directory named $HOME/.config exists &rarr; $HOME/.config/fossil.db
143 * Otherwise $HOME/.fossil
 
 
144
145 Another way of thinking of this algorithm is the following:
146
147 * Use "$FOSSIL_HOME/.fossil" if the FOSSIL_HOME variable is defined
148 * Use the XDG-compatible name (~/.config/fossil.db) on XDG systems
149 if the ~/.fossil file does not already exist
150 * Otherwise, use the traditional unix name of "~/.fossil"
151
152 This algorithm is complex due to the need for historical compatibility.
153 Originally, the database was always just "$HOME/.fossil". Then support
154 for the FOSSIL_HOME environment variable as added. Later, support for the
155 [https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html|XDG-compatible configation filenames]
156 was added. Each of these changes needed to continue to support legacy installs.
 
157
158 On Windows, the configuration database is the first of the following
159 for which the corresponding environment variables exist:
160
161 * %FOSSIL_HOME%/_fossil
162
--- www/tech_overview.wiki
+++ www/tech_overview.wiki
@@ -131,31 +131,34 @@
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 <blockquote><table border="0">
137 <tr><td>1. if environment variable FOSSIL_HOME exists
138 <td>&nbsp;&rarr;&nbsp;<td>$FOSSIL_HOME/.fossil
139 <tr><td>2. if file ~/.fossil exists<td>&nbsp;&rarr;<td>~/.fossil
140 <tr><td>3. if environment variable XDG_CONFIG_HOME exists
141 <td>&nbsp;&rarr;<td>$XDG_CONFIG_HOME/fossil.db
142 <tr><td>4. if a directory ~/.config exists
143 <td>&nbsp;&rarr;<td>~/.config/fossil.db
144 <tr><td>5. Otherwise<td>&nbsp;&rarr;<td>~/.fossil
145 </table></blockquote>
146
147 Another way of thinking of this algorithm is the following:
148
149 * Use "$FOSSIL_HOME/.fossil" if the FOSSIL_HOME variable is defined
150 * Use the XDG-compatible name (usually ~/.config/fossil.db) on XDG systems
151 if the ~/.fossil file does not already exist
152 * Otherwise, use the traditional unix name of "~/.fossil"
153
154 This algorithm is complex due to the need for historical compatibility.
155 Originally, the database was always just "~/.fossil". Then support
156 for the FOSSIL_HOME environment variable as added. Later, support for the
157 [https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html|XDG-compatible configation filenames]
158 was added. Each of these changes needed to continue to support legacy
159 installations.
160
161 On Windows, the configuration database is the first of the following
162 for which the corresponding environment variables exist:
163
164 * %FOSSIL_HOME%/_fossil
165

Keyboard Shortcuts

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