Fossil SCM

tweak `fossil remote` cmd to update the "default" name Don't delete the current default remote-url when the user invokes the invalid `fossil remote add default` command; instead, output correct usage to update the special "default" symbolic name. Tweak help text to make this more obvious. Prompted by [forum:5748fcb117a99b43].

mark 2022-09-25 13:44 trunk
Commit 2a3e851e7bb88c987d66ff5a2aae1ff74211b343167b2282e30a9da81c6e4868
1 file changed +12 -7
+12 -7
--- src/sync.c
+++ src/sync.c
@@ -481,13 +481,14 @@
481481
** COMMAND: remote-url*
482482
**
483483
** Usage: %fossil remote ?SUBCOMMAND ...?
484484
**
485485
** View or modify the URLs of remote repositories used for syncing.
486
-** The "default" remote is the URL used in the most recent "sync",
487
-** "push", "pull", "clone", or similar command. The default remote can
488
-** change with each sync command. Other named remotes are persistent.
486
+** The "default" remote is specially named by Fossil and corresponds to
487
+** the URL used in the most recent "sync", "push", "pull", "clone", or
488
+** similar command. As such, the default remote can be updated by
489
+** Fossil with each sync command. Other named remotes are persistent.
489490
**
490491
** > fossil remote
491492
**
492493
** With no arguments, this command shows the current default remote
493494
** URL. If there is no default, it shows "off".
@@ -494,12 +495,14 @@
494495
**
495496
** > fossil remote add NAME URL
496497
**
497498
** Add a new named URL. Afterwards, NAME can be used as a short
498499
** symbolic name for URL in contexts where a URL is required. The
499
-** URL argument can be "default" or a prior symbolic name, to make
500
-** a copy of an existing URL under a new name.
500
+** URL argument can be "default" or a prior symbolic name to make
501
+** a copy of an existing URL under the new NAME. The "default"
502
+** remote cannot be defined with this subcommand; instead,
503
+** use 'fossil remote REF' as documented below.
501504
**
502505
** > fossil remote config-data
503506
**
504507
** DEBUG USE ONLY - Show the name and value of every CONFIG table
505508
** entry in the repository that is associated with the remote URL store.
@@ -633,11 +636,14 @@
633636
UrlData x;
634637
if( g.argc!=5 ) usage("add NAME URL");
635638
memset(&x, 0, sizeof(x));
636639
zName = g.argv[3];
637640
zUrl = g.argv[4];
638
- if( strcmp(zName,"default")==0 ) goto remote_add_default;
641
+ if( strcmp(zName,"default")==0 ){
642
+ fossil_fatal("update the \"default\" remote-url with 'fossil remote REF'"
643
+ "\nsee 'fossil help remote' for complete usage information");
644
+ }
639645
db_begin_write();
640646
if( fossil_strcmp(zUrl,"default")==0 ){
641647
x.canonical = db_get("last-sync-url",0);
642648
x.passwd = unobscure(db_get("last-sync-pw",0));
643649
}else{
@@ -788,11 +794,10 @@
788794
|| sqlite3_strlike("https://%",zArg,0)==0
789795
|| sqlite3_strlike("ssh:%",zArg,0)==0
790796
|| sqlite3_strlike("file:%",zArg,0)==0
791797
|| db_exists("SELECT 1 FROM config WHERE name='sync-url:%q'",zArg)
792798
){
793
-remote_add_default:
794799
db_unset("last-sync-url", 0);
795800
db_unset("last-sync-pw", 0);
796801
url_parse(g.argv[2], URL_REMEMBER|URL_PROMPT_PW|
797802
URL_USE_CONFIG|URL_ASK_REMEMBER_PW);
798803
url_remember();
799804
--- src/sync.c
+++ src/sync.c
@@ -481,13 +481,14 @@
481 ** COMMAND: remote-url*
482 **
483 ** Usage: %fossil remote ?SUBCOMMAND ...?
484 **
485 ** View or modify the URLs of remote repositories used for syncing.
486 ** The "default" remote is the URL used in the most recent "sync",
487 ** "push", "pull", "clone", or similar command. The default remote can
488 ** change with each sync command. Other named remotes are persistent.
 
489 **
490 ** > fossil remote
491 **
492 ** With no arguments, this command shows the current default remote
493 ** URL. If there is no default, it shows "off".
@@ -494,12 +495,14 @@
494 **
495 ** > fossil remote add NAME URL
496 **
497 ** Add a new named URL. Afterwards, NAME can be used as a short
498 ** symbolic name for URL in contexts where a URL is required. The
499 ** URL argument can be "default" or a prior symbolic name, to make
500 ** a copy of an existing URL under a new name.
 
 
501 **
502 ** > fossil remote config-data
503 **
504 ** DEBUG USE ONLY - Show the name and value of every CONFIG table
505 ** entry in the repository that is associated with the remote URL store.
@@ -633,11 +636,14 @@
633 UrlData x;
634 if( g.argc!=5 ) usage("add NAME URL");
635 memset(&x, 0, sizeof(x));
636 zName = g.argv[3];
637 zUrl = g.argv[4];
638 if( strcmp(zName,"default")==0 ) goto remote_add_default;
 
 
 
639 db_begin_write();
640 if( fossil_strcmp(zUrl,"default")==0 ){
641 x.canonical = db_get("last-sync-url",0);
642 x.passwd = unobscure(db_get("last-sync-pw",0));
643 }else{
@@ -788,11 +794,10 @@
788 || sqlite3_strlike("https://%",zArg,0)==0
789 || sqlite3_strlike("ssh:%",zArg,0)==0
790 || sqlite3_strlike("file:%",zArg,0)==0
791 || db_exists("SELECT 1 FROM config WHERE name='sync-url:%q'",zArg)
792 ){
793 remote_add_default:
794 db_unset("last-sync-url", 0);
795 db_unset("last-sync-pw", 0);
796 url_parse(g.argv[2], URL_REMEMBER|URL_PROMPT_PW|
797 URL_USE_CONFIG|URL_ASK_REMEMBER_PW);
798 url_remember();
799
--- src/sync.c
+++ src/sync.c
@@ -481,13 +481,14 @@
481 ** COMMAND: remote-url*
482 **
483 ** Usage: %fossil remote ?SUBCOMMAND ...?
484 **
485 ** View or modify the URLs of remote repositories used for syncing.
486 ** The "default" remote is specially named by Fossil and corresponds to
487 ** the URL used in the most recent "sync", "push", "pull", "clone", or
488 ** similar command. As such, the default remote can be updated by
489 ** Fossil with each sync command. Other named remotes are persistent.
490 **
491 ** > fossil remote
492 **
493 ** With no arguments, this command shows the current default remote
494 ** URL. If there is no default, it shows "off".
@@ -494,12 +495,14 @@
495 **
496 ** > fossil remote add NAME URL
497 **
498 ** Add a new named URL. Afterwards, NAME can be used as a short
499 ** symbolic name for URL in contexts where a URL is required. The
500 ** URL argument can be "default" or a prior symbolic name to make
501 ** a copy of an existing URL under the new NAME. The "default"
502 ** remote cannot be defined with this subcommand; instead,
503 ** use 'fossil remote REF' as documented below.
504 **
505 ** > fossil remote config-data
506 **
507 ** DEBUG USE ONLY - Show the name and value of every CONFIG table
508 ** entry in the repository that is associated with the remote URL store.
@@ -633,11 +636,14 @@
636 UrlData x;
637 if( g.argc!=5 ) usage("add NAME URL");
638 memset(&x, 0, sizeof(x));
639 zName = g.argv[3];
640 zUrl = g.argv[4];
641 if( strcmp(zName,"default")==0 ){
642 fossil_fatal("update the \"default\" remote-url with 'fossil remote REF'"
643 "\nsee 'fossil help remote' for complete usage information");
644 }
645 db_begin_write();
646 if( fossil_strcmp(zUrl,"default")==0 ){
647 x.canonical = db_get("last-sync-url",0);
648 x.passwd = unobscure(db_get("last-sync-pw",0));
649 }else{
@@ -788,11 +794,10 @@
794 || sqlite3_strlike("https://%",zArg,0)==0
795 || sqlite3_strlike("ssh:%",zArg,0)==0
796 || sqlite3_strlike("file:%",zArg,0)==0
797 || db_exists("SELECT 1 FROM config WHERE name='sync-url:%q'",zArg)
798 ){
 
799 db_unset("last-sync-url", 0);
800 db_unset("last-sync-pw", 0);
801 url_parse(g.argv[2], URL_REMEMBER|URL_PROMPT_PW|
802 URL_USE_CONFIG|URL_ASK_REMEMBER_PW);
803 url_remember();
804

Keyboard Shortcuts

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