Fossil SCM
In db_open_local() check writability of local-db itself in stead of the directory it is in. This should enable fossil checkouts on NFS-mounts, which sometimes lie about writability of directories.
Commit
beb91c916348be092a87ed20ddc12f5c16fb6525
Parent
98fd649a9af410e…
1 file changed
+9
-9
M
src/db.c
+9
-9
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -221,11 +221,11 @@ | ||
| 221 | 221 | ** rolls back rather than commit. It is the responsibility of the |
| 222 | 222 | ** hooks themselves to issue any error messages. |
| 223 | 223 | */ |
| 224 | 224 | void db_commit_hook(int (*x)(void), int sequence){ |
| 225 | 225 | int i; |
| 226 | - assert( db.nCommitHook < sizeof(db.aHook)/sizeof(db.aHook[1]) ); | |
| 226 | + assert( db.nCommitHook < count(db.aHook) ); | |
| 227 | 227 | for(i=0; i<db.nCommitHook; i++){ |
| 228 | 228 | assert( x!=db.aHook[i].xHook ); |
| 229 | 229 | if( db.aHook[i].sequence>sequence ){ |
| 230 | 230 | int s = sequence; |
| 231 | 231 | int (*xS)(void) = x; |
| @@ -920,32 +920,32 @@ | ||
| 920 | 920 | ** that contains a valid repository database. |
| 921 | 921 | ** |
| 922 | 922 | ** For legacy, also look for ".fos". The use of ".fos" is deprecated |
| 923 | 923 | ** since "fos" has negative connotations in Hungarian, we are told. |
| 924 | 924 | ** |
| 925 | -** If no valid _FOSSIL_ or .fos file is found, we move up one level and | |
| 925 | +** If no valid _FOSSIL_ or .fslckout file is found, we move up one level and | |
| 926 | 926 | ** try again. Once the file is found, the g.zLocalRoot variable is set |
| 927 | 927 | ** to the root of the repository tree and this routine returns 1. If |
| 928 | 928 | ** no database is found, then this routine return 0. |
| 929 | 929 | ** |
| 930 | 930 | ** This routine always opens the user database regardless of whether or |
| 931 | -** not the repository database is found. If the _FOSSIL_ or .fos file | |
| 931 | +** not the repository database is found. If the _FOSSIL_ or .fslckout file | |
| 932 | 932 | ** is found, it is attached to the open database connection too. |
| 933 | 933 | */ |
| 934 | 934 | int db_open_local(void){ |
| 935 | 935 | int i, n; |
| 936 | 936 | char zPwd[2000]; |
| 937 | - static const char *const aDbName[] = { "/_FOSSIL_", "/.fslckout", "/.fos" }; | |
| 937 | + static const char aDbName[][10] = { "_FOSSIL_", ".fslckout", ".fos" }; | |
| 938 | 938 | |
| 939 | 939 | if( g.localOpen) return 1; |
| 940 | 940 | file_getcwd(zPwd, sizeof(zPwd)-20); |
| 941 | 941 | n = strlen(zPwd); |
| 942 | 942 | if( n==1 && zPwd[0]=='/' ) zPwd[0] = '.'; |
| 943 | 943 | while( n>0 ){ |
| 944 | - if( file_access(zPwd, W_OK) ) break; | |
| 945 | - for(i=0; i<sizeof(aDbName)/sizeof(aDbName[0]); i++){ | |
| 946 | - sqlite3_snprintf(sizeof(zPwd)-n, &zPwd[n], "%s", aDbName[i]); | |
| 944 | + for(i=0; i<count(aDbName); i++){ | |
| 945 | + sqlite3_snprintf(sizeof(zPwd)-n, &zPwd[n], "/%s", aDbName[i]); | |
| 946 | + if( file_access(zPwd, W_OK) ) continue; | |
| 947 | 947 | if( isValidLocalDb(zPwd) ){ |
| 948 | 948 | /* Found a valid checkout database file */ |
| 949 | 949 | zPwd[n] = 0; |
| 950 | 950 | while( n>1 && zPwd[n-1]=='/' ){ |
| 951 | 951 | n--; |
| @@ -1628,19 +1628,19 @@ | ||
| 1628 | 1628 | ** Return true if the string zVal represents "true" (or "false"). |
| 1629 | 1629 | */ |
| 1630 | 1630 | int is_truth(const char *zVal){ |
| 1631 | 1631 | static const char *const azOn[] = { "on", "yes", "true", "1" }; |
| 1632 | 1632 | int i; |
| 1633 | - for(i=0; i<sizeof(azOn)/sizeof(azOn[0]); i++){ | |
| 1633 | + for(i=0; i<count(azOn); i++){ | |
| 1634 | 1634 | if( fossil_stricmp(zVal,azOn[i])==0 ) return 1; |
| 1635 | 1635 | } |
| 1636 | 1636 | return 0; |
| 1637 | 1637 | } |
| 1638 | 1638 | int is_false(const char *zVal){ |
| 1639 | 1639 | static const char *const azOff[] = { "off", "no", "false", "0" }; |
| 1640 | 1640 | int i; |
| 1641 | - for(i=0; i<sizeof(azOff)/sizeof(azOff[0]); i++){ | |
| 1641 | + for(i=0; i<count(azOff); i++){ | |
| 1642 | 1642 | if( fossil_stricmp(zVal,azOff[i])==0 ) return 1; |
| 1643 | 1643 | } |
| 1644 | 1644 | return 0; |
| 1645 | 1645 | } |
| 1646 | 1646 | |
| 1647 | 1647 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -221,11 +221,11 @@ | |
| 221 | ** rolls back rather than commit. It is the responsibility of the |
| 222 | ** hooks themselves to issue any error messages. |
| 223 | */ |
| 224 | void db_commit_hook(int (*x)(void), int sequence){ |
| 225 | int i; |
| 226 | assert( db.nCommitHook < sizeof(db.aHook)/sizeof(db.aHook[1]) ); |
| 227 | for(i=0; i<db.nCommitHook; i++){ |
| 228 | assert( x!=db.aHook[i].xHook ); |
| 229 | if( db.aHook[i].sequence>sequence ){ |
| 230 | int s = sequence; |
| 231 | int (*xS)(void) = x; |
| @@ -920,32 +920,32 @@ | |
| 920 | ** that contains a valid repository database. |
| 921 | ** |
| 922 | ** For legacy, also look for ".fos". The use of ".fos" is deprecated |
| 923 | ** since "fos" has negative connotations in Hungarian, we are told. |
| 924 | ** |
| 925 | ** If no valid _FOSSIL_ or .fos file is found, we move up one level and |
| 926 | ** try again. Once the file is found, the g.zLocalRoot variable is set |
| 927 | ** to the root of the repository tree and this routine returns 1. If |
| 928 | ** no database is found, then this routine return 0. |
| 929 | ** |
| 930 | ** This routine always opens the user database regardless of whether or |
| 931 | ** not the repository database is found. If the _FOSSIL_ or .fos file |
| 932 | ** is found, it is attached to the open database connection too. |
| 933 | */ |
| 934 | int db_open_local(void){ |
| 935 | int i, n; |
| 936 | char zPwd[2000]; |
| 937 | static const char *const aDbName[] = { "/_FOSSIL_", "/.fslckout", "/.fos" }; |
| 938 | |
| 939 | if( g.localOpen) return 1; |
| 940 | file_getcwd(zPwd, sizeof(zPwd)-20); |
| 941 | n = strlen(zPwd); |
| 942 | if( n==1 && zPwd[0]=='/' ) zPwd[0] = '.'; |
| 943 | while( n>0 ){ |
| 944 | if( file_access(zPwd, W_OK) ) break; |
| 945 | for(i=0; i<sizeof(aDbName)/sizeof(aDbName[0]); i++){ |
| 946 | sqlite3_snprintf(sizeof(zPwd)-n, &zPwd[n], "%s", aDbName[i]); |
| 947 | if( isValidLocalDb(zPwd) ){ |
| 948 | /* Found a valid checkout database file */ |
| 949 | zPwd[n] = 0; |
| 950 | while( n>1 && zPwd[n-1]=='/' ){ |
| 951 | n--; |
| @@ -1628,19 +1628,19 @@ | |
| 1628 | ** Return true if the string zVal represents "true" (or "false"). |
| 1629 | */ |
| 1630 | int is_truth(const char *zVal){ |
| 1631 | static const char *const azOn[] = { "on", "yes", "true", "1" }; |
| 1632 | int i; |
| 1633 | for(i=0; i<sizeof(azOn)/sizeof(azOn[0]); i++){ |
| 1634 | if( fossil_stricmp(zVal,azOn[i])==0 ) return 1; |
| 1635 | } |
| 1636 | return 0; |
| 1637 | } |
| 1638 | int is_false(const char *zVal){ |
| 1639 | static const char *const azOff[] = { "off", "no", "false", "0" }; |
| 1640 | int i; |
| 1641 | for(i=0; i<sizeof(azOff)/sizeof(azOff[0]); i++){ |
| 1642 | if( fossil_stricmp(zVal,azOff[i])==0 ) return 1; |
| 1643 | } |
| 1644 | return 0; |
| 1645 | } |
| 1646 | |
| 1647 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -221,11 +221,11 @@ | |
| 221 | ** rolls back rather than commit. It is the responsibility of the |
| 222 | ** hooks themselves to issue any error messages. |
| 223 | */ |
| 224 | void db_commit_hook(int (*x)(void), int sequence){ |
| 225 | int i; |
| 226 | assert( db.nCommitHook < count(db.aHook) ); |
| 227 | for(i=0; i<db.nCommitHook; i++){ |
| 228 | assert( x!=db.aHook[i].xHook ); |
| 229 | if( db.aHook[i].sequence>sequence ){ |
| 230 | int s = sequence; |
| 231 | int (*xS)(void) = x; |
| @@ -920,32 +920,32 @@ | |
| 920 | ** that contains a valid repository database. |
| 921 | ** |
| 922 | ** For legacy, also look for ".fos". The use of ".fos" is deprecated |
| 923 | ** since "fos" has negative connotations in Hungarian, we are told. |
| 924 | ** |
| 925 | ** If no valid _FOSSIL_ or .fslckout file is found, we move up one level and |
| 926 | ** try again. Once the file is found, the g.zLocalRoot variable is set |
| 927 | ** to the root of the repository tree and this routine returns 1. If |
| 928 | ** no database is found, then this routine return 0. |
| 929 | ** |
| 930 | ** This routine always opens the user database regardless of whether or |
| 931 | ** not the repository database is found. If the _FOSSIL_ or .fslckout file |
| 932 | ** is found, it is attached to the open database connection too. |
| 933 | */ |
| 934 | int db_open_local(void){ |
| 935 | int i, n; |
| 936 | char zPwd[2000]; |
| 937 | static const char aDbName[][10] = { "_FOSSIL_", ".fslckout", ".fos" }; |
| 938 | |
| 939 | if( g.localOpen) return 1; |
| 940 | file_getcwd(zPwd, sizeof(zPwd)-20); |
| 941 | n = strlen(zPwd); |
| 942 | if( n==1 && zPwd[0]=='/' ) zPwd[0] = '.'; |
| 943 | while( n>0 ){ |
| 944 | for(i=0; i<count(aDbName); i++){ |
| 945 | sqlite3_snprintf(sizeof(zPwd)-n, &zPwd[n], "/%s", aDbName[i]); |
| 946 | if( file_access(zPwd, W_OK) ) continue; |
| 947 | if( isValidLocalDb(zPwd) ){ |
| 948 | /* Found a valid checkout database file */ |
| 949 | zPwd[n] = 0; |
| 950 | while( n>1 && zPwd[n-1]=='/' ){ |
| 951 | n--; |
| @@ -1628,19 +1628,19 @@ | |
| 1628 | ** Return true if the string zVal represents "true" (or "false"). |
| 1629 | */ |
| 1630 | int is_truth(const char *zVal){ |
| 1631 | static const char *const azOn[] = { "on", "yes", "true", "1" }; |
| 1632 | int i; |
| 1633 | for(i=0; i<count(azOn); i++){ |
| 1634 | if( fossil_stricmp(zVal,azOn[i])==0 ) return 1; |
| 1635 | } |
| 1636 | return 0; |
| 1637 | } |
| 1638 | int is_false(const char *zVal){ |
| 1639 | static const char *const azOff[] = { "off", "no", "false", "0" }; |
| 1640 | int i; |
| 1641 | for(i=0; i<count(azOff); i++){ |
| 1642 | if( fossil_stricmp(zVal,azOff[i])==0 ) return 1; |
| 1643 | } |
| 1644 | return 0; |
| 1645 | } |
| 1646 | |
| 1647 |