Richard Hipp wrote: > sqlite3_snprintf() is guaranteed to be available. Note, though, that the > first two parameters are reversed. :-\
Well, I only really want to copy up to 3 bytes, so we can "keep it simple, stupid" and just not make a function call. The revised patch is below. But in further testing, I noticed that there is a series of fossil calls involving a sequence of on/off settings to allow-symlinks intermixed with 'fossil update', 'rm', etc that would result in fossil starting to return errors on 'update'. I'm not convinced yet that it is a regression, but the below should be treated with caution until I've had a chance to look at it further. I probably won't get back to that for at least 10 days, though. Someone else can feel free to pick it up from here if they would like. To Stephan's earlier point about just looking specifically for "on" and "off": I would prefer not to do that, since it duplicates logic from is_truth(). (Maybe the fossil devs will want to allow "y" in the future or something, and I wouldn't want a little gotcha lurking in the present patch when that happens. And in any case just looking for "yes" would skip the present valid values of "1", "on", and "true".) [miami:src] $ fossil diff Index: src/vfile.c ================================================================== --- src/vfile.c +++ src/vfile.c @@ -268,21 +268,29 @@ int promptFlag /* Prompt user to confirm overwrites */ ){ Stmt q; Blob content; int nRepos = strlen(g.zLocalRoot); + char bSawSymlinkSetting = 0; + /* In order to properly write out symlinks rather than regular files, + ** we must first observe the .fossil-settings/allow-symlinks file if it + ** exists. If it does, we want to make sure we see it prior to any + ** symlink files. This is why we sort ascending by 'islink'. + */ if( vid>0 && id==0 ){ db_prepare(&q, "SELECT id, %Q || pathname, mrid, isexe, islink" " FROM vfile" - " WHERE vid=%d AND mrid>0", + " WHERE vid=%d AND mrid>0" + " ORDER BY islink ASC", g.zLocalRoot, vid); }else{ assert( vid==0 && id>0 ); db_prepare(&q, "SELECT id, %Q || pathname, mrid, isexe, islink" " FROM vfile" - " WHERE id=%d AND mrid>0", + " WHERE id=%d AND mrid>0" + " ORDER BY islink ASC", g.zLocalRoot, id); } while( db_step(&q)==SQLITE_ROW ){ int id, rid, isExe, isLink; const char *zName; @@ -291,10 +299,21 @@ zName = db_column_text(&q, 1); rid = db_column_int(&q, 2); isExe = db_column_int(&q, 3); isLink = db_column_int(&q, 4); content_get(rid, &content); + if( !bSawSymlinkSetting && + zName[nRepos]=='.' && zName[nRepos+1]=='f' && zName[nRepos+2]=='o' && + strcmp(&zName[nRepos], ".fossil-settings/allow-symlinks")==0 + ){ + char zValue[4] = {0,0,0,0}; + int i=0; + bSawSymlinkSetting = 1; + const char* zCont = blob_str(&content); + while( i<3 && zCont[i]!=0 && zCont[i]!='\n' ){zValue[i]=zCont[i]; ++i;} + g.allowSymlinks = is_truth(zValue); + } if( file_is_the_same(&content, zName) ){ blob_reset(&content); if( file_wd_setexe(zName, isExe) ){ db_multi_exec("UPDATE vfile SET mtime=%lld WHERE id=%d", file_wd_mtime(zName), id); -- Eric A. Rubin-Smith Aterlo Networks, Inc. http://aterlo.com _______________________________________________ fossil-users mailing list fossil-users@lists.fossil-scm.org http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users