Fossil SCM

Allow the "fossil ui" command to specify a directory as long as the "--notfound" option is also used. Give a better error message if these conditions are not met.

drh 2012-11-14 17:39 trunk
Commit 4e368da19cf34e88960fac5dd4225daab1694c1a
1 file changed +9 -5
+9 -5
--- src/main.c
+++ src/main.c
@@ -1754,13 +1754,17 @@
17541754
** is disallowed.
17551755
*/
17561756
static void find_server_repository(int disallowDir){
17571757
if( g.argc<3 ){
17581758
db_must_be_within_tree();
1759
- }else if( !disallowDir && file_isdir(g.argv[2])==1 ){
1760
- g.zRepositoryName = mprintf("%s", g.argv[2]);
1761
- file_simplify_name(g.zRepositoryName, -1, 0);
1759
+ }else if( file_isdir(g.argv[2])==1 ){
1760
+ if( disallowDir ){
1761
+ fossil_fatal("\"%s\" is a directory, not a repository file", g.argv[2]);
1762
+ }else{
1763
+ g.zRepositoryName = mprintf("%s", g.argv[2]);
1764
+ file_simplify_name(g.zRepositoryName, -1, 0);
1765
+ }
17621766
}else{
17631767
db_open_repository(g.argv[2]);
17641768
}
17651769
}
17661770
@@ -1948,11 +1952,11 @@
19481952
isUiCmd = g.argv[1][0]=='u';
19491953
if( isUiCmd ){
19501954
flags |= HTTP_SERVER_LOCALHOST;
19511955
g.useLocalauth = 1;
19521956
}
1953
- find_server_repository(isUiCmd);
1957
+ find_server_repository(isUiCmd && zNotFound==0);
19541958
if( zPort ){
19551959
iPort = mxPort = atoi(zPort);
19561960
}else{
19571961
iPort = db_get_int("http-port", 8080);
19581962
mxPort = iPort+100;
@@ -1987,11 +1991,11 @@
19871991
g.httpOut = stdout;
19881992
if( g.fHttpTrace || g.fSqlTrace ){
19891993
fprintf(stderr, "====== SERVER pid %d =======\n", getpid());
19901994
}
19911995
g.cgiOutput = 1;
1992
- find_server_repository(isUiCmd);
1996
+ find_server_repository(isUiCmd && zNotFound==0);
19931997
g.zRepositoryName = enter_chroot_jail(g.zRepositoryName);
19941998
cgi_handle_http_request(0);
19951999
process_one_web_page(zNotFound);
19962000
#else
19972001
/* Win32 implementation */
19982002
--- src/main.c
+++ src/main.c
@@ -1754,13 +1754,17 @@
1754 ** is disallowed.
1755 */
1756 static void find_server_repository(int disallowDir){
1757 if( g.argc<3 ){
1758 db_must_be_within_tree();
1759 }else if( !disallowDir && file_isdir(g.argv[2])==1 ){
1760 g.zRepositoryName = mprintf("%s", g.argv[2]);
1761 file_simplify_name(g.zRepositoryName, -1, 0);
 
 
 
 
1762 }else{
1763 db_open_repository(g.argv[2]);
1764 }
1765 }
1766
@@ -1948,11 +1952,11 @@
1948 isUiCmd = g.argv[1][0]=='u';
1949 if( isUiCmd ){
1950 flags |= HTTP_SERVER_LOCALHOST;
1951 g.useLocalauth = 1;
1952 }
1953 find_server_repository(isUiCmd);
1954 if( zPort ){
1955 iPort = mxPort = atoi(zPort);
1956 }else{
1957 iPort = db_get_int("http-port", 8080);
1958 mxPort = iPort+100;
@@ -1987,11 +1991,11 @@
1987 g.httpOut = stdout;
1988 if( g.fHttpTrace || g.fSqlTrace ){
1989 fprintf(stderr, "====== SERVER pid %d =======\n", getpid());
1990 }
1991 g.cgiOutput = 1;
1992 find_server_repository(isUiCmd);
1993 g.zRepositoryName = enter_chroot_jail(g.zRepositoryName);
1994 cgi_handle_http_request(0);
1995 process_one_web_page(zNotFound);
1996 #else
1997 /* Win32 implementation */
1998
--- src/main.c
+++ src/main.c
@@ -1754,13 +1754,17 @@
1754 ** is disallowed.
1755 */
1756 static void find_server_repository(int disallowDir){
1757 if( g.argc<3 ){
1758 db_must_be_within_tree();
1759 }else if( file_isdir(g.argv[2])==1 ){
1760 if( disallowDir ){
1761 fossil_fatal("\"%s\" is a directory, not a repository file", g.argv[2]);
1762 }else{
1763 g.zRepositoryName = mprintf("%s", g.argv[2]);
1764 file_simplify_name(g.zRepositoryName, -1, 0);
1765 }
1766 }else{
1767 db_open_repository(g.argv[2]);
1768 }
1769 }
1770
@@ -1948,11 +1952,11 @@
1952 isUiCmd = g.argv[1][0]=='u';
1953 if( isUiCmd ){
1954 flags |= HTTP_SERVER_LOCALHOST;
1955 g.useLocalauth = 1;
1956 }
1957 find_server_repository(isUiCmd && zNotFound==0);
1958 if( zPort ){
1959 iPort = mxPort = atoi(zPort);
1960 }else{
1961 iPort = db_get_int("http-port", 8080);
1962 mxPort = iPort+100;
@@ -1987,11 +1991,11 @@
1991 g.httpOut = stdout;
1992 if( g.fHttpTrace || g.fSqlTrace ){
1993 fprintf(stderr, "====== SERVER pid %d =======\n", getpid());
1994 }
1995 g.cgiOutput = 1;
1996 find_server_repository(isUiCmd && zNotFound==0);
1997 g.zRepositoryName = enter_chroot_jail(g.zRepositoryName);
1998 cgi_handle_http_request(0);
1999 process_one_web_page(zNotFound);
2000 #else
2001 /* Win32 implementation */
2002

Keyboard Shortcuts

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