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.
Commit
8bdea95c586383393fc27d89b075a67e38c6c4df
Parent
85670cfcc852fdf…
1 file changed
+22
-18
M
src/db.c
+22
-18
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -28,12 +28,12 @@ | ||
| 28 | 28 | ** |
| 29 | 29 | ** (1) The "user" database in ~/.fossil |
| 30 | 30 | ** |
| 31 | 31 | ** (2) The "repository" database |
| 32 | 32 | ** |
| 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. | |
| 35 | 35 | ** |
| 36 | 36 | */ |
| 37 | 37 | #include "config.h" |
| 38 | 38 | #ifndef __MINGW32__ |
| 39 | 39 | # include <pwd.h> |
| @@ -601,26 +601,28 @@ | ||
| 601 | 601 | return 1; |
| 602 | 602 | } |
| 603 | 603 | |
| 604 | 604 | /* |
| 605 | 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. | |
| 606 | +** directory is found by searching for a file named "_FOSSIL_" or ".fos" | |
| 607 | +** that contains a valid repository database. | |
| 608 | 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. | |
| 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 | 613 | ** |
| 614 | 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. | |
| 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 | 617 | */ |
| 618 | 618 | int db_open_local(void){ |
| 619 | - int n; | |
| 619 | + int i, n; | |
| 620 | 620 | char zPwd[2000]; |
| 621 | 621 | char *zPwdConv; |
| 622 | + static const char *aDbName[] = { "/_FOSSIL_", "/.fos" }; | |
| 623 | + | |
| 622 | 624 | if( g.localOpen) return 1; |
| 623 | 625 | if( getcwd(zPwd, sizeof(zPwd)-20)==0 ){ |
| 624 | 626 | db_err("pwd too big: max %d", sizeof(zPwd)-20); |
| 625 | 627 | } |
| 626 | 628 | n = strlen(zPwd); |
| @@ -627,24 +629,26 @@ | ||
| 627 | 629 | zPwdConv = mprintf("%/", zPwd); |
| 628 | 630 | strncpy(zPwd, zPwdConv, 2000-20); |
| 629 | 631 | free(zPwdConv); |
| 630 | 632 | while( n>0 ){ |
| 631 | 633 | 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 | + } | |
| 638 | 642 | } |
| 639 | 643 | n--; |
| 640 | 644 | while( n>0 && zPwd[n]!='/' ){ n--; } |
| 641 | 645 | while( n>0 && zPwd[n-1]=='/' ){ n--; } |
| 642 | 646 | zPwd[n] = 0; |
| 643 | 647 | } |
| 644 | 648 | |
| 645 | - /* A _FOSSIL_ file could not be found */ | |
| 649 | + /* A checkout database file could not be found */ | |
| 646 | 650 | return 0; |
| 647 | 651 | } |
| 648 | 652 | |
| 649 | 653 | /* |
| 650 | 654 | ** Open the repository database given by zDbName. If zDbName==NULL then |
| 651 | 655 |
| --- 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 |