Fossil SCM

When reporting the list of mathing ambiguous sub-command, make sure settings with the same prefix are not listed.

mgagnon 2022-04-05 19:51 ambiguous_cmd_fix
Commit bb5162fe163175c0d9f18b6319be7a268c82583d9b70baf63996512be7a35afb
2 files changed +7 -2 +1 -1
+7 -2
--- src/dispatch.c
+++ src/dispatch.c
@@ -209,16 +209,21 @@
209209
return 0;
210210
}
211211
212212
/*
213213
** 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.
215215
*/
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
+){
217221
int i;
218222
int nPrefix = (int)strlen(zPrefix);
219223
for(i=FOSSIL_FIRST_CMD; i<MX_COMMAND; i++){
224
+ if( (aCommand[i].eCmdFlags & eType)==0 ) continue;
220225
if( strncmp(zPrefix, aCommand[i].zName, nPrefix)==0 ){
221226
blob_appendf(pList, " %s", aCommand[i].zName);
222227
}
223228
}
224229
}
225230
--- 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 @@
911911
fossil_exit(0);
912912
#endif
913913
}else if( rc==2 ){
914914
Blob couldbe;
915915
blob_init(&couldbe,0,0);
916
- dispatch_matching_names(zCmdName, &couldbe);
916
+ dispatch_matching_names(zCmdName, CMDFLAG_COMMAND, &couldbe);
917917
fossil_print("%s: ambiguous command prefix: %s\n"
918918
"%s: could be any of:%s\n"
919919
"%s: use \"help\" for more information\n",
920920
g.argv[0], zCmdName, g.argv[0], blob_str(&couldbe), g.argv[0]);
921921
fossil_exit(1);
922922
--- 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

Keyboard Shortcuts

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