Diff
Not logged in

Differences From:

File src/db.c part of check-in [676fdd088a] - Enable proxy support using the "fossil setting proxy" command. This check-in is made using a proxy. by drh on 2008-05-01 22:49:57. [view]

To:

File src/db.c part of check-in [4e683ef07b] - Add the ability to modify global settings (such as the proxy setting) even when there are no repositories defined. by drh on 2008-05-05 17:24:38. [view]

@@ -673,9 +673,9 @@
 ** use the repository of the open checkout if there is one.
 **
 ** Error out if the repository cannot be opened.
 */
-void db_find_and_open_repository(void){
+void db_find_and_open_repository(int errIfNotFound){
   const char *zRep = find_option("repository", "R", 1);
   if( zRep==0 ){
     if( db_open_local()==0 ){
       goto rep_not_found;
@@ -689,9 +689,11 @@
   if( g.repositoryOpen ){
     return;
   }
 rep_not_found:
-  fossil_fatal("use --repository or -R to specific the repository database");
+  if( errIfNotFound ){
+    fossil_fatal("use --repository or -R to specific the repository database");
+  }
 }
 
 /*
 ** Open the local database.  If unable, exit with an error.
@@ -1037,14 +1039,21 @@
 ** Print the value of a setting named zName
 */
 static void print_setting(const char *zName){
   Stmt q;
-  db_prepare(&q,
-     "SELECT '(local)', value FROM config WHERE name=%Q"
-     " UNION ALL "
-     "SELECT '(global)', value FROM global_config WHERE name=%Q",
-     zName, zName
-  );
+  if( g.repositoryOpen ){
+    db_prepare(&q,
+       "SELECT '(local)', value FROM config WHERE name=%Q"
+       " UNION ALL "
+       "SELECT '(global)', value FROM global_config WHERE name=%Q",
+       zName, zName
+    );
+  }else{
+    db_prepare(&q,
+      "SELECT '(global)', value FROM global_config WHERE name=%Q",
+      zName
+    );
+  }
   if( db_step(&q)==SQLITE_ROW ){
     printf("%-20s %-8s %s\n", zName, db_column_text(&q, 0),
         db_column_text(&q, 1));
   }else{
@@ -1099,9 +1108,13 @@
     "gdiff-command",
   };
   int i;
   int globalFlag = find_option("global","g",0)!=0;
-  db_find_and_open_repository();
+  db_find_and_open_repository(0);
+  if( !g.repositoryOpen ){
+    db_open_config();
+    globalFlag = 1;
+  }
   if( g.argc==2 ){
     for(i=0; i<sizeof(azName)/sizeof(azName[0]); i++){
       print_setting(azName[i]);
     }