Fossil SCM

Allow the "_FOSSIL_" file at the root of each check-out to be renamed ".fos". At some point we might make .fos the default, but for now _FOSSIL_ is the default. The file can be freely changed between these two names.

drh 2008-10-24 11:14 trunk
Commit 8bdea95c586383393fc27d89b075a67e38c6c4df
1 file changed +22 -18
+22 -18
--- src/db.c
+++ src/db.c
@@ -28,12 +28,12 @@
2828
**
2929
** (1) The "user" database in ~/.fossil
3030
**
3131
** (2) The "repository" database
3232
**
33
-** (3) A local checkout database named "FOSSIL" and located at the
34
-** root of the local copy of the source tree.
33
+** (3) A local checkout database named "_FOSSIL_" or ".fos"
34
+** and located at the root of the local copy of the source tree.
3535
**
3636
*/
3737
#include "config.h"
3838
#ifndef __MINGW32__
3939
# include <pwd.h>
@@ -601,26 +601,28 @@
601601
return 1;
602602
}
603603
604604
/*
605605
** Locate the root directory of the local repository tree. The root
606
-** directory is found by searching for a file named "FOSSIL" that contains
607
-** a valid repository database.
606
+** directory is found by searching for a file named "_FOSSIL_" or ".fos"
607
+** that contains a valid repository database.
608608
**
609
-** If no valid FOSSIL file is found, we move up one level and try again.
610
-** Once the file is found, the g.zLocalRoot variable is set to the root of
611
-** the repository tree and this routine returns 1. If no database is
612
-** found, then this routine return 0.
609
+** If no valid _FOSSIL_ or .fos file is found, we move up one level and
610
+** try again. Once the file is found, the g.zLocalRoot variable is set
611
+** to the root of the repository tree and this routine returns 1. If
612
+** no database is found, then this routine return 0.
613613
**
614614
** This routine always opens the user database regardless of whether or
615
-** not the repository database is found. If the FOSSIL file is found,
616
-** it is attached to the open database connection too.
615
+** not the repository database is found. If the _FOSSIL_ or .fos file
616
+** is found, it is attached to the open database connection too.
617617
*/
618618
int db_open_local(void){
619
- int n;
619
+ int i, n;
620620
char zPwd[2000];
621621
char *zPwdConv;
622
+ static const char *aDbName[] = { "/_FOSSIL_", "/.fos" };
623
+
622624
if( g.localOpen) return 1;
623625
if( getcwd(zPwd, sizeof(zPwd)-20)==0 ){
624626
db_err("pwd too big: max %d", sizeof(zPwd)-20);
625627
}
626628
n = strlen(zPwd);
@@ -627,24 +629,26 @@
627629
zPwdConv = mprintf("%/", zPwd);
628630
strncpy(zPwd, zPwdConv, 2000-20);
629631
free(zPwdConv);
630632
while( n>0 ){
631633
if( access(zPwd, W_OK) ) break;
632
- strcpy(&zPwd[n], "/_FOSSIL_");
633
- if( isValidLocalDb(zPwd) ){
634
- /* Found a valid _FOSSIL_ file */
635
- zPwd[n] = 0;
636
- g.zLocalRoot = mprintf("%s/", zPwd);
637
- return 1;
634
+ for(i=0; i<sizeof(aDbName)/sizeof(aDbName[0]); i++){
635
+ strcpy(&zPwd[n], aDbName[i]);
636
+ if( isValidLocalDb(zPwd) ){
637
+ /* Found a valid checkout database file */
638
+ zPwd[n] = 0;
639
+ g.zLocalRoot = mprintf("%s/", zPwd);
640
+ return 1;
641
+ }
638642
}
639643
n--;
640644
while( n>0 && zPwd[n]!='/' ){ n--; }
641645
while( n>0 && zPwd[n-1]=='/' ){ n--; }
642646
zPwd[n] = 0;
643647
}
644648
645
- /* A _FOSSIL_ file could not be found */
649
+ /* A checkout database file could not be found */
646650
return 0;
647651
}
648652
649653
/*
650654
** Open the repository database given by zDbName. If zDbName==NULL then
651655
--- src/db.c
+++ src/db.c
@@ -28,12 +28,12 @@
28 **
29 ** (1) The "user" database in ~/.fossil
30 **
31 ** (2) The "repository" database
32 **
33 ** (3) A local checkout database named "FOSSIL" and located at the
34 ** root of the local copy of the source tree.
35 **
36 */
37 #include "config.h"
38 #ifndef __MINGW32__
39 # include <pwd.h>
@@ -601,26 +601,28 @@
601 return 1;
602 }
603
604 /*
605 ** Locate the root directory of the local repository tree. The root
606 ** directory is found by searching for a file named "FOSSIL" that contains
607 ** a valid repository database.
608 **
609 ** If no valid FOSSIL file is found, we move up one level and try again.
610 ** Once the file is found, the g.zLocalRoot variable is set to the root of
611 ** the repository tree and this routine returns 1. If no database is
612 ** found, then this routine return 0.
613 **
614 ** This routine always opens the user database regardless of whether or
615 ** not the repository database is found. If the FOSSIL file is found,
616 ** it is attached to the open database connection too.
617 */
618 int db_open_local(void){
619 int n;
620 char zPwd[2000];
621 char *zPwdConv;
 
 
622 if( g.localOpen) return 1;
623 if( getcwd(zPwd, sizeof(zPwd)-20)==0 ){
624 db_err("pwd too big: max %d", sizeof(zPwd)-20);
625 }
626 n = strlen(zPwd);
@@ -627,24 +629,26 @@
627 zPwdConv = mprintf("%/", zPwd);
628 strncpy(zPwd, zPwdConv, 2000-20);
629 free(zPwdConv);
630 while( n>0 ){
631 if( access(zPwd, W_OK) ) break;
632 strcpy(&zPwd[n], "/_FOSSIL_");
633 if( isValidLocalDb(zPwd) ){
634 /* Found a valid _FOSSIL_ file */
635 zPwd[n] = 0;
636 g.zLocalRoot = mprintf("%s/", zPwd);
637 return 1;
 
 
638 }
639 n--;
640 while( n>0 && zPwd[n]!='/' ){ n--; }
641 while( n>0 && zPwd[n-1]=='/' ){ n--; }
642 zPwd[n] = 0;
643 }
644
645 /* A _FOSSIL_ file could not be found */
646 return 0;
647 }
648
649 /*
650 ** Open the repository database given by zDbName. If zDbName==NULL then
651
--- src/db.c
+++ src/db.c
@@ -28,12 +28,12 @@
28 **
29 ** (1) The "user" database in ~/.fossil
30 **
31 ** (2) The "repository" database
32 **
33 ** (3) A local checkout database named "_FOSSIL_" or ".fos"
34 ** and located at the root of the local copy of the source tree.
35 **
36 */
37 #include "config.h"
38 #ifndef __MINGW32__
39 # include <pwd.h>
@@ -601,26 +601,28 @@
601 return 1;
602 }
603
604 /*
605 ** Locate the root directory of the local repository tree. The root
606 ** directory is found by searching for a file named "_FOSSIL_" or ".fos"
607 ** that contains a valid repository database.
608 **
609 ** If no valid _FOSSIL_ or .fos file is found, we move up one level and
610 ** try again. Once the file is found, the g.zLocalRoot variable is set
611 ** to the root of the repository tree and this routine returns 1. If
612 ** no database is found, then this routine return 0.
613 **
614 ** This routine always opens the user database regardless of whether or
615 ** not the repository database is found. If the _FOSSIL_ or .fos file
616 ** is found, it is attached to the open database connection too.
617 */
618 int db_open_local(void){
619 int i, n;
620 char zPwd[2000];
621 char *zPwdConv;
622 static const char *aDbName[] = { "/_FOSSIL_", "/.fos" };
623
624 if( g.localOpen) return 1;
625 if( getcwd(zPwd, sizeof(zPwd)-20)==0 ){
626 db_err("pwd too big: max %d", sizeof(zPwd)-20);
627 }
628 n = strlen(zPwd);
@@ -627,24 +629,26 @@
629 zPwdConv = mprintf("%/", zPwd);
630 strncpy(zPwd, zPwdConv, 2000-20);
631 free(zPwdConv);
632 while( n>0 ){
633 if( access(zPwd, W_OK) ) break;
634 for(i=0; i<sizeof(aDbName)/sizeof(aDbName[0]); i++){
635 strcpy(&zPwd[n], aDbName[i]);
636 if( isValidLocalDb(zPwd) ){
637 /* Found a valid checkout database file */
638 zPwd[n] = 0;
639 g.zLocalRoot = mprintf("%s/", zPwd);
640 return 1;
641 }
642 }
643 n--;
644 while( n>0 && zPwd[n]!='/' ){ n--; }
645 while( n>0 && zPwd[n-1]=='/' ){ n--; }
646 zPwd[n] = 0;
647 }
648
649 /* A checkout database file could not be found */
650 return 0;
651 }
652
653 /*
654 ** Open the repository database given by zDbName. If zDbName==NULL then
655

Keyboard Shortcuts

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