Fossil SCM

Fix db_open_local() fonction so it find the local checkout database on "/". It was working inconsistently depending what was the current directory. ** Even if fossil is not the right tool to version files on the root of the system, I found it very usefull to track what file change on my system Tested on Linux only for now..

mgagnon 2014-01-08 04:42 UTC trunk
Commit be993c47d5dd6d319d6317f917446f6691106d63
1 file changed +13 -4
+13 -4
--- src/db.c
+++ src/db.c
@@ -934,40 +934,49 @@
934934
**
935935
** This routine always opens the user database regardless of whether or
936936
** not the repository database is found. If the _FOSSIL_ or .fslckout file
937937
** is found, it is attached to the open database connection too.
938938
*/
939
+/* #define DBG_CHECKOUT_ON_ROOT_FIX 1 */
939940
int db_open_local(const char *zDbName){
940941
int i, n;
941942
char zPwd[2000];
942943
static const char aDbName[][10] = { "_FOSSIL_", ".fslckout", ".fos" };
943944
944945
if( g.localOpen) return 1;
945946
file_getcwd(zPwd, sizeof(zPwd)-20);
946947
n = strlen(zPwd);
947
- if( n==1 && zPwd[0]=='/' ) zPwd[0] = '.';
948
+#ifdef DBG_CHECKOUT_ON_ROOT_FIX
949
+ fossil_trace("---> DEBUG: zPwd: %s, n: %d\n", zPwd, n);
950
+#endif
948951
while( n>0 ){
949952
for(i=0; i<count(aDbName); i++){
950953
sqlite3_snprintf(sizeof(zPwd)-n, &zPwd[n], "/%s", aDbName[i]);
951954
if( isValidLocalDb(zPwd) ){
952955
/* Found a valid checkout database file */
953956
zPwd[n] = 0;
954
- while( n>1 && zPwd[n-1]=='/' ){
957
+ while( n>0 && zPwd[n-1]=='/' ){
955958
n--;
956959
zPwd[n] = 0;
957960
}
958961
g.zLocalRoot = mprintf("%s/", zPwd);
962
+#ifdef DBG_CHECKOUT_ON_ROOT_FIX
963
+ fossil_trace("---> DEBUG: g.zLocalRoot: %s\n", g.zLocalRoot);
964
+#endif
959965
g.localOpen = 1;
960966
db_open_config(0);
961967
db_open_repository(zDbName);
962968
return 1;
963969
}
964970
}
965971
n--;
966
- while( n>0 && zPwd[n]!='/' ){ n--; }
967
- while( n>0 && zPwd[n-1]=='/' ){ n--; }
972
+ while( n>1 && zPwd[n]!='/' ){ n--; }
973
+ while( n>1 && zPwd[n-1]=='/' ){ n--; }
968974
zPwd[n] = 0;
975
+#ifdef DBG_CHECKOUT_ON_ROOT_FIX
976
+ fossil_trace("---> DEBUG: next zPwd: %s, n: %d\n", zPwd, n);
977
+#endif
969978
}
970979
971980
/* A checkout database file could not be found */
972981
return 0;
973982
}
974983
--- src/db.c
+++ src/db.c
@@ -934,40 +934,49 @@
934 **
935 ** This routine always opens the user database regardless of whether or
936 ** not the repository database is found. If the _FOSSIL_ or .fslckout file
937 ** is found, it is attached to the open database connection too.
938 */
 
939 int db_open_local(const char *zDbName){
940 int i, n;
941 char zPwd[2000];
942 static const char aDbName[][10] = { "_FOSSIL_", ".fslckout", ".fos" };
943
944 if( g.localOpen) return 1;
945 file_getcwd(zPwd, sizeof(zPwd)-20);
946 n = strlen(zPwd);
947 if( n==1 && zPwd[0]=='/' ) zPwd[0] = '.';
 
 
948 while( n>0 ){
949 for(i=0; i<count(aDbName); i++){
950 sqlite3_snprintf(sizeof(zPwd)-n, &zPwd[n], "/%s", aDbName[i]);
951 if( isValidLocalDb(zPwd) ){
952 /* Found a valid checkout database file */
953 zPwd[n] = 0;
954 while( n>1 && zPwd[n-1]=='/' ){
955 n--;
956 zPwd[n] = 0;
957 }
958 g.zLocalRoot = mprintf("%s/", zPwd);
 
 
 
959 g.localOpen = 1;
960 db_open_config(0);
961 db_open_repository(zDbName);
962 return 1;
963 }
964 }
965 n--;
966 while( n>0 && zPwd[n]!='/' ){ n--; }
967 while( n>0 && zPwd[n-1]=='/' ){ n--; }
968 zPwd[n] = 0;
 
 
 
969 }
970
971 /* A checkout database file could not be found */
972 return 0;
973 }
974
--- src/db.c
+++ src/db.c
@@ -934,40 +934,49 @@
934 **
935 ** This routine always opens the user database regardless of whether or
936 ** not the repository database is found. If the _FOSSIL_ or .fslckout file
937 ** is found, it is attached to the open database connection too.
938 */
939 /* #define DBG_CHECKOUT_ON_ROOT_FIX 1 */
940 int db_open_local(const char *zDbName){
941 int i, n;
942 char zPwd[2000];
943 static const char aDbName[][10] = { "_FOSSIL_", ".fslckout", ".fos" };
944
945 if( g.localOpen) return 1;
946 file_getcwd(zPwd, sizeof(zPwd)-20);
947 n = strlen(zPwd);
948 #ifdef DBG_CHECKOUT_ON_ROOT_FIX
949 fossil_trace("---> DEBUG: zPwd: %s, n: %d\n", zPwd, n);
950 #endif
951 while( n>0 ){
952 for(i=0; i<count(aDbName); i++){
953 sqlite3_snprintf(sizeof(zPwd)-n, &zPwd[n], "/%s", aDbName[i]);
954 if( isValidLocalDb(zPwd) ){
955 /* Found a valid checkout database file */
956 zPwd[n] = 0;
957 while( n>0 && zPwd[n-1]=='/' ){
958 n--;
959 zPwd[n] = 0;
960 }
961 g.zLocalRoot = mprintf("%s/", zPwd);
962 #ifdef DBG_CHECKOUT_ON_ROOT_FIX
963 fossil_trace("---> DEBUG: g.zLocalRoot: %s\n", g.zLocalRoot);
964 #endif
965 g.localOpen = 1;
966 db_open_config(0);
967 db_open_repository(zDbName);
968 return 1;
969 }
970 }
971 n--;
972 while( n>1 && zPwd[n]!='/' ){ n--; }
973 while( n>1 && zPwd[n-1]=='/' ){ n--; }
974 zPwd[n] = 0;
975 #ifdef DBG_CHECKOUT_ON_ROOT_FIX
976 fossil_trace("---> DEBUG: next zPwd: %s, n: %d\n", zPwd, n);
977 #endif
978 }
979
980 /* A checkout database file could not be found */
981 return 0;
982 }
983

Keyboard Shortcuts

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