Fossil SCM

In the "remote-url" command, omit the userid and password from the URL unless the "--show-pw" command-line option is used.

drh 2009-08-13 14:36 trunk
Commit 9cbef7a104e5d6168895a1ab99ad0a68484be369
1 file changed +15 -6
+15 -6
--- src/sync.c
+++ src/sync.c
@@ -154,26 +154,26 @@
154154
}
155155
156156
/*
157157
** COMMAND: remote-url
158158
**
159
-** Usage: %fossil remote-url ?URL|off?
159
+** Usage: %fossil remote-url ?URL|off? --show-pw
160160
**
161161
** Query and optional change the default server named used for syncing
162162
** the current check-out.
163163
**
164
-** WARNING: If the username and password are part of the URL then the
165
-** username and password will be displayed by this command. The user
166
-** name and password are normally suppressed when echoing the remote-url
167
-** during an auto-sync.
164
+** The userid and password are stripped from the URL and are not printed
165
+** unless the --show-pw option is used on the command-line.
168166
**
169167
** The remote-url is set automatically by a "clone" command or by any
170168
** "sync", "push", or "pull" command that specifies an explicit URL.
171169
** The default remote-url is used by auto-syncing and by "sync", "push",
172170
** "pull" that omit the server URL.
173171
*/
174172
void remote_url_cmd(void){
173
+ char *zUrl;
174
+ int showPw = find_option("show-pw",0,0)!=0;
175175
db_must_be_within_tree();
176176
if( g.argc!=2 && g.argc!=3 ){
177177
usage("remote-url ?URL|off?");
178178
}
179179
if( g.argc==3 ){
@@ -182,7 +182,16 @@
182182
}else{
183183
url_parse(g.argv[2]);
184184
db_set("last-sync-url", g.urlCanonical, 0);
185185
}
186186
}
187
- printf("%s\n", db_get("last-sync-url", "off"));
187
+ zUrl = db_get("last-sync-url", 0);
188
+ if( zUrl==0 ){
189
+ printf("off\n");
190
+ return;
191
+ }else if( showPw ){
192
+ g.urlCanonical = zUrl;
193
+ }else{
194
+ url_parse(zUrl);
195
+ }
196
+ printf("%s\n", g.urlCanonical);
188197
}
189198
--- src/sync.c
+++ src/sync.c
@@ -154,26 +154,26 @@
154 }
155
156 /*
157 ** COMMAND: remote-url
158 **
159 ** Usage: %fossil remote-url ?URL|off?
160 **
161 ** Query and optional change the default server named used for syncing
162 ** the current check-out.
163 **
164 ** WARNING: If the username and password are part of the URL then the
165 ** username and password will be displayed by this command. The user
166 ** name and password are normally suppressed when echoing the remote-url
167 ** during an auto-sync.
168 **
169 ** The remote-url is set automatically by a "clone" command or by any
170 ** "sync", "push", or "pull" command that specifies an explicit URL.
171 ** The default remote-url is used by auto-syncing and by "sync", "push",
172 ** "pull" that omit the server URL.
173 */
174 void remote_url_cmd(void){
 
 
175 db_must_be_within_tree();
176 if( g.argc!=2 && g.argc!=3 ){
177 usage("remote-url ?URL|off?");
178 }
179 if( g.argc==3 ){
@@ -182,7 +182,16 @@
182 }else{
183 url_parse(g.argv[2]);
184 db_set("last-sync-url", g.urlCanonical, 0);
185 }
186 }
187 printf("%s\n", db_get("last-sync-url", "off"));
 
 
 
 
 
 
 
 
 
188 }
189
--- src/sync.c
+++ src/sync.c
@@ -154,26 +154,26 @@
154 }
155
156 /*
157 ** COMMAND: remote-url
158 **
159 ** Usage: %fossil remote-url ?URL|off? --show-pw
160 **
161 ** Query and optional change the default server named used for syncing
162 ** the current check-out.
163 **
164 ** The userid and password are stripped from the URL and are not printed
165 ** unless the --show-pw option is used on the command-line.
 
 
166 **
167 ** The remote-url is set automatically by a "clone" command or by any
168 ** "sync", "push", or "pull" command that specifies an explicit URL.
169 ** The default remote-url is used by auto-syncing and by "sync", "push",
170 ** "pull" that omit the server URL.
171 */
172 void remote_url_cmd(void){
173 char *zUrl;
174 int showPw = find_option("show-pw",0,0)!=0;
175 db_must_be_within_tree();
176 if( g.argc!=2 && g.argc!=3 ){
177 usage("remote-url ?URL|off?");
178 }
179 if( g.argc==3 ){
@@ -182,7 +182,16 @@
182 }else{
183 url_parse(g.argv[2]);
184 db_set("last-sync-url", g.urlCanonical, 0);
185 }
186 }
187 zUrl = db_get("last-sync-url", 0);
188 if( zUrl==0 ){
189 printf("off\n");
190 return;
191 }else if( showPw ){
192 g.urlCanonical = zUrl;
193 }else{
194 url_parse(zUrl);
195 }
196 printf("%s\n", g.urlCanonical);
197 }
198

Keyboard Shortcuts

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