Fossil SCM

Fix issue with [9ecbfb3724] that caused the versioned 'allow-symlinks' setting to be ignored.

mistachkin 2015-11-04 00:18 trunk
Commit 81d7ce3018f07798b12266b0c946dca7b5a00c52
1 file changed +51 -5
+51 -5
--- src/db.c
+++ src/db.c
@@ -1134,10 +1134,22 @@
11341134
zRepo = mprintf("%s%s", g.zLocalRoot, zRepo);
11351135
}
11361136
}
11371137
return zRepo;
11381138
}
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
+}
11391151
11401152
/*
11411153
** Open the repository database given by zDbName. If zDbName==NULL then
11421154
** get the name from the already open local database.
11431155
*/
@@ -1172,11 +1184,12 @@
11721184
}
11731185
g.zRepositoryName = mprintf("%s", zDbName);
11741186
db_open_or_attach(g.zRepositoryName, "repository", 0);
11751187
g.repositoryOpen = 1;
11761188
/* 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());
11781191
g.zAuxSchema = db_get("aux-schema","");
11791192
11801193
/* Verify that the PLINK table has a new column added by the
11811194
** 2014-11-28 schema change. Create it if necessary. This code
11821195
** can be removed in the future, once all users have upgraded to the
@@ -2109,10 +2122,17 @@
21092122
int db_get_boolean(const char *zName, int dflt){
21102123
char *zVal = db_get(zName, dflt ? "on" : "off");
21112124
if( is_truth(zVal) ) return 1;
21122125
if( is_false(zVal) ) return 0;
21132126
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;
21142134
}
21152135
char *db_lget(const char *zName, const char *zDefault){
21162136
return db_text(zDefault,
21172137
"SELECT value FROM vvar WHERE name=%Q", zName);
21182138
}
@@ -2219,10 +2239,11 @@
22192239
void cmd_open(void){
22202240
int emptyFlag;
22212241
int keepFlag;
22222242
int forceMissingFlag;
22232243
int allowNested;
2244
+ int allowSymlinks;
22242245
static char *azNewArgv[] = { 0, "checkout", "--prompt", 0, 0, 0, 0 };
22252246
22262247
url_proxy_options();
22272248
emptyFlag = find_option("empty",0,0)!=0;
22282249
keepFlag = find_option("keep",0,0)!=0;
@@ -2246,10 +2267,24 @@
22462267
g.zOpenRevision = g.argv[3];
22472268
}else if( db_exists("SELECT 1 FROM event WHERE type='ci'") ){
22482269
g.zOpenRevision = db_get("main-branch", "trunk");
22492270
}
22502271
}
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
+ }
22512286
22522287
#if defined(_WIN32) || defined(__CYGWIN__)
22532288
# define LOCALDB_NAME "./_FOSSIL_"
22542289
#else
22552290
# define LOCALDB_NAME "./.fslckout"
@@ -2259,14 +2294,25 @@
22592294
"COMMIT; PRAGMA journal_mode=WAL; BEGIN;",
22602295
#endif
22612296
(char*)0);
22622297
db_delete_on_failure(LOCALDB_NAME);
22632298
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());
22682314
}
22692315
db_lset("repository", g.argv[2]);
22702316
db_record_repository_filename(g.argv[2]);
22712317
db_lset_int("checkout", 0);
22722318
azNewArgv[0] = g.argv[0];
22732319
--- 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

Keyboard Shortcuts

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