Fossil SCM

Start a branch with fix to make work consistently a local checkout directly on root ("/").

meeks 2011-11-11 12:13 trunk
Commit 518e1f8d7fcb74bb165c4cc30921ff8c803dcb42
1 file changed +13 -3
+13 -3
--- src/db.c
+++ src/db.c
@@ -835,34 +835,44 @@
835835
** is found, it is attached to the open database connection too.
836836
*/
837837
int db_open_local(void){
838838
int i, n;
839839
char zPwd[2000];
840
- static const char *aDbName[] = { "/_FOSSIL_", "/.fos" };
840
+ static const char *aDbName[] = { "_FOSSIL_", ".fos" };
841841
842842
if( g.localOpen) return 1;
843843
file_getcwd(zPwd, sizeof(zPwd)-20);
844844
n = strlen(zPwd);
845
- if( n==1 && zPwd[0]=='/' ) zPwd[0] = '.';
846845
while( n>0 ){
847846
if( file_access(zPwd, W_OK) ) break;
848847
for(i=0; i<sizeof(aDbName)/sizeof(aDbName[0]); i++){
849
- sqlite3_snprintf(sizeof(zPwd)-n, &zPwd[n], "%s", aDbName[i]);
848
+ if( zPwd[n-1] == '/'){
849
+ sqlite3_snprintf(sizeof(zPwd)-n, &zPwd[n], "%s", aDbName[i]);
850
+ }else{
851
+ sqlite3_snprintf(sizeof(zPwd)-n, &zPwd[n], "/%s", aDbName[i]);
852
+ }
850853
if( isValidLocalDb(zPwd) ){
851854
/* Found a valid checkout database file */
852855
zPwd[n] = 0;
853856
while( n>1 && zPwd[n-1]=='/' ){
854857
n--;
855858
zPwd[n] = 0;
856859
}
860
+ if( zPwd[n-1] == '/'){
861
+ g.zLocalRoot = mprintf("%s", zPwd);
862
+ }else{
857863
g.zLocalRoot = mprintf("%s/", zPwd);
864
+ }
858865
return 1;
859866
}
860867
}
861868
n--;
862869
while( n>0 && zPwd[n]!='/' ){ n--; }
863870
while( n>0 && zPwd[n-1]=='/' ){ n--; }
871
+ if(n==0 && zPwd[0]=='/'){
872
+ n=1;
873
+ }
864874
zPwd[n] = 0;
865875
}
866876
867877
/* A checkout database file could not be found */
868878
return 0;
869879
--- src/db.c
+++ src/db.c
@@ -835,34 +835,44 @@
835 ** is found, it is attached to the open database connection too.
836 */
837 int db_open_local(void){
838 int i, n;
839 char zPwd[2000];
840 static const char *aDbName[] = { "/_FOSSIL_", "/.fos" };
841
842 if( g.localOpen) return 1;
843 file_getcwd(zPwd, sizeof(zPwd)-20);
844 n = strlen(zPwd);
845 if( n==1 && zPwd[0]=='/' ) zPwd[0] = '.';
846 while( n>0 ){
847 if( file_access(zPwd, W_OK) ) break;
848 for(i=0; i<sizeof(aDbName)/sizeof(aDbName[0]); i++){
849 sqlite3_snprintf(sizeof(zPwd)-n, &zPwd[n], "%s", aDbName[i]);
 
 
 
 
850 if( isValidLocalDb(zPwd) ){
851 /* Found a valid checkout database file */
852 zPwd[n] = 0;
853 while( n>1 && zPwd[n-1]=='/' ){
854 n--;
855 zPwd[n] = 0;
856 }
 
 
 
857 g.zLocalRoot = mprintf("%s/", zPwd);
 
858 return 1;
859 }
860 }
861 n--;
862 while( n>0 && zPwd[n]!='/' ){ n--; }
863 while( n>0 && zPwd[n-1]=='/' ){ n--; }
 
 
 
864 zPwd[n] = 0;
865 }
866
867 /* A checkout database file could not be found */
868 return 0;
869
--- src/db.c
+++ src/db.c
@@ -835,34 +835,44 @@
835 ** is found, it is attached to the open database connection too.
836 */
837 int db_open_local(void){
838 int i, n;
839 char zPwd[2000];
840 static const char *aDbName[] = { "_FOSSIL_", ".fos" };
841
842 if( g.localOpen) return 1;
843 file_getcwd(zPwd, sizeof(zPwd)-20);
844 n = strlen(zPwd);
 
845 while( n>0 ){
846 if( file_access(zPwd, W_OK) ) break;
847 for(i=0; i<sizeof(aDbName)/sizeof(aDbName[0]); i++){
848 if( zPwd[n-1] == '/'){
849 sqlite3_snprintf(sizeof(zPwd)-n, &zPwd[n], "%s", aDbName[i]);
850 }else{
851 sqlite3_snprintf(sizeof(zPwd)-n, &zPwd[n], "/%s", aDbName[i]);
852 }
853 if( isValidLocalDb(zPwd) ){
854 /* Found a valid checkout database file */
855 zPwd[n] = 0;
856 while( n>1 && zPwd[n-1]=='/' ){
857 n--;
858 zPwd[n] = 0;
859 }
860 if( zPwd[n-1] == '/'){
861 g.zLocalRoot = mprintf("%s", zPwd);
862 }else{
863 g.zLocalRoot = mprintf("%s/", zPwd);
864 }
865 return 1;
866 }
867 }
868 n--;
869 while( n>0 && zPwd[n]!='/' ){ n--; }
870 while( n>0 && zPwd[n-1]=='/' ){ n--; }
871 if(n==0 && zPwd[0]=='/'){
872 n=1;
873 }
874 zPwd[n] = 0;
875 }
876
877 /* A checkout database file could not be found */
878 return 0;
879

Keyboard Shortcuts

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