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].
Commit
2a3e851e7bb88c987d66ff5a2aae1ff74211b343167b2282e30a9da81c6e4868
Parent
1431ebae3d33974…
1 file changed
+12
-7
+12
-7
| --- src/sync.c | ||
| +++ src/sync.c | ||
| @@ -481,13 +481,14 @@ | ||
| 481 | 481 | ** COMMAND: remote-url* |
| 482 | 482 | ** |
| 483 | 483 | ** Usage: %fossil remote ?SUBCOMMAND ...? |
| 484 | 484 | ** |
| 485 | 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. | |
| 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. | |
| 489 | 490 | ** |
| 490 | 491 | ** > fossil remote |
| 491 | 492 | ** |
| 492 | 493 | ** With no arguments, this command shows the current default remote |
| 493 | 494 | ** URL. If there is no default, it shows "off". |
| @@ -494,12 +495,14 @@ | ||
| 494 | 495 | ** |
| 495 | 496 | ** > fossil remote add NAME URL |
| 496 | 497 | ** |
| 497 | 498 | ** Add a new named URL. Afterwards, NAME can be used as a short |
| 498 | 499 | ** 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. | |
| 501 | 504 | ** |
| 502 | 505 | ** > fossil remote config-data |
| 503 | 506 | ** |
| 504 | 507 | ** DEBUG USE ONLY - Show the name and value of every CONFIG table |
| 505 | 508 | ** entry in the repository that is associated with the remote URL store. |
| @@ -633,11 +636,14 @@ | ||
| 633 | 636 | UrlData x; |
| 634 | 637 | if( g.argc!=5 ) usage("add NAME URL"); |
| 635 | 638 | memset(&x, 0, sizeof(x)); |
| 636 | 639 | zName = g.argv[3]; |
| 637 | 640 | 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 | + } | |
| 639 | 645 | db_begin_write(); |
| 640 | 646 | if( fossil_strcmp(zUrl,"default")==0 ){ |
| 641 | 647 | x.canonical = db_get("last-sync-url",0); |
| 642 | 648 | x.passwd = unobscure(db_get("last-sync-pw",0)); |
| 643 | 649 | }else{ |
| @@ -788,11 +794,10 @@ | ||
| 788 | 794 | || sqlite3_strlike("https://%",zArg,0)==0 |
| 789 | 795 | || sqlite3_strlike("ssh:%",zArg,0)==0 |
| 790 | 796 | || sqlite3_strlike("file:%",zArg,0)==0 |
| 791 | 797 | || db_exists("SELECT 1 FROM config WHERE name='sync-url:%q'",zArg) |
| 792 | 798 | ){ |
| 793 | -remote_add_default: | |
| 794 | 799 | db_unset("last-sync-url", 0); |
| 795 | 800 | db_unset("last-sync-pw", 0); |
| 796 | 801 | url_parse(g.argv[2], URL_REMEMBER|URL_PROMPT_PW| |
| 797 | 802 | URL_USE_CONFIG|URL_ASK_REMEMBER_PW); |
| 798 | 803 | url_remember(); |
| 799 | 804 |
| --- 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 |