Fossil SCM

Make it possible to override global setting from command line. Improve sync output when test-http is in use.

andybradford 2013-08-10 21:31 ssh-test-http
Commit 3c479fb95bc006a77c5eb62b4c8b04cd2339984b
+8 -4
--- src/clone.c
+++ src/clone.c
@@ -96,11 +96,11 @@
9696
** --private Also clone private branches
9797
** --ssl-identity=filename Use the SSL identity if requested by the server
9898
** --ssh-fossil|-f /fossil Use this path as remote fossil command
9999
** --ssh-command|-c 'command' Use this SSH command
100100
** --ssh-fossil-user|-l user Fossil user to use for SSH if different.
101
-** --ssh-use-http|-h Enable http instead of test-http
101
+** --ssh-use-http|-h on/off Enable http instead of test-http. Default: off
102102
**
103103
** See also: init
104104
*/
105105
void clone_cmd(void){
106106
char *zPassword;
@@ -188,10 +188,11 @@
188188
*/
189189
void clone_ssh_find_options(void){
190190
const char *zSshFossilCmd; /* Path to remote fossil command for SSH */
191191
const char *zSshCmd; /* SSH command string */
192192
const char *zFossilUser; /* Fossil user if login specified for SSH */
193
+ const char *zSshUseHttp; /* Use http or test-http mode for SSH */
193194
194195
zSshFossilCmd = find_option("ssh-fossil","f",1);
195196
if( zSshFossilCmd && zSshFossilCmd[0] ){
196197
g.zSshFossilCmd = mprintf("%s", zSshFossilCmd);
197198
}
@@ -201,11 +202,14 @@
201202
}
202203
zFossilUser = find_option("ssh-fossil-user","l",1);
203204
if( zFossilUser && zFossilUser[0] ){
204205
g.zFossilUser = mprintf("%s", zFossilUser);
205206
}
206
- g.fSshUseHttp = find_option("ssh-use-http","h",0)!=0;
207
+ zSshUseHttp = find_option("ssh-use-http","h",1);
208
+ if( zSshUseHttp && zSshUseHttp[0] ){
209
+ g.zSshUseHttp = mprintf("%s", zSshUseHttp);
210
+ }
207211
}
208212
209213
/*
210214
** Set SSH options discovered in global variables (set from command line
211215
** options).
@@ -218,9 +222,9 @@
218222
db_set("ssh-command", g.zSshCmd, 0);
219223
}
220224
if( g.zFossilUser && g.zFossilUser[0] ){
221225
db_set("ssh-fossil-user", g.zFossilUser, 0);
222226
}
223
- if( g.fSshUseHttp ){
224
- db_set_int("ssh-use-http", 1, 0);
227
+ if( g.zSshUseHttp && g.zSshUseHttp[0] ){
228
+ db_set_int("ssh-use-http", is_truth(g.zSshUseHttp), 0);
225229
}
226230
}
227231
--- src/clone.c
+++ src/clone.c
@@ -96,11 +96,11 @@
96 ** --private Also clone private branches
97 ** --ssl-identity=filename Use the SSL identity if requested by the server
98 ** --ssh-fossil|-f /fossil Use this path as remote fossil command
99 ** --ssh-command|-c 'command' Use this SSH command
100 ** --ssh-fossil-user|-l user Fossil user to use for SSH if different.
101 ** --ssh-use-http|-h Enable http instead of test-http
102 **
103 ** See also: init
104 */
105 void clone_cmd(void){
106 char *zPassword;
@@ -188,10 +188,11 @@
188 */
189 void clone_ssh_find_options(void){
190 const char *zSshFossilCmd; /* Path to remote fossil command for SSH */
191 const char *zSshCmd; /* SSH command string */
192 const char *zFossilUser; /* Fossil user if login specified for SSH */
 
193
194 zSshFossilCmd = find_option("ssh-fossil","f",1);
195 if( zSshFossilCmd && zSshFossilCmd[0] ){
196 g.zSshFossilCmd = mprintf("%s", zSshFossilCmd);
197 }
@@ -201,11 +202,14 @@
201 }
202 zFossilUser = find_option("ssh-fossil-user","l",1);
203 if( zFossilUser && zFossilUser[0] ){
204 g.zFossilUser = mprintf("%s", zFossilUser);
205 }
206 g.fSshUseHttp = find_option("ssh-use-http","h",0)!=0;
 
 
 
207 }
208
209 /*
210 ** Set SSH options discovered in global variables (set from command line
211 ** options).
@@ -218,9 +222,9 @@
218 db_set("ssh-command", g.zSshCmd, 0);
219 }
220 if( g.zFossilUser && g.zFossilUser[0] ){
221 db_set("ssh-fossil-user", g.zFossilUser, 0);
222 }
223 if( g.fSshUseHttp ){
224 db_set_int("ssh-use-http", 1, 0);
225 }
226 }
227
--- src/clone.c
+++ src/clone.c
@@ -96,11 +96,11 @@
96 ** --private Also clone private branches
97 ** --ssl-identity=filename Use the SSL identity if requested by the server
98 ** --ssh-fossil|-f /fossil Use this path as remote fossil command
99 ** --ssh-command|-c 'command' Use this SSH command
100 ** --ssh-fossil-user|-l user Fossil user to use for SSH if different.
101 ** --ssh-use-http|-h on/off Enable http instead of test-http. Default: off
102 **
103 ** See also: init
104 */
105 void clone_cmd(void){
106 char *zPassword;
@@ -188,10 +188,11 @@
188 */
189 void clone_ssh_find_options(void){
190 const char *zSshFossilCmd; /* Path to remote fossil command for SSH */
191 const char *zSshCmd; /* SSH command string */
192 const char *zFossilUser; /* Fossil user if login specified for SSH */
193 const char *zSshUseHttp; /* Use http or test-http mode for SSH */
194
195 zSshFossilCmd = find_option("ssh-fossil","f",1);
196 if( zSshFossilCmd && zSshFossilCmd[0] ){
197 g.zSshFossilCmd = mprintf("%s", zSshFossilCmd);
198 }
@@ -201,11 +202,14 @@
202 }
203 zFossilUser = find_option("ssh-fossil-user","l",1);
204 if( zFossilUser && zFossilUser[0] ){
205 g.zFossilUser = mprintf("%s", zFossilUser);
206 }
207 zSshUseHttp = find_option("ssh-use-http","h",1);
208 if( zSshUseHttp && zSshUseHttp[0] ){
209 g.zSshUseHttp = mprintf("%s", zSshUseHttp);
210 }
211 }
212
213 /*
214 ** Set SSH options discovered in global variables (set from command line
215 ** options).
@@ -218,9 +222,9 @@
222 db_set("ssh-command", g.zSshCmd, 0);
223 }
224 if( g.zFossilUser && g.zFossilUser[0] ){
225 db_set("ssh-fossil-user", g.zFossilUser, 0);
226 }
227 if( g.zSshUseHttp && g.zSshUseHttp[0] ){
228 db_set_int("ssh-use-http", is_truth(g.zSshUseHttp), 0);
229 }
230 }
231
+1 -1
--- src/http.c
+++ src/http.c
@@ -41,11 +41,11 @@
4141
Blob sig; /* The signature field */
4242
4343
zLogin = url_or_fossil_user();
4444
blob_zero(pLogin);
4545
if( zLogin==0 || fossil_strcmp(g.urlUser, "anonymous")==0 ||
46
- ( g.urlIsSsh && url_ssh_use_http()==0 ) ){
46
+ ( g.urlIsSsh && ! url_ssh_use_http() ) ){
4747
return; /* If no login card for users "nobody" and "anonymous" */
4848
}
4949
blob_zero(&nonce);
5050
blob_zero(&pw);
5151
sha1sum_blob(pPayload, &nonce);
5252
--- src/http.c
+++ src/http.c
@@ -41,11 +41,11 @@
41 Blob sig; /* The signature field */
42
43 zLogin = url_or_fossil_user();
44 blob_zero(pLogin);
45 if( zLogin==0 || fossil_strcmp(g.urlUser, "anonymous")==0 ||
46 ( g.urlIsSsh && url_ssh_use_http()==0 ) ){
47 return; /* If no login card for users "nobody" and "anonymous" */
48 }
49 blob_zero(&nonce);
50 blob_zero(&pw);
51 sha1sum_blob(pPayload, &nonce);
52
--- src/http.c
+++ src/http.c
@@ -41,11 +41,11 @@
41 Blob sig; /* The signature field */
42
43 zLogin = url_or_fossil_user();
44 blob_zero(pLogin);
45 if( zLogin==0 || fossil_strcmp(g.urlUser, "anonymous")==0 ||
46 ( g.urlIsSsh && ! url_ssh_use_http() ) ){
47 return; /* If no login card for users "nobody" and "anonymous" */
48 }
49 blob_zero(&nonce);
50 blob_zero(&pw);
51 sha1sum_blob(pPayload, &nonce);
52
+2 -2
--- src/main.c
+++ src/main.c
@@ -134,11 +134,11 @@
134134
int fSqlPrint; /* True if -sqlprint flag is present */
135135
int fQuiet; /* True if -quiet flag is present */
136136
int fHttpTrace; /* Trace outbound HTTP requests */
137137
int fSystemTrace; /* Trace calls to fossil_system(), --systemtrace */
138138
int fSshTrace; /* Trace the SSH setup traffic */
139
- int fSshUseHttp; /* Use http or test-http mode for SSH */
139
+ char *zSshUseHttp; /* Use http or test-http mode for SSH */
140140
char *zSshFossilCmd; /* Path to remoe fossil command for SSH */
141141
char *zSshCmd; /* SSH command string */
142142
char *zFossilUser; /* Fossil user if different from URL user */
143143
int fNoSync; /* Do not do an autosync ever. --nosync */
144144
char *zPath; /* Name of webpage being served */
@@ -582,11 +582,11 @@
582582
g.fQuiet = find_option("quiet", 0, 0)!=0;
583583
g.fSqlTrace = find_option("sqltrace", 0, 0)!=0;
584584
g.fSqlStats = find_option("sqlstats", 0, 0)!=0;
585585
g.fSystemTrace = find_option("systemtrace", 0, 0)!=0;
586586
g.fSshTrace = find_option("sshtrace", 0, 0)!=0;
587
- g.fSshUseHttp = 0;
587
+ g.zSshUseHttp = 0;
588588
g.zSshFossilCmd = 0;
589589
g.zSshCmd = 0;
590590
g.zFossilUser = 0;
591591
if( g.fSqlTrace ) g.fSqlStats = 1;
592592
g.fSqlPrint = find_option("sqlprint", 0, 0)!=0;
593593
--- src/main.c
+++ src/main.c
@@ -134,11 +134,11 @@
134 int fSqlPrint; /* True if -sqlprint flag is present */
135 int fQuiet; /* True if -quiet flag is present */
136 int fHttpTrace; /* Trace outbound HTTP requests */
137 int fSystemTrace; /* Trace calls to fossil_system(), --systemtrace */
138 int fSshTrace; /* Trace the SSH setup traffic */
139 int fSshUseHttp; /* Use http or test-http mode for SSH */
140 char *zSshFossilCmd; /* Path to remoe fossil command for SSH */
141 char *zSshCmd; /* SSH command string */
142 char *zFossilUser; /* Fossil user if different from URL user */
143 int fNoSync; /* Do not do an autosync ever. --nosync */
144 char *zPath; /* Name of webpage being served */
@@ -582,11 +582,11 @@
582 g.fQuiet = find_option("quiet", 0, 0)!=0;
583 g.fSqlTrace = find_option("sqltrace", 0, 0)!=0;
584 g.fSqlStats = find_option("sqlstats", 0, 0)!=0;
585 g.fSystemTrace = find_option("systemtrace", 0, 0)!=0;
586 g.fSshTrace = find_option("sshtrace", 0, 0)!=0;
587 g.fSshUseHttp = 0;
588 g.zSshFossilCmd = 0;
589 g.zSshCmd = 0;
590 g.zFossilUser = 0;
591 if( g.fSqlTrace ) g.fSqlStats = 1;
592 g.fSqlPrint = find_option("sqlprint", 0, 0)!=0;
593
--- src/main.c
+++ src/main.c
@@ -134,11 +134,11 @@
134 int fSqlPrint; /* True if -sqlprint flag is present */
135 int fQuiet; /* True if -quiet flag is present */
136 int fHttpTrace; /* Trace outbound HTTP requests */
137 int fSystemTrace; /* Trace calls to fossil_system(), --systemtrace */
138 int fSshTrace; /* Trace the SSH setup traffic */
139 char *zSshUseHttp; /* Use http or test-http mode for SSH */
140 char *zSshFossilCmd; /* Path to remoe fossil command for SSH */
141 char *zSshCmd; /* SSH command string */
142 char *zFossilUser; /* Fossil user if different from URL user */
143 int fNoSync; /* Do not do an autosync ever. --nosync */
144 char *zPath; /* Name of webpage being served */
@@ -582,11 +582,11 @@
582 g.fQuiet = find_option("quiet", 0, 0)!=0;
583 g.fSqlTrace = find_option("sqltrace", 0, 0)!=0;
584 g.fSqlStats = find_option("sqlstats", 0, 0)!=0;
585 g.fSystemTrace = find_option("systemtrace", 0, 0)!=0;
586 g.fSshTrace = find_option("sshtrace", 0, 0)!=0;
587 g.zSshUseHttp = 0;
588 g.zSshFossilCmd = 0;
589 g.zSshCmd = 0;
590 g.zFossilUser = 0;
591 if( g.fSqlTrace ) g.fSqlStats = 1;
592 g.fSqlPrint = find_option("sqlprint", 0, 0)!=0;
593
+4 -4
--- src/sync.c
+++ src/sync.c
@@ -69,11 +69,11 @@
6969
*/
7070
configSync = CONFIGSET_SHUN;
7171
}
7272
#endif
7373
if( find_option("verbose","v",0)!=0 ) flags |= SYNC_VERBOSE;
74
- is_fossil_user() ?
74
+ is_fossil_user() && url_ssh_use_http() ?
7575
fossil_print("Autosync: (%s) %s\n", g.zFossilUser, g.urlCanonical) :
7676
fossil_print("Autosync: %s\n", g.urlCanonical);
7777
url_enable_proxy("via proxy: ");
7878
rc = client_sync(flags, configSync, 0);
7979
if( rc ) fossil_warning("Autosync failed");
@@ -126,19 +126,19 @@
126126
usage("URL");
127127
}
128128
user_select();
129129
if( g.argc==2 ){
130130
if( ((*pSyncFlags) & (SYNC_PUSH|SYNC_PULL))==(SYNC_PUSH|SYNC_PULL) ){
131
- is_fossil_user() ?
131
+ is_fossil_user() && url_ssh_use_http() ?
132132
fossil_print("Sync with (%s) %s\n", g.zFossilUser, g.urlCanonical) :
133133
fossil_print("Sync with %s\n", g.urlCanonical);
134134
}else if( (*pSyncFlags) & SYNC_PUSH ){
135
- is_fossil_user() ?
135
+ is_fossil_user() && url_ssh_use_http() ?
136136
fossil_print("Push to (%s) %s\n", g.zFossilUser, g.urlCanonical) :
137137
fossil_print("Push to %s\n", g.urlCanonical);
138138
}else if( (*pSyncFlags) & SYNC_PULL ){
139
- is_fossil_user() ?
139
+ is_fossil_user() && url_ssh_use_http() ?
140140
fossil_print("Pull from (%s) %s\n", g.zFossilUser, g.urlCanonical) :
141141
fossil_print("Pull from %s\n", g.urlCanonical);
142142
}
143143
}
144144
url_enable_proxy("via proxy: ");
145145
--- src/sync.c
+++ src/sync.c
@@ -69,11 +69,11 @@
69 */
70 configSync = CONFIGSET_SHUN;
71 }
72 #endif
73 if( find_option("verbose","v",0)!=0 ) flags |= SYNC_VERBOSE;
74 is_fossil_user() ?
75 fossil_print("Autosync: (%s) %s\n", g.zFossilUser, g.urlCanonical) :
76 fossil_print("Autosync: %s\n", g.urlCanonical);
77 url_enable_proxy("via proxy: ");
78 rc = client_sync(flags, configSync, 0);
79 if( rc ) fossil_warning("Autosync failed");
@@ -126,19 +126,19 @@
126 usage("URL");
127 }
128 user_select();
129 if( g.argc==2 ){
130 if( ((*pSyncFlags) & (SYNC_PUSH|SYNC_PULL))==(SYNC_PUSH|SYNC_PULL) ){
131 is_fossil_user() ?
132 fossil_print("Sync with (%s) %s\n", g.zFossilUser, g.urlCanonical) :
133 fossil_print("Sync with %s\n", g.urlCanonical);
134 }else if( (*pSyncFlags) & SYNC_PUSH ){
135 is_fossil_user() ?
136 fossil_print("Push to (%s) %s\n", g.zFossilUser, g.urlCanonical) :
137 fossil_print("Push to %s\n", g.urlCanonical);
138 }else if( (*pSyncFlags) & SYNC_PULL ){
139 is_fossil_user() ?
140 fossil_print("Pull from (%s) %s\n", g.zFossilUser, g.urlCanonical) :
141 fossil_print("Pull from %s\n", g.urlCanonical);
142 }
143 }
144 url_enable_proxy("via proxy: ");
145
--- src/sync.c
+++ src/sync.c
@@ -69,11 +69,11 @@
69 */
70 configSync = CONFIGSET_SHUN;
71 }
72 #endif
73 if( find_option("verbose","v",0)!=0 ) flags |= SYNC_VERBOSE;
74 is_fossil_user() && url_ssh_use_http() ?
75 fossil_print("Autosync: (%s) %s\n", g.zFossilUser, g.urlCanonical) :
76 fossil_print("Autosync: %s\n", g.urlCanonical);
77 url_enable_proxy("via proxy: ");
78 rc = client_sync(flags, configSync, 0);
79 if( rc ) fossil_warning("Autosync failed");
@@ -126,19 +126,19 @@
126 usage("URL");
127 }
128 user_select();
129 if( g.argc==2 ){
130 if( ((*pSyncFlags) & (SYNC_PUSH|SYNC_PULL))==(SYNC_PUSH|SYNC_PULL) ){
131 is_fossil_user() && url_ssh_use_http() ?
132 fossil_print("Sync with (%s) %s\n", g.zFossilUser, g.urlCanonical) :
133 fossil_print("Sync with %s\n", g.urlCanonical);
134 }else if( (*pSyncFlags) & SYNC_PUSH ){
135 is_fossil_user() && url_ssh_use_http() ?
136 fossil_print("Push to (%s) %s\n", g.zFossilUser, g.urlCanonical) :
137 fossil_print("Push to %s\n", g.urlCanonical);
138 }else if( (*pSyncFlags) & SYNC_PULL ){
139 is_fossil_user() && url_ssh_use_http() ?
140 fossil_print("Pull from (%s) %s\n", g.zFossilUser, g.urlCanonical) :
141 fossil_print("Pull from %s\n", g.urlCanonical);
142 }
143 }
144 url_enable_proxy("via proxy: ");
145
+5 -3
--- src/url.c
+++ src/url.c
@@ -412,11 +412,11 @@
412412
/*
413413
** Prompt the user for the password for g.urlUser. Store the result
414414
** in g.urlPasswd.
415415
*/
416416
void url_prompt_for_password(void){
417
- if( g.urlIsFile || ( g.urlIsSsh && url_ssh_use_http()==0 ) ) return;
417
+ if( g.urlIsFile || ( g.urlIsSsh && ! url_ssh_use_http() ) ) return;
418418
if( isatty(fileno(stdin))
419419
&& (g.urlFlags & URL_PROMPT_PW)!=0
420420
&& (g.urlFlags & URL_PROMPTED)==0
421421
){
422422
g.urlFlags |= URL_PROMPTED;
@@ -439,11 +439,12 @@
439439
440440
/*
441441
** Return true if http mode is in use for "ssh://" URL.
442442
*/
443443
int url_ssh_use_http(void){
444
- return db_get_boolean("ssh-use-http", 0) || g.fSshUseHttp;
444
+ return ( g.zSshUseHttp && g.zSshUseHttp[0] ) ? is_truth(g.zSshUseHttp) :
445
+ db_get_boolean("ssh-use-http", 0);
445446
}
446447
447448
/*
448449
** Remember the URL if requested.
449450
*/
@@ -457,12 +458,13 @@
457458
458459
/* Preemptively prompt for a password if a username is given in the
459460
** URL but no password.
460461
*/
461462
void url_get_password_if_needed(void){
462
- if( (g.urlUser && g.urlUser[0])
463
+ const char *zFossilUser = url_or_fossil_user();
464
+ if( ( zFossilUser && zFossilUser[0] )
463465
&& (g.urlPasswd==0 || g.urlPasswd[0]==0)
464466
&& isatty(fileno(stdin))
465467
){
466468
url_prompt_for_password();
467469
}
468470
}
469471
--- src/url.c
+++ src/url.c
@@ -412,11 +412,11 @@
412 /*
413 ** Prompt the user for the password for g.urlUser. Store the result
414 ** in g.urlPasswd.
415 */
416 void url_prompt_for_password(void){
417 if( g.urlIsFile || ( g.urlIsSsh && url_ssh_use_http()==0 ) ) return;
418 if( isatty(fileno(stdin))
419 && (g.urlFlags & URL_PROMPT_PW)!=0
420 && (g.urlFlags & URL_PROMPTED)==0
421 ){
422 g.urlFlags |= URL_PROMPTED;
@@ -439,11 +439,12 @@
439
440 /*
441 ** Return true if http mode is in use for "ssh://" URL.
442 */
443 int url_ssh_use_http(void){
444 return db_get_boolean("ssh-use-http", 0) || g.fSshUseHttp;
 
445 }
446
447 /*
448 ** Remember the URL if requested.
449 */
@@ -457,12 +458,13 @@
457
458 /* Preemptively prompt for a password if a username is given in the
459 ** URL but no password.
460 */
461 void url_get_password_if_needed(void){
462 if( (g.urlUser && g.urlUser[0])
 
463 && (g.urlPasswd==0 || g.urlPasswd[0]==0)
464 && isatty(fileno(stdin))
465 ){
466 url_prompt_for_password();
467 }
468 }
469
--- src/url.c
+++ src/url.c
@@ -412,11 +412,11 @@
412 /*
413 ** Prompt the user for the password for g.urlUser. Store the result
414 ** in g.urlPasswd.
415 */
416 void url_prompt_for_password(void){
417 if( g.urlIsFile || ( g.urlIsSsh && ! url_ssh_use_http() ) ) return;
418 if( isatty(fileno(stdin))
419 && (g.urlFlags & URL_PROMPT_PW)!=0
420 && (g.urlFlags & URL_PROMPTED)==0
421 ){
422 g.urlFlags |= URL_PROMPTED;
@@ -439,11 +439,12 @@
439
440 /*
441 ** Return true if http mode is in use for "ssh://" URL.
442 */
443 int url_ssh_use_http(void){
444 return ( g.zSshUseHttp && g.zSshUseHttp[0] ) ? is_truth(g.zSshUseHttp) :
445 db_get_boolean("ssh-use-http", 0);
446 }
447
448 /*
449 ** Remember the URL if requested.
450 */
@@ -457,12 +458,13 @@
458
459 /* Preemptively prompt for a password if a username is given in the
460 ** URL but no password.
461 */
462 void url_get_password_if_needed(void){
463 const char *zFossilUser = url_or_fossil_user();
464 if( ( zFossilUser && zFossilUser[0] )
465 && (g.urlPasswd==0 || g.urlPasswd[0]==0)
466 && isatty(fileno(stdin))
467 ){
468 url_prompt_for_password();
469 }
470 }
471

Keyboard Shortcuts

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