Fossil SCM
When reporting the list of mathing ambiguous sub-command, make sure settings with the same prefix are not listed.
Commit
bb5162fe163175c0d9f18b6319be7a268c82583d9b70baf63996512be7a35afb
Parent
862ce7ce2c5d910…
2 files changed
+7
-2
+1
-1
+7
-2
| --- src/dispatch.c | ||
| +++ src/dispatch.c | ||
| @@ -209,16 +209,21 @@ | ||
| 209 | 209 | return 0; |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | /* |
| 213 | 213 | ** Fill Blob with a space-separated list of all command names that |
| 214 | -** match the prefix zPrefix. | |
| 214 | +** match the prefix zPrefix and the eType CMDFLAGS_ bits. | |
| 215 | 215 | */ |
| 216 | -void dispatch_matching_names(const char *zPrefix, Blob *pList){ | |
| 216 | +void dispatch_matching_names( | |
| 217 | + const char *zPrefix, /* name prefix */ | |
| 218 | + unsigned eType, /* CMDFLAG_ bits */ | |
| 219 | + Blob *pList /* space-separated list of command names */ | |
| 220 | +){ | |
| 217 | 221 | int i; |
| 218 | 222 | int nPrefix = (int)strlen(zPrefix); |
| 219 | 223 | for(i=FOSSIL_FIRST_CMD; i<MX_COMMAND; i++){ |
| 224 | + if( (aCommand[i].eCmdFlags & eType)==0 ) continue; | |
| 220 | 225 | if( strncmp(zPrefix, aCommand[i].zName, nPrefix)==0 ){ |
| 221 | 226 | blob_appendf(pList, " %s", aCommand[i].zName); |
| 222 | 227 | } |
| 223 | 228 | } |
| 224 | 229 | } |
| 225 | 230 |
| --- src/dispatch.c | |
| +++ src/dispatch.c | |
| @@ -209,16 +209,21 @@ | |
| 209 | return 0; |
| 210 | } |
| 211 | |
| 212 | /* |
| 213 | ** Fill Blob with a space-separated list of all command names that |
| 214 | ** match the prefix zPrefix. |
| 215 | */ |
| 216 | void dispatch_matching_names(const char *zPrefix, Blob *pList){ |
| 217 | int i; |
| 218 | int nPrefix = (int)strlen(zPrefix); |
| 219 | for(i=FOSSIL_FIRST_CMD; i<MX_COMMAND; i++){ |
| 220 | if( strncmp(zPrefix, aCommand[i].zName, nPrefix)==0 ){ |
| 221 | blob_appendf(pList, " %s", aCommand[i].zName); |
| 222 | } |
| 223 | } |
| 224 | } |
| 225 |
| --- src/dispatch.c | |
| +++ src/dispatch.c | |
| @@ -209,16 +209,21 @@ | |
| 209 | return 0; |
| 210 | } |
| 211 | |
| 212 | /* |
| 213 | ** Fill Blob with a space-separated list of all command names that |
| 214 | ** match the prefix zPrefix and the eType CMDFLAGS_ bits. |
| 215 | */ |
| 216 | void dispatch_matching_names( |
| 217 | const char *zPrefix, /* name prefix */ |
| 218 | unsigned eType, /* CMDFLAG_ bits */ |
| 219 | Blob *pList /* space-separated list of command names */ |
| 220 | ){ |
| 221 | int i; |
| 222 | int nPrefix = (int)strlen(zPrefix); |
| 223 | for(i=FOSSIL_FIRST_CMD; i<MX_COMMAND; i++){ |
| 224 | if( (aCommand[i].eCmdFlags & eType)==0 ) continue; |
| 225 | if( strncmp(zPrefix, aCommand[i].zName, nPrefix)==0 ){ |
| 226 | blob_appendf(pList, " %s", aCommand[i].zName); |
| 227 | } |
| 228 | } |
| 229 | } |
| 230 |
+1
-1
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -911,11 +911,11 @@ | ||
| 911 | 911 | fossil_exit(0); |
| 912 | 912 | #endif |
| 913 | 913 | }else if( rc==2 ){ |
| 914 | 914 | Blob couldbe; |
| 915 | 915 | blob_init(&couldbe,0,0); |
| 916 | - dispatch_matching_names(zCmdName, &couldbe); | |
| 916 | + dispatch_matching_names(zCmdName, CMDFLAG_COMMAND, &couldbe); | |
| 917 | 917 | fossil_print("%s: ambiguous command prefix: %s\n" |
| 918 | 918 | "%s: could be any of:%s\n" |
| 919 | 919 | "%s: use \"help\" for more information\n", |
| 920 | 920 | g.argv[0], zCmdName, g.argv[0], blob_str(&couldbe), g.argv[0]); |
| 921 | 921 | fossil_exit(1); |
| 922 | 922 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -911,11 +911,11 @@ | |
| 911 | fossil_exit(0); |
| 912 | #endif |
| 913 | }else if( rc==2 ){ |
| 914 | Blob couldbe; |
| 915 | blob_init(&couldbe,0,0); |
| 916 | dispatch_matching_names(zCmdName, &couldbe); |
| 917 | fossil_print("%s: ambiguous command prefix: %s\n" |
| 918 | "%s: could be any of:%s\n" |
| 919 | "%s: use \"help\" for more information\n", |
| 920 | g.argv[0], zCmdName, g.argv[0], blob_str(&couldbe), g.argv[0]); |
| 921 | fossil_exit(1); |
| 922 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -911,11 +911,11 @@ | |
| 911 | fossil_exit(0); |
| 912 | #endif |
| 913 | }else if( rc==2 ){ |
| 914 | Blob couldbe; |
| 915 | blob_init(&couldbe,0,0); |
| 916 | dispatch_matching_names(zCmdName, CMDFLAG_COMMAND, &couldbe); |
| 917 | fossil_print("%s: ambiguous command prefix: %s\n" |
| 918 | "%s: could be any of:%s\n" |
| 919 | "%s: use \"help\" for more information\n", |
| 920 | g.argv[0], zCmdName, g.argv[0], blob_str(&couldbe), g.argv[0]); |
| 921 | fossil_exit(1); |
| 922 |