Fossil SCM
Improve comments on symlink logic
Commit
39a5df1fde741d084db2b4f900ada78adad62e350258034a3f60e8baaae0b13d
Parent
b9ae03f6eeb1569…
1 file changed
+17
-14
+17
-14
| --- src/file.c | ||
| +++ src/file.c | ||
| @@ -47,22 +47,21 @@ | ||
| 47 | 47 | ** used for files that are under management by a Fossil repository. ExtFILE |
| 48 | 48 | ** should be used for files that are not under management. SymFILE is for |
| 49 | 49 | ** a few special cases such as the "fossil test-tarball" command when we never |
| 50 | 50 | ** want to follow symlinks. |
| 51 | 51 | ** |
| 52 | -** If RepoFILE is used and if the allow-symlinks setting is true and if | |
| 53 | -** the object is a symbolic link, then the object is treated like an ordinary | |
| 54 | -** file whose content is name of the object to which the symbolic link | |
| 55 | -** points. | |
| 56 | -** | |
| 57 | -** If ExtFILE is used or allow-symlinks is false, then operations on a | |
| 58 | -** symbolic link are the same as operations on the object to which the | |
| 59 | -** symbolic link points. | |
| 60 | -** | |
| 61 | -** SymFILE is like RepoFILE except that it always uses the target filename of | |
| 62 | -** a symbolic link as the content, instead of the content of the object | |
| 63 | -** that the symlink points to. SymFILE acts as if allow-symlinks is always ON. | |
| 52 | +** ExtFILE Symbolic links always refer to the object to which the | |
| 53 | +** link points. Symlinks are never recognized as symlinks but | |
| 54 | +** instead always appear to the the target object. | |
| 55 | +** | |
| 56 | +** SymFILE Symbolic links always appear to be files whose name is | |
| 57 | +** the target pathname of the symbolic link. | |
| 58 | +** | |
| 59 | +** RepoFILE Like symfile is allow-symlinks is true, or like | |
| 60 | +** ExtFile if allow-symlinks is false. In other words, | |
| 61 | +** symbolic links are only recognized as something different | |
| 62 | +** from files or directories if allow-symlinks is true. | |
| 64 | 63 | */ |
| 65 | 64 | #define ExtFILE 0 /* Always follow symlinks */ |
| 66 | 65 | #define RepoFILE 1 /* Follow symlinks if and only if allow-symlinks is OFF */ |
| 67 | 66 | #define SymFILE 2 /* Never follow symlinks */ |
| 68 | 67 | |
| @@ -134,13 +133,16 @@ | ||
| 134 | 133 | int eFType /* Look at symlink itself if RepoFILE and enabled. */ |
| 135 | 134 | ){ |
| 136 | 135 | int rc; |
| 137 | 136 | void *zMbcs = fossil_utf8_to_path(zFilename, 0); |
| 138 | 137 | #if !defined(_WIN32) |
| 139 | - if( eFType>=RepoFILE && (eFType==SymFILE || db_allow_symlinks()) ){ | |
| 138 | + if( (eFType=RepoFILE && db_allow_symlinks()) | |
| 139 | + || eFType==SymFILE ){ | |
| 140 | + /* Symlinks look like files whose content is the name of the target */ | |
| 140 | 141 | rc = lstat(zMbcs, buf); |
| 141 | 142 | }else{ |
| 143 | + /* Symlinks look like the object to which they point */ | |
| 142 | 144 | rc = stat(zMbcs, buf); |
| 143 | 145 | } |
| 144 | 146 | #else |
| 145 | 147 | rc = win32_stat(zMbcs, buf, eFType); |
| 146 | 148 | #endif |
| @@ -316,11 +318,12 @@ | ||
| 316 | 318 | |
| 317 | 319 | /* |
| 318 | 320 | ** Return TRUE if the named file is a symlink and symlinks are allowed. |
| 319 | 321 | ** Return false for all other cases. |
| 320 | 322 | ** |
| 321 | -** This routines RepoFILE - that zFilename is always a file under management. | |
| 323 | +** This routines assumes RepoFILE - that zFilename is always a file | |
| 324 | +** under management. | |
| 322 | 325 | ** |
| 323 | 326 | ** On Windows, always return False. |
| 324 | 327 | */ |
| 325 | 328 | int file_islink(const char *zFilename){ |
| 326 | 329 | return file_perm(zFilename, RepoFILE)==PERM_LNK; |
| 327 | 330 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -47,22 +47,21 @@ | |
| 47 | ** used for files that are under management by a Fossil repository. ExtFILE |
| 48 | ** should be used for files that are not under management. SymFILE is for |
| 49 | ** a few special cases such as the "fossil test-tarball" command when we never |
| 50 | ** want to follow symlinks. |
| 51 | ** |
| 52 | ** If RepoFILE is used and if the allow-symlinks setting is true and if |
| 53 | ** the object is a symbolic link, then the object is treated like an ordinary |
| 54 | ** file whose content is name of the object to which the symbolic link |
| 55 | ** points. |
| 56 | ** |
| 57 | ** If ExtFILE is used or allow-symlinks is false, then operations on a |
| 58 | ** symbolic link are the same as operations on the object to which the |
| 59 | ** symbolic link points. |
| 60 | ** |
| 61 | ** SymFILE is like RepoFILE except that it always uses the target filename of |
| 62 | ** a symbolic link as the content, instead of the content of the object |
| 63 | ** that the symlink points to. SymFILE acts as if allow-symlinks is always ON. |
| 64 | */ |
| 65 | #define ExtFILE 0 /* Always follow symlinks */ |
| 66 | #define RepoFILE 1 /* Follow symlinks if and only if allow-symlinks is OFF */ |
| 67 | #define SymFILE 2 /* Never follow symlinks */ |
| 68 | |
| @@ -134,13 +133,16 @@ | |
| 134 | int eFType /* Look at symlink itself if RepoFILE and enabled. */ |
| 135 | ){ |
| 136 | int rc; |
| 137 | void *zMbcs = fossil_utf8_to_path(zFilename, 0); |
| 138 | #if !defined(_WIN32) |
| 139 | if( eFType>=RepoFILE && (eFType==SymFILE || db_allow_symlinks()) ){ |
| 140 | rc = lstat(zMbcs, buf); |
| 141 | }else{ |
| 142 | rc = stat(zMbcs, buf); |
| 143 | } |
| 144 | #else |
| 145 | rc = win32_stat(zMbcs, buf, eFType); |
| 146 | #endif |
| @@ -316,11 +318,12 @@ | |
| 316 | |
| 317 | /* |
| 318 | ** Return TRUE if the named file is a symlink and symlinks are allowed. |
| 319 | ** Return false for all other cases. |
| 320 | ** |
| 321 | ** This routines RepoFILE - that zFilename is always a file under management. |
| 322 | ** |
| 323 | ** On Windows, always return False. |
| 324 | */ |
| 325 | int file_islink(const char *zFilename){ |
| 326 | return file_perm(zFilename, RepoFILE)==PERM_LNK; |
| 327 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -47,22 +47,21 @@ | |
| 47 | ** used for files that are under management by a Fossil repository. ExtFILE |
| 48 | ** should be used for files that are not under management. SymFILE is for |
| 49 | ** a few special cases such as the "fossil test-tarball" command when we never |
| 50 | ** want to follow symlinks. |
| 51 | ** |
| 52 | ** ExtFILE Symbolic links always refer to the object to which the |
| 53 | ** link points. Symlinks are never recognized as symlinks but |
| 54 | ** instead always appear to the the target object. |
| 55 | ** |
| 56 | ** SymFILE Symbolic links always appear to be files whose name is |
| 57 | ** the target pathname of the symbolic link. |
| 58 | ** |
| 59 | ** RepoFILE Like symfile is allow-symlinks is true, or like |
| 60 | ** ExtFile if allow-symlinks is false. In other words, |
| 61 | ** symbolic links are only recognized as something different |
| 62 | ** from files or directories if allow-symlinks is true. |
| 63 | */ |
| 64 | #define ExtFILE 0 /* Always follow symlinks */ |
| 65 | #define RepoFILE 1 /* Follow symlinks if and only if allow-symlinks is OFF */ |
| 66 | #define SymFILE 2 /* Never follow symlinks */ |
| 67 | |
| @@ -134,13 +133,16 @@ | |
| 133 | int eFType /* Look at symlink itself if RepoFILE and enabled. */ |
| 134 | ){ |
| 135 | int rc; |
| 136 | void *zMbcs = fossil_utf8_to_path(zFilename, 0); |
| 137 | #if !defined(_WIN32) |
| 138 | if( (eFType=RepoFILE && db_allow_symlinks()) |
| 139 | || eFType==SymFILE ){ |
| 140 | /* Symlinks look like files whose content is the name of the target */ |
| 141 | rc = lstat(zMbcs, buf); |
| 142 | }else{ |
| 143 | /* Symlinks look like the object to which they point */ |
| 144 | rc = stat(zMbcs, buf); |
| 145 | } |
| 146 | #else |
| 147 | rc = win32_stat(zMbcs, buf, eFType); |
| 148 | #endif |
| @@ -316,11 +318,12 @@ | |
| 318 | |
| 319 | /* |
| 320 | ** Return TRUE if the named file is a symlink and symlinks are allowed. |
| 321 | ** Return false for all other cases. |
| 322 | ** |
| 323 | ** This routines assumes RepoFILE - that zFilename is always a file |
| 324 | ** under management. |
| 325 | ** |
| 326 | ** On Windows, always return False. |
| 327 | */ |
| 328 | int file_islink(const char *zFilename){ |
| 329 | return file_perm(zFilename, RepoFILE)==PERM_LNK; |
| 330 |