107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
-
+
+
-
+
|
**
** Options:
** --admin-user|-A USERNAME Make USERNAME the administrator
** --once Don't save url.
** --private Also clone private branches
** --ssl-identity=filename Use the SSL identity if requested by the server
** --ssh-command|-c 'command' Use this SSH command
** --httpauth|-B Add HTTP Basic Authorization to requests
** --httpauth|-B 'user:pass' Add HTTP Basic Authorization to requests
**
** See also: init
*/
void clone_cmd(void){
char *zPassword;
const char *zDefaultUser; /* Optional name of the default user */
const char *zHttpAuth; /* HTTP Authorization user:pass information */
int nErr = 0;
int bPrivate = 0; /* Also clone private branches */
int urlFlags = URL_PROMPT_PW | URL_REMEMBER;
if( find_option("private",0,0)!=0 ) bPrivate = SYNC_PRIVATE;
if( find_option("once",0,0)!=0) urlFlags &= ~URL_REMEMBER;
g.fUseHttpAuth = find_option("httpauth","B",0)!=0;
zHttpAuth = find_option("httpauth","B",1);
zDefaultUser = find_option("admin-user","A",1);
clone_ssh_find_options();
url_proxy_options();
if( g.argc < 4 ){
usage("?OPTIONS? FILE-OR-URL NEW-REPOSITORY");
}
db_open_config(0);
|
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
|
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
-
+
|
db_begin_transaction();
db_record_repository_filename(g.argv[3]);
db_initial_setup(0, 0, zDefaultUser, 0);
user_select();
db_set("content-schema", CONTENT_SCHEMA, 0);
db_set("aux-schema", AUX_SCHEMA, 0);
db_set("rebuilt", get_version(), 0);
remember_or_get_http_auth(urlFlags & URL_REMEMBER, g.argv[2]);
remember_or_get_http_auth(zHttpAuth, urlFlags & URL_REMEMBER, g.argv[2]);
url_remember();
if( g.zSSLIdentity!=0 ){
/* If the --ssl-identity option was specified, store it as a setting */
Blob fn;
blob_zero(&fn);
file_canonical_name(g.zSSLIdentity, &fn, 0);
db_set("ssl-identity", blob_str(&fn), 0);
|
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
|
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
|
-
+
+
+
+
-
-
+
+
-
+
-
+
-
-
+
+
|
/*
** If user chooses to use HTTP Authentication over unencrypted HTTP,
** remember decision. Otherwise, if the URL is being changed and no preference
** has been indicated, err on the safe side and revert the decision.
** Set the global preference if the URL is not being changed.
*/
void remember_or_get_http_auth(int fRemember, const char *zUrl){
void remember_or_get_http_auth(const char *zHttpAuth, int fRemember, const char *zUrl){
if( zHttpAuth && zHttpAuth[0] ){
g.zHttpAuth = mprintf("%s", zHttpAuth);
}
if( fRemember ){
if( g.fUseHttpAuth==1 ){
db_set_int("use-http-auth", 1, 0);
if( g.zHttpAuth && g.zHttpAuth[0] ){
db_set("http-auth", obscure(g.zHttpAuth), 0);
}else if( zUrl && zUrl[0] ){
db_unset("use-http-auth", 0);
db_unset("http-auth", 0);
}else{
g.fUseHttpAuth = db_get_boolean("use-http-auth",0)!=0;
g.zHttpAuth = unobscure(db_get("http-auth",0));
}
}else if( g.fUseHttpAuth==0 && zUrl==0 ){
g.fUseHttpAuth = db_get_boolean("use-http-auth",0)!=0;
}else if( g.zHttpAuth==0 && zUrl==0 ){
g.zHttpAuth = unobscure(db_get("http-auth",0));
}
}
/*
** Look for SSH clone command line options and setup in globals.
*/
void clone_ssh_find_options(void){
|