Fossil SCM

Improvements to HOME search on windows, and improve the documentation of the same.

drh 2019-08-13 20:31 trunk merge
Commit 006afac0f04b31672ec3ed7fbb176840c62a227feaeea91ff25c50bbed4a2855
2 files changed +8 -5 +35 -50
+8 -5
--- src/db.c
+++ src/db.c
@@ -1383,21 +1383,24 @@
13831383
if( zHome==0 ){
13841384
zHome = fossil_getenv("LOCALAPPDATA");
13851385
if( zHome==0 ){
13861386
zHome = fossil_getenv("APPDATA");
13871387
if( zHome==0 ){
1388
- char *zDrive = fossil_getenv("HOMEDRIVE");
1389
- char *zPath = fossil_getenv("HOMEPATH");
1390
- if( zDrive && zPath ) zHome = mprintf("%s%s", zDrive, zPath);
1388
+ zHome = fossil_getenv("USERPROFILE");
1389
+ if( zHome==0 ){
1390
+ char *zDrive = fossil_getenv("HOMEDRIVE");
1391
+ char *zPath = fossil_getenv("HOMEPATH");
1392
+ if( zDrive && zPath ) zHome = mprintf("%s%s", zDrive, zPath);
1393
+ }
13911394
}
13921395
}
13931396
}
13941397
if( zHome==0 ){
13951398
if( isOptional ) return 0;
13961399
fossil_panic("cannot locate home directory - please set the "
1397
- "FOSSIL_HOME, LOCALAPPDATA, APPDATA, or HOMEPATH "
1398
- "environment variables");
1400
+ "FOSSIL_HOME, LOCALAPPDATA, APPDATA, USERPROFILE, "
1401
+ "or HOMEDRIVE / HOMEPATH environment variables");
13991402
}
14001403
#else
14011404
if( zHome==0 ){
14021405
zHome = fossil_getenv("HOME");
14031406
}
14041407
--- src/db.c
+++ src/db.c
@@ -1383,21 +1383,24 @@
1383 if( zHome==0 ){
1384 zHome = fossil_getenv("LOCALAPPDATA");
1385 if( zHome==0 ){
1386 zHome = fossil_getenv("APPDATA");
1387 if( zHome==0 ){
1388 char *zDrive = fossil_getenv("HOMEDRIVE");
1389 char *zPath = fossil_getenv("HOMEPATH");
1390 if( zDrive && zPath ) zHome = mprintf("%s%s", zDrive, zPath);
 
 
 
1391 }
1392 }
1393 }
1394 if( zHome==0 ){
1395 if( isOptional ) return 0;
1396 fossil_panic("cannot locate home directory - please set the "
1397 "FOSSIL_HOME, LOCALAPPDATA, APPDATA, or HOMEPATH "
1398 "environment variables");
1399 }
1400 #else
1401 if( zHome==0 ){
1402 zHome = fossil_getenv("HOME");
1403 }
1404
--- src/db.c
+++ src/db.c
@@ -1383,21 +1383,24 @@
1383 if( zHome==0 ){
1384 zHome = fossil_getenv("LOCALAPPDATA");
1385 if( zHome==0 ){
1386 zHome = fossil_getenv("APPDATA");
1387 if( zHome==0 ){
1388 zHome = fossil_getenv("USERPROFILE");
1389 if( zHome==0 ){
1390 char *zDrive = fossil_getenv("HOMEDRIVE");
1391 char *zPath = fossil_getenv("HOMEPATH");
1392 if( zDrive && zPath ) zHome = mprintf("%s%s", zDrive, zPath);
1393 }
1394 }
1395 }
1396 }
1397 if( zHome==0 ){
1398 if( isOptional ) return 0;
1399 fossil_panic("cannot locate home directory - please set the "
1400 "FOSSIL_HOME, LOCALAPPDATA, APPDATA, USERPROFILE, "
1401 "or HOMEDRIVE / HOMEPATH environment variables");
1402 }
1403 #else
1404 if( zHome==0 ){
1405 zHome = fossil_getenv("HOME");
1406 }
1407
+35 -50
--- www/env-opts.md
+++ www/env-opts.md
@@ -112,16 +112,25 @@
112112
113113
114114
Environment Variables
115115
---------------------
116116
117
+On most platforms, the location of the user’s account-wide `.fossil`
118
+file is either `FOSSIL_HOME` or `HOME`, in that order. This ordering
119
+lets you put this file somewhere other than at the top of your user’s
120
+home directory by defining `FOSSIL_HOME` to mask the always-defined
121
+`HOME`.
117122
118
-`APPDATA`: (Windows) Location of the `~/.fossil` file. The first
119
-environment variable found in the environment from the list
120
-`FOSSIL_HOME`, `LOCALAPPDATA` (Windows), `APPDATA` (Windows),
121
-`HOMEDRIVE` and `HOMEPATH` (Windows, used together), and `HOME` is
122
-used as the location of the `~/.fossil` file.
123
+For native Windows builds and for Cygwin builds, the file is called
124
+`_fossil` instead to avoid problems with old programs that assume file
125
+names cannot begin with a dot, as was true in old versions of Windows
126
+and in MS-DOS. (Newer Microsoft OSes and file systems don’t have a
127
+problem with such files, but still we take the safe path in case you’re
128
+on a system with software that can’t cope.) We start our search with
129
+`FOSSIL_HOME` again, but instead of falling back to `HOME`, we instead
130
+try `USERPROFILE`, then `LOCALAPPDATA`, then `APPDATA`, and finally we
131
+concatenate `HOMEDRIVE` + `HOMEPATH`.
123132
124133
`EDITOR`: Name the editor to use for check-in and stash comments.
125134
Overridden by the local or global `editor` setting or the `VISUAL`
126135
environment variable.
127136
@@ -175,25 +184,15 @@
175184
176185
`FOSSIL_TCL_PATH`: When Tcl stubs support is configured, point to a
177186
specific file or folder containing the version of Tcl to load at run
178187
time.
179188
180
-`FOSSIL_TEMP`: Fallback location of the temporary directories and files
181
-created and deleted when running the test suite. The first environment
182
-variable found in the environment from the list `FOSSIL_TEST_TEMP`,
183
-`FOSSIL_TEMP`, `TEMP`, and `TMP` is used.
184
-
185189
`FOSSIL_TEST_DANGEROUS_IGNORE_OPEN_CHECKOUT`: When set to the literal
186190
value `YES_DO_IT`, the test suite will relax the constraint that some
187191
tests may not run within an open checkout. This is subject to removal
188192
in the future.
189193
190
-`FOSSIL_TEST_TEMP`: Primary location of the temporary directories
191
-and files created and deleted when running the test suite. The
192
-first environment variable found in the environment from the list
193
-`FOSSIL_TEST_TEMP`, `FOSSIL_TEMP`, `TEMP`, and `TMP` is used.
194
-
195194
`FOSSIL_VFS`: Name a VFS to load into SQLite.
196195
197196
`GATEWAY_INTERFACE`: If present and the `--nocgi` option is not, assume
198197
fossil is invoked from a web server as a CGI command, and act
199198
accordingly.
@@ -259,16 +258,10 @@
259258
260259
261260
`SYSTEMROOT`: (Windows) Used to locate `notepad.exe` as a
262261
fall back comment editor.
263262
264
-`TEMP`: On Windows, the location of temporary files. The first
265
-environment variable found in the environment that names an existing
266
-directory from the list `TMP`, `TEMP`, `USERPROFILE`, the Windows
267
-directory (usually `C:\WINDOWS`), `TEMP`, `TMP`, and the current
268
-directory (aka `.`) is the temporary folder.
269
-
270263
`TERM`: If the linenoise library is used (almost certainly not on
271264
Windows), it will check `TERM` to verify that the interactive terminal
272265
is not named on a short list on terminals known to not work with
273266
linenoise. Linenoise is a library that provides command history and
274267
command line editing to interactive programs, and can be used in the
@@ -296,16 +289,10 @@
296289
297290
`TH1_TEST_USER_CAPS`: Override the default user permissions used when
298291
processing the `--set-user-caps` option for the `test-th-eval`,
299292
`test-th-render`, and `test-th-source` test commands.
300293
301
-`TMP`: On Windows, the location of temporary files. The first
302
-environment variable found in the environment that names an existing
303
-directory from the list `TMP`, `TEMP`, `USERPROFILE`, the Windows
304
-directory (usually `C:\WINDOWS`), `TEMP`, `TMP`, and the current
305
-directory (aka `.`) is the temporary folder.
306
-
307294
`TMPDIR`: Names the temporary file location for SQLite.
308295
309296
310297
`USER`: Name of the logged in user on many Unix-like platforms.
311298
Used as the fossil user name if `FOSSIL_USER` is not specified. See
@@ -313,16 +300,10 @@
313300
314301
`USERNAME`: Name of the logged in user on Windows platforms.
315302
Used as the fossil user name if `FOSSIL_USER` is not specified. See
316303
the discussion of Fossil Username below for a lot more detail.
317304
318
-`USERPROFILE`: On Windows, the location of temporary files. The first
319
-environment variable found in the environment that names an existing
320
-directory from the list `TMP`, `TEMP`, `USERPROFILE`, the Windows
321
-directory (usually `C:\WINDOWS`), `TEMP`, `TMP`, and the current
322
-directory (aka `.`) is the temporary folder.
323
-
324305
`VISUAL`: Name the editor to use for check-in and stash comments.
325306
Overrides the `EDITOR` environment variable. Overridden by the local
326307
or global `editor` setting.
327308
328309
@@ -453,30 +434,34 @@
453434
precedence.
454435
455436
456437
### Temporary File Location
457438
458
-Fossil places some temporary files in the current directory, notably
439
+Fossil places some temporary files in the checkout directory. Most notably,
459440
supporting files related to merge conflicts are placed in the same
460441
folder as the merge result.
461442
462
-Other temporary files need a home. On Unix-like systems, the first
463
-folder from the hard coded list `/var/tmp`, `/usr/tmp`, `/tmp`,
464
-`/temp`, and `.` that is found to exist in the file system is used by
465
-fossil. The SQLite library has its own code for finding a safe place for
466
-temporary files. It checks the environment variables `SQLITE_TMPDIR`
467
-and `TMPDIR` ahead of the hard coded list `/var/tmp`, `/usr/tmp`,
468
-`/tmp`, and `.` for the first directory that exists.
469
-
470
-On Windows, fossil calls [`GetTempPath`][gtp], and also queries the
471
-environment variables `TEMP`, and `TMP`. If none of those three places
472
-exist, then it uses `.`. Notice that `GetTempPath` itself used `TMP`,
473
-`TEMP`, `USERPROFILE`, and the Windows folder (named in the variable
474
-`SystemRoot`). Since the Windows folder always exists, but in modern
475
-versions of Windows is generally *not* writable by the logged in user,
476
-not having `TEMP`, `TMP`, or `USERPROFILE` set is almost guaranteed to
477
-cause trouble.
443
+Other temporary files need a different home. The rules for choosing one are
444
+complicated.
445
+
446
+Fossil-specific code uses `FOSSIL_TEMP`, `TEMP`, and `TMP`, in that
447
+order. Fossil’s own test suite prepends `FOSSIL_TEST_TEMP` to that list.
448
+
449
+The underlying SQLite code uses several different path sets for its temp
450
+files, depending on the platform type.
451
+
452
+On Unix-like platforms, excepting Cygwin, SQLite first checks the
453
+environment variables `SQLITE_TMPDIR` and `TMPDIR`, in that order. If
454
+neither is defined, it falls back to a hard-coded list of paths:
455
+`/var/tmp`, `/usr/tmp`, and `/tmp`. If all of that fails, it uses the
456
+current working directory.
457
+
458
+For Cygwin builds, SQLite instead uses the first defined variable in
459
+this list: `SQLITE_TMPDIR`, `TMPDIR`, `TMP`, `TEMP`, and `USERPROFILE`.
460
+
461
+For native Windows builds, SQLite simply calls the OS’s [`GetTempPath()`
462
+API][gtp]. See that reference page for details.
478463
479464
[gtp]: https://msdn.microsoft.com/en-us/library/windows/desktop/aa364992%28v=vs.85%29.aspx
480465
481466
482467
483468
--- www/env-opts.md
+++ www/env-opts.md
@@ -112,16 +112,25 @@
112
113
114 Environment Variables
115 ---------------------
116
 
 
 
 
 
117
118 `APPDATA`: (Windows) Location of the `~/.fossil` file. The first
119 environment variable found in the environment from the list
120 `FOSSIL_HOME`, `LOCALAPPDATA` (Windows), `APPDATA` (Windows),
121 `HOMEDRIVE` and `HOMEPATH` (Windows, used together), and `HOME` is
122 used as the location of the `~/.fossil` file.
 
 
 
 
123
124 `EDITOR`: Name the editor to use for check-in and stash comments.
125 Overridden by the local or global `editor` setting or the `VISUAL`
126 environment variable.
127
@@ -175,25 +184,15 @@
175
176 `FOSSIL_TCL_PATH`: When Tcl stubs support is configured, point to a
177 specific file or folder containing the version of Tcl to load at run
178 time.
179
180 `FOSSIL_TEMP`: Fallback location of the temporary directories and files
181 created and deleted when running the test suite. The first environment
182 variable found in the environment from the list `FOSSIL_TEST_TEMP`,
183 `FOSSIL_TEMP`, `TEMP`, and `TMP` is used.
184
185 `FOSSIL_TEST_DANGEROUS_IGNORE_OPEN_CHECKOUT`: When set to the literal
186 value `YES_DO_IT`, the test suite will relax the constraint that some
187 tests may not run within an open checkout. This is subject to removal
188 in the future.
189
190 `FOSSIL_TEST_TEMP`: Primary location of the temporary directories
191 and files created and deleted when running the test suite. The
192 first environment variable found in the environment from the list
193 `FOSSIL_TEST_TEMP`, `FOSSIL_TEMP`, `TEMP`, and `TMP` is used.
194
195 `FOSSIL_VFS`: Name a VFS to load into SQLite.
196
197 `GATEWAY_INTERFACE`: If present and the `--nocgi` option is not, assume
198 fossil is invoked from a web server as a CGI command, and act
199 accordingly.
@@ -259,16 +258,10 @@
259
260
261 `SYSTEMROOT`: (Windows) Used to locate `notepad.exe` as a
262 fall back comment editor.
263
264 `TEMP`: On Windows, the location of temporary files. The first
265 environment variable found in the environment that names an existing
266 directory from the list `TMP`, `TEMP`, `USERPROFILE`, the Windows
267 directory (usually `C:\WINDOWS`), `TEMP`, `TMP`, and the current
268 directory (aka `.`) is the temporary folder.
269
270 `TERM`: If the linenoise library is used (almost certainly not on
271 Windows), it will check `TERM` to verify that the interactive terminal
272 is not named on a short list on terminals known to not work with
273 linenoise. Linenoise is a library that provides command history and
274 command line editing to interactive programs, and can be used in the
@@ -296,16 +289,10 @@
296
297 `TH1_TEST_USER_CAPS`: Override the default user permissions used when
298 processing the `--set-user-caps` option for the `test-th-eval`,
299 `test-th-render`, and `test-th-source` test commands.
300
301 `TMP`: On Windows, the location of temporary files. The first
302 environment variable found in the environment that names an existing
303 directory from the list `TMP`, `TEMP`, `USERPROFILE`, the Windows
304 directory (usually `C:\WINDOWS`), `TEMP`, `TMP`, and the current
305 directory (aka `.`) is the temporary folder.
306
307 `TMPDIR`: Names the temporary file location for SQLite.
308
309
310 `USER`: Name of the logged in user on many Unix-like platforms.
311 Used as the fossil user name if `FOSSIL_USER` is not specified. See
@@ -313,16 +300,10 @@
313
314 `USERNAME`: Name of the logged in user on Windows platforms.
315 Used as the fossil user name if `FOSSIL_USER` is not specified. See
316 the discussion of Fossil Username below for a lot more detail.
317
318 `USERPROFILE`: On Windows, the location of temporary files. The first
319 environment variable found in the environment that names an existing
320 directory from the list `TMP`, `TEMP`, `USERPROFILE`, the Windows
321 directory (usually `C:\WINDOWS`), `TEMP`, `TMP`, and the current
322 directory (aka `.`) is the temporary folder.
323
324 `VISUAL`: Name the editor to use for check-in and stash comments.
325 Overrides the `EDITOR` environment variable. Overridden by the local
326 or global `editor` setting.
327
328
@@ -453,30 +434,34 @@
453 precedence.
454
455
456 ### Temporary File Location
457
458 Fossil places some temporary files in the current directory, notably
459 supporting files related to merge conflicts are placed in the same
460 folder as the merge result.
461
462 Other temporary files need a home. On Unix-like systems, the first
463 folder from the hard coded list `/var/tmp`, `/usr/tmp`, `/tmp`,
464 `/temp`, and `.` that is found to exist in the file system is used by
465 fossil. The SQLite library has its own code for finding a safe place for
466 temporary files. It checks the environment variables `SQLITE_TMPDIR`
467 and `TMPDIR` ahead of the hard coded list `/var/tmp`, `/usr/tmp`,
468 `/tmp`, and `.` for the first directory that exists.
469
470 On Windows, fossil calls [`GetTempPath`][gtp], and also queries the
471 environment variables `TEMP`, and `TMP`. If none of those three places
472 exist, then it uses `.`. Notice that `GetTempPath` itself used `TMP`,
473 `TEMP`, `USERPROFILE`, and the Windows folder (named in the variable
474 `SystemRoot`). Since the Windows folder always exists, but in modern
475 versions of Windows is generally *not* writable by the logged in user,
476 not having `TEMP`, `TMP`, or `USERPROFILE` set is almost guaranteed to
477 cause trouble.
 
 
 
 
478
479 [gtp]: https://msdn.microsoft.com/en-us/library/windows/desktop/aa364992%28v=vs.85%29.aspx
480
481
482
483
--- www/env-opts.md
+++ www/env-opts.md
@@ -112,16 +112,25 @@
112
113
114 Environment Variables
115 ---------------------
116
117 On most platforms, the location of the user’s account-wide `.fossil`
118 file is either `FOSSIL_HOME` or `HOME`, in that order. This ordering
119 lets you put this file somewhere other than at the top of your user’s
120 home directory by defining `FOSSIL_HOME` to mask the always-defined
121 `HOME`.
122
123 For native Windows builds and for Cygwin builds, the file is called
124 `_fossil` instead to avoid problems with old programs that assume file
125 names cannot begin with a dot, as was true in old versions of Windows
126 and in MS-DOS. (Newer Microsoft OSes and file systems don’t have a
127 problem with such files, but still we take the safe path in case you’re
128 on a system with software that can’t cope.) We start our search with
129 `FOSSIL_HOME` again, but instead of falling back to `HOME`, we instead
130 try `USERPROFILE`, then `LOCALAPPDATA`, then `APPDATA`, and finally we
131 concatenate `HOMEDRIVE` + `HOMEPATH`.
132
133 `EDITOR`: Name the editor to use for check-in and stash comments.
134 Overridden by the local or global `editor` setting or the `VISUAL`
135 environment variable.
136
@@ -175,25 +184,15 @@
184
185 `FOSSIL_TCL_PATH`: When Tcl stubs support is configured, point to a
186 specific file or folder containing the version of Tcl to load at run
187 time.
188
 
 
 
 
 
189 `FOSSIL_TEST_DANGEROUS_IGNORE_OPEN_CHECKOUT`: When set to the literal
190 value `YES_DO_IT`, the test suite will relax the constraint that some
191 tests may not run within an open checkout. This is subject to removal
192 in the future.
193
 
 
 
 
 
194 `FOSSIL_VFS`: Name a VFS to load into SQLite.
195
196 `GATEWAY_INTERFACE`: If present and the `--nocgi` option is not, assume
197 fossil is invoked from a web server as a CGI command, and act
198 accordingly.
@@ -259,16 +258,10 @@
258
259
260 `SYSTEMROOT`: (Windows) Used to locate `notepad.exe` as a
261 fall back comment editor.
262
 
 
 
 
 
 
263 `TERM`: If the linenoise library is used (almost certainly not on
264 Windows), it will check `TERM` to verify that the interactive terminal
265 is not named on a short list on terminals known to not work with
266 linenoise. Linenoise is a library that provides command history and
267 command line editing to interactive programs, and can be used in the
@@ -296,16 +289,10 @@
289
290 `TH1_TEST_USER_CAPS`: Override the default user permissions used when
291 processing the `--set-user-caps` option for the `test-th-eval`,
292 `test-th-render`, and `test-th-source` test commands.
293
 
 
 
 
 
 
294 `TMPDIR`: Names the temporary file location for SQLite.
295
296
297 `USER`: Name of the logged in user on many Unix-like platforms.
298 Used as the fossil user name if `FOSSIL_USER` is not specified. See
@@ -313,16 +300,10 @@
300
301 `USERNAME`: Name of the logged in user on Windows platforms.
302 Used as the fossil user name if `FOSSIL_USER` is not specified. See
303 the discussion of Fossil Username below for a lot more detail.
304
 
 
 
 
 
 
305 `VISUAL`: Name the editor to use for check-in and stash comments.
306 Overrides the `EDITOR` environment variable. Overridden by the local
307 or global `editor` setting.
308
309
@@ -453,30 +434,34 @@
434 precedence.
435
436
437 ### Temporary File Location
438
439 Fossil places some temporary files in the checkout directory. Most notably,
440 supporting files related to merge conflicts are placed in the same
441 folder as the merge result.
442
443 Other temporary files need a different home. The rules for choosing one are
444 complicated.
445
446 Fossil-specific code uses `FOSSIL_TEMP`, `TEMP`, and `TMP`, in that
447 order. Fossil’s own test suite prepends `FOSSIL_TEST_TEMP` to that list.
448
449 The underlying SQLite code uses several different path sets for its temp
450 files, depending on the platform type.
451
452 On Unix-like platforms, excepting Cygwin, SQLite first checks the
453 environment variables `SQLITE_TMPDIR` and `TMPDIR`, in that order. If
454 neither is defined, it falls back to a hard-coded list of paths:
455 `/var/tmp`, `/usr/tmp`, and `/tmp`. If all of that fails, it uses the
456 current working directory.
457
458 For Cygwin builds, SQLite instead uses the first defined variable in
459 this list: `SQLITE_TMPDIR`, `TMPDIR`, `TMP`, `TEMP`, and `USERPROFILE`.
460
461 For native Windows builds, SQLite simply calls the OS’s [`GetTempPath()`
462 API][gtp]. See that reference page for details.
463
464 [gtp]: https://msdn.microsoft.com/en-us/library/windows/desktop/aa364992%28v=vs.85%29.aspx
465
466
467
468

Keyboard Shortcuts

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