Fossil SCM

Treat the --repository (-R) option specially, caching its value in the global state. This is only strictly necessary when TH1 hooks are enabled at compile-time.

mistachkin 2014-06-15 23:54 trunk
Commit 912fce2be831d130a9194c16af8ea3ded766a120
3 files changed +1 -1 +15 +1 -1
+1 -1
--- src/db.c
+++ src/db.c
@@ -1069,11 +1069,11 @@
10691069
** use the repository of the open checkout if there is one.
10701070
**
10711071
** Error out if the repository cannot be opened.
10721072
*/
10731073
void db_find_and_open_repository(int bFlags, int nArgUsed){
1074
- const char *zRep = find_option("repository", "R", 1);
1074
+ const char *zRep = find_repository_option();
10751075
if( zRep==0 && nArgUsed && g.argc==nArgUsed+1 ){
10761076
zRep = g.argv[nArgUsed];
10771077
}
10781078
if( zRep==0 ){
10791079
if( db_open_local(0)==0 ){
10801080
--- src/db.c
+++ src/db.c
@@ -1069,11 +1069,11 @@
1069 ** use the repository of the open checkout if there is one.
1070 **
1071 ** Error out if the repository cannot be opened.
1072 */
1073 void db_find_and_open_repository(int bFlags, int nArgUsed){
1074 const char *zRep = find_option("repository", "R", 1);
1075 if( zRep==0 && nArgUsed && g.argc==nArgUsed+1 ){
1076 zRep = g.argv[nArgUsed];
1077 }
1078 if( zRep==0 ){
1079 if( db_open_local(0)==0 ){
1080
--- src/db.c
+++ src/db.c
@@ -1069,11 +1069,11 @@
1069 ** use the repository of the open checkout if there is one.
1070 **
1071 ** Error out if the repository cannot be opened.
1072 */
1073 void db_find_and_open_repository(int bFlags, int nArgUsed){
1074 const char *zRep = find_repository_option();
1075 if( zRep==0 && nArgUsed && g.argc==nArgUsed+1 ){
1076 zRep = g.argv[nArgUsed];
1077 }
1078 if( zRep==0 ){
1079 if( db_open_local(0)==0 ){
1080
+15
--- src/main.c
+++ src/main.c
@@ -124,10 +124,11 @@
124124
sqlite3 *dbConfig; /* Separate connection for global_config table */
125125
int useAttach; /* True if global_config is attached to repository */
126126
const char *zConfigDbName;/* Path of the config database. NULL if not open */
127127
sqlite3_int64 now; /* Seconds since 1970 */
128128
int repositoryOpen; /* True if the main repository database is open */
129
+ char *zRepositoryOption; /* Most recent cached repository option value */
129130
char *zRepositoryName; /* Name of the repository database */
130131
const char *zMainDbType;/* "configdb", "localdb", or "repository" */
131132
const char *zConfigDbType; /* "configdb", "localdb", or "repository" */
132133
int localOpen; /* True if the local database is open */
133134
char *zLocalRoot; /* The directory holding the local database */
@@ -796,10 +797,24 @@
796797
break;
797798
}
798799
}
799800
return zReturn;
800801
}
802
+
803
+/*
804
+** Look for a repository command-line option. If present, [re-]cache it in
805
+** the global state and return the new pointer, freeing any previous value.
806
+** If absent and there is no cached value, return NULL.
807
+*/
808
+const char *find_repository_option(){
809
+ const char *zRepository = find_option("repository", "R", 1);
810
+ if( zRepository ){
811
+ if( g.zRepositoryOption ) fossil_free(g.zRepositoryOption);
812
+ g.zRepositoryOption = mprintf("%s", zRepository);
813
+ }
814
+ return g.zRepositoryOption;
815
+}
801816
802817
/*
803818
** Verify that there are no unprocessed command-line options. If
804819
** Any remaining command-line argument begins with "-" print
805820
** an error message and quit.
806821
--- src/main.c
+++ src/main.c
@@ -124,10 +124,11 @@
124 sqlite3 *dbConfig; /* Separate connection for global_config table */
125 int useAttach; /* True if global_config is attached to repository */
126 const char *zConfigDbName;/* Path of the config database. NULL if not open */
127 sqlite3_int64 now; /* Seconds since 1970 */
128 int repositoryOpen; /* True if the main repository database is open */
 
129 char *zRepositoryName; /* Name of the repository database */
130 const char *zMainDbType;/* "configdb", "localdb", or "repository" */
131 const char *zConfigDbType; /* "configdb", "localdb", or "repository" */
132 int localOpen; /* True if the local database is open */
133 char *zLocalRoot; /* The directory holding the local database */
@@ -796,10 +797,24 @@
796 break;
797 }
798 }
799 return zReturn;
800 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
801
802 /*
803 ** Verify that there are no unprocessed command-line options. If
804 ** Any remaining command-line argument begins with "-" print
805 ** an error message and quit.
806
--- src/main.c
+++ src/main.c
@@ -124,10 +124,11 @@
124 sqlite3 *dbConfig; /* Separate connection for global_config table */
125 int useAttach; /* True if global_config is attached to repository */
126 const char *zConfigDbName;/* Path of the config database. NULL if not open */
127 sqlite3_int64 now; /* Seconds since 1970 */
128 int repositoryOpen; /* True if the main repository database is open */
129 char *zRepositoryOption; /* Most recent cached repository option value */
130 char *zRepositoryName; /* Name of the repository database */
131 const char *zMainDbType;/* "configdb", "localdb", or "repository" */
132 const char *zConfigDbType; /* "configdb", "localdb", or "repository" */
133 int localOpen; /* True if the local database is open */
134 char *zLocalRoot; /* The directory holding the local database */
@@ -796,10 +797,24 @@
797 break;
798 }
799 }
800 return zReturn;
801 }
802
803 /*
804 ** Look for a repository command-line option. If present, [re-]cache it in
805 ** the global state and return the new pointer, freeing any previous value.
806 ** If absent and there is no cached value, return NULL.
807 */
808 const char *find_repository_option(){
809 const char *zRepository = find_option("repository", "R", 1);
810 if( zRepository ){
811 if( g.zRepositoryOption ) fossil_free(g.zRepositoryOption);
812 g.zRepositoryOption = mprintf("%s", zRepository);
813 }
814 return g.zRepositoryOption;
815 }
816
817 /*
818 ** Verify that there are no unprocessed command-line options. If
819 ** Any remaining command-line argument begins with "-" print
820 ** an error message and quit.
821
+1 -1
--- src/winhttp.c
+++ src/winhttp.c
@@ -674,11 +674,11 @@
674674
const char *zPassword = find_option("password", "W", 1);
675675
const char *zPort = find_option("port", "P", 1);
676676
const char *zNotFound = find_option("notfound", 0, 1);
677677
const char *zFileGlob = find_option("files", 0, 1);
678678
const char *zLocalAuth = find_option("localauth", 0, 0);
679
- const char *zRepository = find_option("repository", "R", 1);
679
+ const char *zRepository = find_repository_option();
680680
int useSCGI = find_option("scgi", 0, 0)!=0;
681681
Blob binPath;
682682
683683
verify_all_options();
684684
if( g.argc==4 ){
685685
--- src/winhttp.c
+++ src/winhttp.c
@@ -674,11 +674,11 @@
674 const char *zPassword = find_option("password", "W", 1);
675 const char *zPort = find_option("port", "P", 1);
676 const char *zNotFound = find_option("notfound", 0, 1);
677 const char *zFileGlob = find_option("files", 0, 1);
678 const char *zLocalAuth = find_option("localauth", 0, 0);
679 const char *zRepository = find_option("repository", "R", 1);
680 int useSCGI = find_option("scgi", 0, 0)!=0;
681 Blob binPath;
682
683 verify_all_options();
684 if( g.argc==4 ){
685
--- src/winhttp.c
+++ src/winhttp.c
@@ -674,11 +674,11 @@
674 const char *zPassword = find_option("password", "W", 1);
675 const char *zPort = find_option("port", "P", 1);
676 const char *zNotFound = find_option("notfound", 0, 1);
677 const char *zFileGlob = find_option("files", 0, 1);
678 const char *zLocalAuth = find_option("localauth", 0, 0);
679 const char *zRepository = find_repository_option();
680 int useSCGI = find_option("scgi", 0, 0)!=0;
681 Blob binPath;
682
683 verify_all_options();
684 if( g.argc==4 ){
685

Keyboard Shortcuts

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