Fossil SCM
Start a branch with fix to make work consistently a local checkout directly on root ("/").
Commit
518e1f8d7fcb74bb165c4cc30921ff8c803dcb42
Parent
24e298edd02f9b8…
1 file changed
+13
-3
M
src/db.c
+13
-3
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -835,34 +835,44 @@ | ||
| 835 | 835 | ** is found, it is attached to the open database connection too. |
| 836 | 836 | */ |
| 837 | 837 | int db_open_local(void){ |
| 838 | 838 | int i, n; |
| 839 | 839 | char zPwd[2000]; |
| 840 | - static const char *aDbName[] = { "/_FOSSIL_", "/.fos" }; | |
| 840 | + static const char *aDbName[] = { "_FOSSIL_", ".fos" }; | |
| 841 | 841 | |
| 842 | 842 | if( g.localOpen) return 1; |
| 843 | 843 | file_getcwd(zPwd, sizeof(zPwd)-20); |
| 844 | 844 | n = strlen(zPwd); |
| 845 | - if( n==1 && zPwd[0]=='/' ) zPwd[0] = '.'; | |
| 846 | 845 | while( n>0 ){ |
| 847 | 846 | if( file_access(zPwd, W_OK) ) break; |
| 848 | 847 | 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 | + } | |
| 850 | 853 | if( isValidLocalDb(zPwd) ){ |
| 851 | 854 | /* Found a valid checkout database file */ |
| 852 | 855 | zPwd[n] = 0; |
| 853 | 856 | while( n>1 && zPwd[n-1]=='/' ){ |
| 854 | 857 | n--; |
| 855 | 858 | zPwd[n] = 0; |
| 856 | 859 | } |
| 860 | + if( zPwd[n-1] == '/'){ | |
| 861 | + g.zLocalRoot = mprintf("%s", zPwd); | |
| 862 | + }else{ | |
| 857 | 863 | g.zLocalRoot = mprintf("%s/", zPwd); |
| 864 | + } | |
| 858 | 865 | return 1; |
| 859 | 866 | } |
| 860 | 867 | } |
| 861 | 868 | n--; |
| 862 | 869 | while( n>0 && zPwd[n]!='/' ){ n--; } |
| 863 | 870 | while( n>0 && zPwd[n-1]=='/' ){ n--; } |
| 871 | + if(n==0 && zPwd[0]=='/'){ | |
| 872 | + n=1; | |
| 873 | + } | |
| 864 | 874 | zPwd[n] = 0; |
| 865 | 875 | } |
| 866 | 876 | |
| 867 | 877 | /* A checkout database file could not be found */ |
| 868 | 878 | return 0; |
| 869 | 879 |
| --- 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 |