Fossil SCM
Fix issue with [9ecbfb3724] that caused the versioned 'allow-symlinks' setting to be ignored.
Commit
81d7ce3018f07798b12266b0c946dca7b5a00c52
Parent
aa92270fe96d492…
1 file changed
+51
-5
M
src/db.c
+51
-5
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -1134,10 +1134,22 @@ | ||
| 1134 | 1134 | zRepo = mprintf("%s%s", g.zLocalRoot, zRepo); |
| 1135 | 1135 | } |
| 1136 | 1136 | } |
| 1137 | 1137 | return zRepo; |
| 1138 | 1138 | } |
| 1139 | + | |
| 1140 | +/* | |
| 1141 | +** Returns non-zero if the default value for the "allow-symlinks" setting | |
| 1142 | +** is "on". | |
| 1143 | +*/ | |
| 1144 | +int db_allow_symlinks_by_default(void){ | |
| 1145 | +#if defined(_WIN32) | |
| 1146 | + return 0; | |
| 1147 | +#else | |
| 1148 | + return 1; | |
| 1149 | +#endif | |
| 1150 | +} | |
| 1139 | 1151 | |
| 1140 | 1152 | /* |
| 1141 | 1153 | ** Open the repository database given by zDbName. If zDbName==NULL then |
| 1142 | 1154 | ** get the name from the already open local database. |
| 1143 | 1155 | */ |
| @@ -1172,11 +1184,12 @@ | ||
| 1172 | 1184 | } |
| 1173 | 1185 | g.zRepositoryName = mprintf("%s", zDbName); |
| 1174 | 1186 | db_open_or_attach(g.zRepositoryName, "repository", 0); |
| 1175 | 1187 | g.repositoryOpen = 1; |
| 1176 | 1188 | /* Cache "allow-symlinks" option, because we'll need it on every stat call */ |
| 1177 | - g.allowSymlinks = db_get_boolean("allow-symlinks", 0); | |
| 1189 | + g.allowSymlinks = db_get_boolean("allow-symlinks", | |
| 1190 | + db_allow_symlinks_by_default()); | |
| 1178 | 1191 | g.zAuxSchema = db_get("aux-schema",""); |
| 1179 | 1192 | |
| 1180 | 1193 | /* Verify that the PLINK table has a new column added by the |
| 1181 | 1194 | ** 2014-11-28 schema change. Create it if necessary. This code |
| 1182 | 1195 | ** can be removed in the future, once all users have upgraded to the |
| @@ -2109,10 +2122,17 @@ | ||
| 2109 | 2122 | int db_get_boolean(const char *zName, int dflt){ |
| 2110 | 2123 | char *zVal = db_get(zName, dflt ? "on" : "off"); |
| 2111 | 2124 | if( is_truth(zVal) ) return 1; |
| 2112 | 2125 | if( is_false(zVal) ) return 0; |
| 2113 | 2126 | return dflt; |
| 2127 | +} | |
| 2128 | +int db_get_versioned_boolean(const char *zName, int dflt){ | |
| 2129 | + char *zVal = db_get_versioned(zName, 0); | |
| 2130 | + if( zVal==0 ) return dflt; | |
| 2131 | + if( is_truth(zVal) ) return 1; | |
| 2132 | + if( is_false(zVal) ) return 0; | |
| 2133 | + return dflt; | |
| 2114 | 2134 | } |
| 2115 | 2135 | char *db_lget(const char *zName, const char *zDefault){ |
| 2116 | 2136 | return db_text(zDefault, |
| 2117 | 2137 | "SELECT value FROM vvar WHERE name=%Q", zName); |
| 2118 | 2138 | } |
| @@ -2219,10 +2239,11 @@ | ||
| 2219 | 2239 | void cmd_open(void){ |
| 2220 | 2240 | int emptyFlag; |
| 2221 | 2241 | int keepFlag; |
| 2222 | 2242 | int forceMissingFlag; |
| 2223 | 2243 | int allowNested; |
| 2244 | + int allowSymlinks; | |
| 2224 | 2245 | static char *azNewArgv[] = { 0, "checkout", "--prompt", 0, 0, 0, 0 }; |
| 2225 | 2246 | |
| 2226 | 2247 | url_proxy_options(); |
| 2227 | 2248 | emptyFlag = find_option("empty",0,0)!=0; |
| 2228 | 2249 | keepFlag = find_option("keep",0,0)!=0; |
| @@ -2246,10 +2267,24 @@ | ||
| 2246 | 2267 | g.zOpenRevision = g.argv[3]; |
| 2247 | 2268 | }else if( db_exists("SELECT 1 FROM event WHERE type='ci'") ){ |
| 2248 | 2269 | g.zOpenRevision = db_get("main-branch", "trunk"); |
| 2249 | 2270 | } |
| 2250 | 2271 | } |
| 2272 | + | |
| 2273 | + if( g.zOpenRevision ){ | |
| 2274 | + /* Since the repository is open and we know the revision now, | |
| 2275 | + ** refresh the allow-symlinks flag. Since neither the local | |
| 2276 | + ** checkout nor the configuration database are open at this | |
| 2277 | + ** point, this should always return the versioned setting, | |
| 2278 | + ** if any, or the default value, which is negative one. The | |
| 2279 | + ** value negative one, in this context, means that the code | |
| 2280 | + ** below should fallback to using the setting value from the | |
| 2281 | + ** repository or global configuration databases only. */ | |
| 2282 | + allowSymlinks = db_get_versioned_boolean("allow-symlinks", -1); | |
| 2283 | + }else{ | |
| 2284 | + allowSymlinks = -1; /* Use non-versioned settings only. */ | |
| 2285 | + } | |
| 2251 | 2286 | |
| 2252 | 2287 | #if defined(_WIN32) || defined(__CYGWIN__) |
| 2253 | 2288 | # define LOCALDB_NAME "./_FOSSIL_" |
| 2254 | 2289 | #else |
| 2255 | 2290 | # define LOCALDB_NAME "./.fslckout" |
| @@ -2259,14 +2294,25 @@ | ||
| 2259 | 2294 | "COMMIT; PRAGMA journal_mode=WAL; BEGIN;", |
| 2260 | 2295 | #endif |
| 2261 | 2296 | (char*)0); |
| 2262 | 2297 | db_delete_on_failure(LOCALDB_NAME); |
| 2263 | 2298 | db_open_local(0); |
| 2264 | - if( g.zOpenRevision ){ | |
| 2265 | - /* Since the repository is open and we know the revision now, | |
| 2266 | - ** refresh the allow-symlinks flag. */ | |
| 2267 | - g.allowSymlinks = db_get_boolean("allow-symlinks", 0); | |
| 2299 | + if( allowSymlinks>=0 ){ | |
| 2300 | + /* Use the value from the versioned setting, which was read | |
| 2301 | + ** prior to opening the local checkout (i.e. which is most | |
| 2302 | + ** likely empty and does not actually contain any versioned | |
| 2303 | + ** setting files yet). Normally, this value would be given | |
| 2304 | + ** first priority within db_get_boolean(); however, this is | |
| 2305 | + ** a special case because we know the on-disk files may not | |
| 2306 | + ** exist yet. */ | |
| 2307 | + g.allowSymlinks = allowSymlinks; | |
| 2308 | + }else{ | |
| 2309 | + /* Since the local checkout may not have any files at this | |
| 2310 | + ** point, this will probably be the setting value from the | |
| 2311 | + ** repository or global configuration databases. */ | |
| 2312 | + g.allowSymlinks = db_get_boolean("allow-symlinks", | |
| 2313 | + db_allow_symlinks_by_default()); | |
| 2268 | 2314 | } |
| 2269 | 2315 | db_lset("repository", g.argv[2]); |
| 2270 | 2316 | db_record_repository_filename(g.argv[2]); |
| 2271 | 2317 | db_lset_int("checkout", 0); |
| 2272 | 2318 | azNewArgv[0] = g.argv[0]; |
| 2273 | 2319 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -1134,10 +1134,22 @@ | |
| 1134 | zRepo = mprintf("%s%s", g.zLocalRoot, zRepo); |
| 1135 | } |
| 1136 | } |
| 1137 | return zRepo; |
| 1138 | } |
| 1139 | |
| 1140 | /* |
| 1141 | ** Open the repository database given by zDbName. If zDbName==NULL then |
| 1142 | ** get the name from the already open local database. |
| 1143 | */ |
| @@ -1172,11 +1184,12 @@ | |
| 1172 | } |
| 1173 | g.zRepositoryName = mprintf("%s", zDbName); |
| 1174 | db_open_or_attach(g.zRepositoryName, "repository", 0); |
| 1175 | g.repositoryOpen = 1; |
| 1176 | /* Cache "allow-symlinks" option, because we'll need it on every stat call */ |
| 1177 | g.allowSymlinks = db_get_boolean("allow-symlinks", 0); |
| 1178 | g.zAuxSchema = db_get("aux-schema",""); |
| 1179 | |
| 1180 | /* Verify that the PLINK table has a new column added by the |
| 1181 | ** 2014-11-28 schema change. Create it if necessary. This code |
| 1182 | ** can be removed in the future, once all users have upgraded to the |
| @@ -2109,10 +2122,17 @@ | |
| 2109 | int db_get_boolean(const char *zName, int dflt){ |
| 2110 | char *zVal = db_get(zName, dflt ? "on" : "off"); |
| 2111 | if( is_truth(zVal) ) return 1; |
| 2112 | if( is_false(zVal) ) return 0; |
| 2113 | return dflt; |
| 2114 | } |
| 2115 | char *db_lget(const char *zName, const char *zDefault){ |
| 2116 | return db_text(zDefault, |
| 2117 | "SELECT value FROM vvar WHERE name=%Q", zName); |
| 2118 | } |
| @@ -2219,10 +2239,11 @@ | |
| 2219 | void cmd_open(void){ |
| 2220 | int emptyFlag; |
| 2221 | int keepFlag; |
| 2222 | int forceMissingFlag; |
| 2223 | int allowNested; |
| 2224 | static char *azNewArgv[] = { 0, "checkout", "--prompt", 0, 0, 0, 0 }; |
| 2225 | |
| 2226 | url_proxy_options(); |
| 2227 | emptyFlag = find_option("empty",0,0)!=0; |
| 2228 | keepFlag = find_option("keep",0,0)!=0; |
| @@ -2246,10 +2267,24 @@ | |
| 2246 | g.zOpenRevision = g.argv[3]; |
| 2247 | }else if( db_exists("SELECT 1 FROM event WHERE type='ci'") ){ |
| 2248 | g.zOpenRevision = db_get("main-branch", "trunk"); |
| 2249 | } |
| 2250 | } |
| 2251 | |
| 2252 | #if defined(_WIN32) || defined(__CYGWIN__) |
| 2253 | # define LOCALDB_NAME "./_FOSSIL_" |
| 2254 | #else |
| 2255 | # define LOCALDB_NAME "./.fslckout" |
| @@ -2259,14 +2294,25 @@ | |
| 2259 | "COMMIT; PRAGMA journal_mode=WAL; BEGIN;", |
| 2260 | #endif |
| 2261 | (char*)0); |
| 2262 | db_delete_on_failure(LOCALDB_NAME); |
| 2263 | db_open_local(0); |
| 2264 | if( g.zOpenRevision ){ |
| 2265 | /* Since the repository is open and we know the revision now, |
| 2266 | ** refresh the allow-symlinks flag. */ |
| 2267 | g.allowSymlinks = db_get_boolean("allow-symlinks", 0); |
| 2268 | } |
| 2269 | db_lset("repository", g.argv[2]); |
| 2270 | db_record_repository_filename(g.argv[2]); |
| 2271 | db_lset_int("checkout", 0); |
| 2272 | azNewArgv[0] = g.argv[0]; |
| 2273 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -1134,10 +1134,22 @@ | |
| 1134 | zRepo = mprintf("%s%s", g.zLocalRoot, zRepo); |
| 1135 | } |
| 1136 | } |
| 1137 | return zRepo; |
| 1138 | } |
| 1139 | |
| 1140 | /* |
| 1141 | ** Returns non-zero if the default value for the "allow-symlinks" setting |
| 1142 | ** is "on". |
| 1143 | */ |
| 1144 | int db_allow_symlinks_by_default(void){ |
| 1145 | #if defined(_WIN32) |
| 1146 | return 0; |
| 1147 | #else |
| 1148 | return 1; |
| 1149 | #endif |
| 1150 | } |
| 1151 | |
| 1152 | /* |
| 1153 | ** Open the repository database given by zDbName. If zDbName==NULL then |
| 1154 | ** get the name from the already open local database. |
| 1155 | */ |
| @@ -1172,11 +1184,12 @@ | |
| 1184 | } |
| 1185 | g.zRepositoryName = mprintf("%s", zDbName); |
| 1186 | db_open_or_attach(g.zRepositoryName, "repository", 0); |
| 1187 | g.repositoryOpen = 1; |
| 1188 | /* Cache "allow-symlinks" option, because we'll need it on every stat call */ |
| 1189 | g.allowSymlinks = db_get_boolean("allow-symlinks", |
| 1190 | db_allow_symlinks_by_default()); |
| 1191 | g.zAuxSchema = db_get("aux-schema",""); |
| 1192 | |
| 1193 | /* Verify that the PLINK table has a new column added by the |
| 1194 | ** 2014-11-28 schema change. Create it if necessary. This code |
| 1195 | ** can be removed in the future, once all users have upgraded to the |
| @@ -2109,10 +2122,17 @@ | |
| 2122 | int db_get_boolean(const char *zName, int dflt){ |
| 2123 | char *zVal = db_get(zName, dflt ? "on" : "off"); |
| 2124 | if( is_truth(zVal) ) return 1; |
| 2125 | if( is_false(zVal) ) return 0; |
| 2126 | return dflt; |
| 2127 | } |
| 2128 | int db_get_versioned_boolean(const char *zName, int dflt){ |
| 2129 | char *zVal = db_get_versioned(zName, 0); |
| 2130 | if( zVal==0 ) return dflt; |
| 2131 | if( is_truth(zVal) ) return 1; |
| 2132 | if( is_false(zVal) ) return 0; |
| 2133 | return dflt; |
| 2134 | } |
| 2135 | char *db_lget(const char *zName, const char *zDefault){ |
| 2136 | return db_text(zDefault, |
| 2137 | "SELECT value FROM vvar WHERE name=%Q", zName); |
| 2138 | } |
| @@ -2219,10 +2239,11 @@ | |
| 2239 | void cmd_open(void){ |
| 2240 | int emptyFlag; |
| 2241 | int keepFlag; |
| 2242 | int forceMissingFlag; |
| 2243 | int allowNested; |
| 2244 | int allowSymlinks; |
| 2245 | static char *azNewArgv[] = { 0, "checkout", "--prompt", 0, 0, 0, 0 }; |
| 2246 | |
| 2247 | url_proxy_options(); |
| 2248 | emptyFlag = find_option("empty",0,0)!=0; |
| 2249 | keepFlag = find_option("keep",0,0)!=0; |
| @@ -2246,10 +2267,24 @@ | |
| 2267 | g.zOpenRevision = g.argv[3]; |
| 2268 | }else if( db_exists("SELECT 1 FROM event WHERE type='ci'") ){ |
| 2269 | g.zOpenRevision = db_get("main-branch", "trunk"); |
| 2270 | } |
| 2271 | } |
| 2272 | |
| 2273 | if( g.zOpenRevision ){ |
| 2274 | /* Since the repository is open and we know the revision now, |
| 2275 | ** refresh the allow-symlinks flag. Since neither the local |
| 2276 | ** checkout nor the configuration database are open at this |
| 2277 | ** point, this should always return the versioned setting, |
| 2278 | ** if any, or the default value, which is negative one. The |
| 2279 | ** value negative one, in this context, means that the code |
| 2280 | ** below should fallback to using the setting value from the |
| 2281 | ** repository or global configuration databases only. */ |
| 2282 | allowSymlinks = db_get_versioned_boolean("allow-symlinks", -1); |
| 2283 | }else{ |
| 2284 | allowSymlinks = -1; /* Use non-versioned settings only. */ |
| 2285 | } |
| 2286 | |
| 2287 | #if defined(_WIN32) || defined(__CYGWIN__) |
| 2288 | # define LOCALDB_NAME "./_FOSSIL_" |
| 2289 | #else |
| 2290 | # define LOCALDB_NAME "./.fslckout" |
| @@ -2259,14 +2294,25 @@ | |
| 2294 | "COMMIT; PRAGMA journal_mode=WAL; BEGIN;", |
| 2295 | #endif |
| 2296 | (char*)0); |
| 2297 | db_delete_on_failure(LOCALDB_NAME); |
| 2298 | db_open_local(0); |
| 2299 | if( allowSymlinks>=0 ){ |
| 2300 | /* Use the value from the versioned setting, which was read |
| 2301 | ** prior to opening the local checkout (i.e. which is most |
| 2302 | ** likely empty and does not actually contain any versioned |
| 2303 | ** setting files yet). Normally, this value would be given |
| 2304 | ** first priority within db_get_boolean(); however, this is |
| 2305 | ** a special case because we know the on-disk files may not |
| 2306 | ** exist yet. */ |
| 2307 | g.allowSymlinks = allowSymlinks; |
| 2308 | }else{ |
| 2309 | /* Since the local checkout may not have any files at this |
| 2310 | ** point, this will probably be the setting value from the |
| 2311 | ** repository or global configuration databases. */ |
| 2312 | g.allowSymlinks = db_get_boolean("allow-symlinks", |
| 2313 | db_allow_symlinks_by_default()); |
| 2314 | } |
| 2315 | db_lset("repository", g.argv[2]); |
| 2316 | db_record_repository_filename(g.argv[2]); |
| 2317 | db_lset_int("checkout", 0); |
| 2318 | azNewArgv[0] = g.argv[0]; |
| 2319 |