Fossil

Check-in [41820798]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add the "unset" command for clearing settings.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 418207989a55779c3226021079c046f8f296919b
User & Date: drh 2008-05-10 17:22:07
Context
2008-05-10
18:01
Help message cleanup. Automatically delete cloned database files if the clone fails. check-in: 6b85fd17 user: drh tags: trunk
17:22
Add the "unset" command for clearing settings. check-in: 41820798 user: drh tags: trunk
17:09
Add the --nosync option to temporarily disable autosync. Useful when off network. check-in: 9ba6e428 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/db.c.

939
940
941
942
943
944
945









946
947
948
949
950
951
952
....
1061
1062
1063
1064
1065
1066
1067

1068

1069
1070
1071


1072


1073
1074
1075
1076
1077
1078
1079
....
1108
1109
1110
1111
1112
1113
1114

1115
1116
1117
1118
1119



1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132


1133
1134
1135
1136
1137
1138
1139
1140
  db_begin_transaction();
  db_multi_exec("REPLACE INTO %sconfig(name,value) VALUES(%Q,%Q)",
                 globalFlag ? "global_" : "", zName, zValue);
  if( globalFlag && g.repositoryOpen ){
    db_multi_exec("DELETE FROM config WHERE name=%Q", zName);
  }
  db_end_transaction(0);









}
int db_is_global(const char *zName){
  if( g.configOpen ){
    return db_exists("SELECT 1 FROM global_config WHERE name=%Q", zName);
  }else{
    return 0;
  }
................................................................................
  }
  db_finalize(&q);
}


/*
** COMMAND: settings

** %fossil setting ?PROPERTY? ?VALUE? ?-global?

**
** With no arguments, list all properties and their values.  With just
** a property name, show the value of that property.  With a value


** argument, change the property for the current repository.


**
**    autosync         If enabled, automatically pull prior to
**                     commit or update and automatically push
**                     after commit or tag or branch creation.
**
**    pgp-command      Command used to clear-sign manifests at check-in.
**                     The default is "gpg --clearsign -o ".
................................................................................
    "omitsign",
    "proxy",
    "diff-command",
    "gdiff-command",
  };
  int i;
  int globalFlag = find_option("global","g",0)!=0;

  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]);
    }
  }else if( g.argc==3 || g.argc==4 ){
    const char *zName = g.argv[2];
    int n = strlen(zName);
    for(i=0; i<sizeof(azName)/sizeof(azName[0]); i++){
      if( strncmp(azName[i], zName, n)==0 ) break;
    }
    if( i>=sizeof(azName)/sizeof(azName[0]) ){
      fossil_fatal("no such setting: %s", zName);
    }


    if( g.argc==4 ){
      db_set(azName[i], g.argv[3], globalFlag);
    }else{
      print_setting(azName[i]);
    }
  }else{
    usage("?PROPERTY? ?VALUE?");
  }







>
>
>
>
>
>
>
>
>







 







>

>

<
<
>
>
|
>
>







 







>





>
>
>













>
>
|







939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
....
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080


1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
....
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
  db_begin_transaction();
  db_multi_exec("REPLACE INTO %sconfig(name,value) VALUES(%Q,%Q)",
                 globalFlag ? "global_" : "", zName, zValue);
  if( globalFlag && g.repositoryOpen ){
    db_multi_exec("DELETE FROM config WHERE name=%Q", zName);
  }
  db_end_transaction(0);
}
void db_unset(const char *zName, int globalFlag){
  db_begin_transaction();
  db_multi_exec("DELETE FROM %sconfig WHERE name=%Q",
                 globalFlag ? "global_" : "", zName);
  if( globalFlag && g.repositoryOpen ){
    db_multi_exec("DELETE FROM config WHERE name=%Q", zName);
  }
  db_end_transaction(0);
}
int db_is_global(const char *zName){
  if( g.configOpen ){
    return db_exists("SELECT 1 FROM global_config WHERE name=%Q", zName);
  }else{
    return 0;
  }
................................................................................
  }
  db_finalize(&q);
}


/*
** COMMAND: settings
** COMMAND: unset
** %fossil setting ?PROPERTY? ?VALUE? ?-global?
** %fossil unset PROPERTY ?-global?
**


** The "setting" command with no arguments lists all properties and their
** values.  With just a property name it shows the value of that property.
** With a value argument it changes the property for the current repository.
**
** The "unset" command clears a property setting.
**
**    autosync         If enabled, automatically pull prior to
**                     commit or update and automatically push
**                     after commit or tag or branch creation.
**
**    pgp-command      Command used to clear-sign manifests at check-in.
**                     The default is "gpg --clearsign -o ".
................................................................................
    "omitsign",
    "proxy",
    "diff-command",
    "gdiff-command",
  };
  int i;
  int globalFlag = find_option("global","g",0)!=0;
  int unsetFlag = g.argv[1][0]=='u';
  db_find_and_open_repository(0);
  if( !g.repositoryOpen ){
    db_open_config();
    globalFlag = 1;
  }
  if( unsetFlag && g.argc!=3 ){
    usage("PROPERTY ?-global?");
  }
  if( g.argc==2 ){
    for(i=0; i<sizeof(azName)/sizeof(azName[0]); i++){
      print_setting(azName[i]);
    }
  }else if( g.argc==3 || g.argc==4 ){
    const char *zName = g.argv[2];
    int n = strlen(zName);
    for(i=0; i<sizeof(azName)/sizeof(azName[0]); i++){
      if( strncmp(azName[i], zName, n)==0 ) break;
    }
    if( i>=sizeof(azName)/sizeof(azName[0]) ){
      fossil_fatal("no such setting: %s", zName);
    }
    if( unsetFlag ){
      db_unset(azName[i], globalFlag);
    }else if( g.argc==4 ){
      db_set(azName[i], g.argv[3], globalFlag);
    }else{
      print_setting(azName[i]);
    }
  }else{
    usage("?PROPERTY? ?VALUE?");
  }