Fossil SCM

Improvements to "fossil patch alias" help, including putting that subcommand in alphabetical order with the rest. Enhance the patch_resolve_remote() subroutine so that it avoids a full-table scan of CONFIG.

drh 2025-02-28 14:40 patch-alias
Commit e74de63bf7078261a1b0f9332dc855d948d6035e019b451810a8ce750b517924
1 file changed +16 -24
+16 -24
--- src/patch.c
+++ src/patch.c
@@ -707,14 +707,14 @@
707707
**
708708
** If a CONFIG table entry matching name='patch-alias:$zKey' is found,
709709
** the corresponding value is returned, else a fossil_strdup() of zKey
710710
** is returned.
711711
*/
712
-static char * patch_resolve_remote(const char *zKey){
713
- char * zAlias = db_text(0, "SELECT value FROM config "
714
- "WHERE name = 'patch-alias:' || %Q",
715
- zKey);
712
+static char *patch_resolve_remote(const char *zKey){
713
+ char *zAlias = db_text(0, "SELECT value FROM config "
714
+ "WHERE name = 'patch-alias:%q'",
715
+ zKey);
716716
return zAlias ? zAlias : fossil_strdup(zKey);
717717
}
718718
719719
/*
720720
** Create a FILE* that will execute the remote side of a push or pull
@@ -930,10 +930,22 @@
930930
** This command is used to create, view, and apply Fossil binary patches.
931931
** A Fossil binary patch is a single (binary) file that captures all of the
932932
** uncommitted changes of a check-out. Use Fossil binary patches to transfer
933933
** proposed or incomplete changes between machines for testing or analysis.
934934
**
935
+** > fossil patch alias add|rm|ls|list ?ARGS?
936
+**
937
+** Manage remote-name aliases, which act as short-form
938
+** equivalents to REMOTE-CHECKOUT strings. Aliases are local to
939
+** a given repository and do not sync. Subcommands:
940
+**
941
+** ... add ALIAS REMOTE-CHECKOUT Add ALIAS as an alias
942
+** for REMOTE-CHECKOUT.
943
+** ... ls|list List all local aliases.
944
+** ... rm ALIAS [ALIAS...] Remove named aliases
945
+** ... rm --all Remove all aliases
946
+**
935947
** > fossil patch create [DIRECTORY] PATCHFILE
936948
**
937949
** Create a new binary patch in PATCHFILE that captures all uncommitted
938950
** changes in the check-out at DIRECTORY, or the current directory if
939951
** DIRECTORY is omitted. If PATCHFILE is "-" then the binary patch
@@ -1004,30 +1016,10 @@
10041016
** View a summary of the changes in the binary patch in PATCHFILE.
10051017
** Use "fossil patch diff" for detailed patch content.
10061018
**
10071019
** -v|--verbose Show extra detail about the patch
10081020
**
1009
-** > fossil patch alias add|rm|ls|list ?ARGS?
1010
-**
1011
-** Manage remote-name aliases, which act as short-form
1012
-** equivalents to REMOTE-CHECKOUT strings. Aliases are local to
1013
-** a given repository and do not sync.
1014
-**
1015
-** Subcommands:
1016
-**
1017
-** > add local-name REMOTE-CHECKOUT
1018
-**
1019
-** Add local-name as an alias for REMOTE-CHECKOUT.
1020
-**
1021
-** > ls|list
1022
-**
1023
-** List all local aliases.
1024
-**
1025
-** > rm [-all]| local-name [...local-nameN]
1026
-**
1027
-** Remove all aliases which match the given GLOB patterns, or
1028
-** all aliases if -all is specified.
10291021
*/
10301022
void patch_cmd(void){
10311023
const char *zCmd;
10321024
size_t n;
10331025
if( g.argc<3 ){
10341026
--- src/patch.c
+++ src/patch.c
@@ -707,14 +707,14 @@
707 **
708 ** If a CONFIG table entry matching name='patch-alias:$zKey' is found,
709 ** the corresponding value is returned, else a fossil_strdup() of zKey
710 ** is returned.
711 */
712 static char * patch_resolve_remote(const char *zKey){
713 char * zAlias = db_text(0, "SELECT value FROM config "
714 "WHERE name = 'patch-alias:' || %Q",
715 zKey);
716 return zAlias ? zAlias : fossil_strdup(zKey);
717 }
718
719 /*
720 ** Create a FILE* that will execute the remote side of a push or pull
@@ -930,10 +930,22 @@
930 ** This command is used to create, view, and apply Fossil binary patches.
931 ** A Fossil binary patch is a single (binary) file that captures all of the
932 ** uncommitted changes of a check-out. Use Fossil binary patches to transfer
933 ** proposed or incomplete changes between machines for testing or analysis.
934 **
 
 
 
 
 
 
 
 
 
 
 
 
935 ** > fossil patch create [DIRECTORY] PATCHFILE
936 **
937 ** Create a new binary patch in PATCHFILE that captures all uncommitted
938 ** changes in the check-out at DIRECTORY, or the current directory if
939 ** DIRECTORY is omitted. If PATCHFILE is "-" then the binary patch
@@ -1004,30 +1016,10 @@
1004 ** View a summary of the changes in the binary patch in PATCHFILE.
1005 ** Use "fossil patch diff" for detailed patch content.
1006 **
1007 ** -v|--verbose Show extra detail about the patch
1008 **
1009 ** > fossil patch alias add|rm|ls|list ?ARGS?
1010 **
1011 ** Manage remote-name aliases, which act as short-form
1012 ** equivalents to REMOTE-CHECKOUT strings. Aliases are local to
1013 ** a given repository and do not sync.
1014 **
1015 ** Subcommands:
1016 **
1017 ** > add local-name REMOTE-CHECKOUT
1018 **
1019 ** Add local-name as an alias for REMOTE-CHECKOUT.
1020 **
1021 ** > ls|list
1022 **
1023 ** List all local aliases.
1024 **
1025 ** > rm [-all]| local-name [...local-nameN]
1026 **
1027 ** Remove all aliases which match the given GLOB patterns, or
1028 ** all aliases if -all is specified.
1029 */
1030 void patch_cmd(void){
1031 const char *zCmd;
1032 size_t n;
1033 if( g.argc<3 ){
1034
--- src/patch.c
+++ src/patch.c
@@ -707,14 +707,14 @@
707 **
708 ** If a CONFIG table entry matching name='patch-alias:$zKey' is found,
709 ** the corresponding value is returned, else a fossil_strdup() of zKey
710 ** is returned.
711 */
712 static char *patch_resolve_remote(const char *zKey){
713 char *zAlias = db_text(0, "SELECT value FROM config "
714 "WHERE name = 'patch-alias:%q'",
715 zKey);
716 return zAlias ? zAlias : fossil_strdup(zKey);
717 }
718
719 /*
720 ** Create a FILE* that will execute the remote side of a push or pull
@@ -930,10 +930,22 @@
930 ** This command is used to create, view, and apply Fossil binary patches.
931 ** A Fossil binary patch is a single (binary) file that captures all of the
932 ** uncommitted changes of a check-out. Use Fossil binary patches to transfer
933 ** proposed or incomplete changes between machines for testing or analysis.
934 **
935 ** > fossil patch alias add|rm|ls|list ?ARGS?
936 **
937 ** Manage remote-name aliases, which act as short-form
938 ** equivalents to REMOTE-CHECKOUT strings. Aliases are local to
939 ** a given repository and do not sync. Subcommands:
940 **
941 ** ... add ALIAS REMOTE-CHECKOUT Add ALIAS as an alias
942 ** for REMOTE-CHECKOUT.
943 ** ... ls|list List all local aliases.
944 ** ... rm ALIAS [ALIAS...] Remove named aliases
945 ** ... rm --all Remove all aliases
946 **
947 ** > fossil patch create [DIRECTORY] PATCHFILE
948 **
949 ** Create a new binary patch in PATCHFILE that captures all uncommitted
950 ** changes in the check-out at DIRECTORY, or the current directory if
951 ** DIRECTORY is omitted. If PATCHFILE is "-" then the binary patch
@@ -1004,30 +1016,10 @@
1016 ** View a summary of the changes in the binary patch in PATCHFILE.
1017 ** Use "fossil patch diff" for detailed patch content.
1018 **
1019 ** -v|--verbose Show extra detail about the patch
1020 **
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1021 */
1022 void patch_cmd(void){
1023 const char *zCmd;
1024 size_t n;
1025 if( g.argc<3 ){
1026

Keyboard Shortcuts

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