Fossil SCM

Allow for the creation of "sub-repositories" that can be accessed through the web interface using the same login credentials as the parent repository.

drh 2011-03-28 18:08 UTC trunk
Commit 97d0118794cdb35c2256b3f1be03ed537dd6c7f0
1 file changed +38 -8
+38 -8
--- src/main.c
+++ src/main.c
@@ -968,19 +968,49 @@
968968
fossil_redirect_home();
969969
}else{
970970
zPath = mprintf("%s", zPathInfo);
971971
}
972972
973
- /* Remove the leading "/" at the beginning of the path.
973
+ /* Make g.zPath point to the first element of the path. Make
974
+ ** g.zExtra point to everything past that point.
974975
*/
975
- g.zPath = &zPath[1];
976
- for(i=1; zPath[i] && zPath[i]!='/'; i++){}
977
- if( zPath[i]=='/' ){
978
- zPath[i] = 0;
979
- g.zExtra = &zPath[i+1];
980
- }else{
981
- g.zExtra = 0;
976
+ while(1){
977
+ char *zAltRepo = 0;
978
+ g.zPath = &zPath[1];
979
+ for(i=1; zPath[i] && zPath[i]!='/'; i++){}
980
+ if( zPath[i]=='/' ){
981
+ zPath[i] = 0;
982
+ g.zExtra = &zPath[i+1];
983
+
984
+ /* Look for sub-repositories. A sub-repository is another repository
985
+ ** that accepts the login credentials of the current repository. A
986
+ ** subrepository is identified by a CONFIG table entry "subrepo:NAME"
987
+ ** where NAME is the first component of the path. The value of the
988
+ ** the CONFIG entries is the name of the repository.
989
+ */
990
+ zAltRepo = db_text(0, "SELECT value FROM config WHERE name='subrepo:%q'",
991
+ g.zPath);
992
+ if( zAltRepo ){
993
+ int nHost;
994
+ login_check_credentials();
995
+ if( zAltRepo[0]!='/' ){
996
+ zAltRepo = mprintf("%s/../%z", g.zRepositoryName, zAltRepo);
997
+ file_simplify_name(zAltRepo, -1);
998
+ }
999
+ db_close(1);
1000
+ db_open_repository(zAltRepo);
1001
+ fossil_free(zAltRepo);
1002
+ zPath += i;
1003
+ nHost = g.zTop - g.zBaseURL;
1004
+ g.zBaseURL = mprintf("%z/%s", g.zBaseURL, g.zPath);
1005
+ g.zTop = g.zBaseURL + nHost;
1006
+ continue;
1007
+ }
1008
+ }else{
1009
+ g.zExtra = 0;
1010
+ }
1011
+ break;
9821012
}
9831013
if( g.zExtra ){
9841014
/* CGI parameters get this treatment elsewhere, but places like getfile
9851015
** will use g.zExtra directly.
9861016
*/
9871017
--- src/main.c
+++ src/main.c
@@ -968,19 +968,49 @@
968 fossil_redirect_home();
969 }else{
970 zPath = mprintf("%s", zPathInfo);
971 }
972
973 /* Remove the leading "/" at the beginning of the path.
 
974 */
975 g.zPath = &zPath[1];
976 for(i=1; zPath[i] && zPath[i]!='/'; i++){}
977 if( zPath[i]=='/' ){
978 zPath[i] = 0;
979 g.zExtra = &zPath[i+1];
980 }else{
981 g.zExtra = 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
982 }
983 if( g.zExtra ){
984 /* CGI parameters get this treatment elsewhere, but places like getfile
985 ** will use g.zExtra directly.
986 */
987
--- src/main.c
+++ src/main.c
@@ -968,19 +968,49 @@
968 fossil_redirect_home();
969 }else{
970 zPath = mprintf("%s", zPathInfo);
971 }
972
973 /* Make g.zPath point to the first element of the path. Make
974 ** g.zExtra point to everything past that point.
975 */
976 while(1){
977 char *zAltRepo = 0;
978 g.zPath = &zPath[1];
979 for(i=1; zPath[i] && zPath[i]!='/'; i++){}
980 if( zPath[i]=='/' ){
981 zPath[i] = 0;
982 g.zExtra = &zPath[i+1];
983
984 /* Look for sub-repositories. A sub-repository is another repository
985 ** that accepts the login credentials of the current repository. A
986 ** subrepository is identified by a CONFIG table entry "subrepo:NAME"
987 ** where NAME is the first component of the path. The value of the
988 ** the CONFIG entries is the name of the repository.
989 */
990 zAltRepo = db_text(0, "SELECT value FROM config WHERE name='subrepo:%q'",
991 g.zPath);
992 if( zAltRepo ){
993 int nHost;
994 login_check_credentials();
995 if( zAltRepo[0]!='/' ){
996 zAltRepo = mprintf("%s/../%z", g.zRepositoryName, zAltRepo);
997 file_simplify_name(zAltRepo, -1);
998 }
999 db_close(1);
1000 db_open_repository(zAltRepo);
1001 fossil_free(zAltRepo);
1002 zPath += i;
1003 nHost = g.zTop - g.zBaseURL;
1004 g.zBaseURL = mprintf("%z/%s", g.zBaseURL, g.zPath);
1005 g.zTop = g.zBaseURL + nHost;
1006 continue;
1007 }
1008 }else{
1009 g.zExtra = 0;
1010 }
1011 break;
1012 }
1013 if( g.zExtra ){
1014 /* CGI parameters get this treatment elsewhere, but places like getfile
1015 ** will use g.zExtra directly.
1016 */
1017

Keyboard Shortcuts

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