summaryrefslogtreecommitdiff
path: root/help.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2019-03-20 18:03:28 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-03-21 02:52:11 (GMT)
commit057ab54b6646fbdabc8c953299f218081ff67456 (patch)
treef04384200663b1ef50f251c5588459bbbd6aa830 /help.c
parent402e3e1500b3bce5cee9f903f8aa691a8010e76a (diff)
downloadgit-057ab54b6646fbdabc8c953299f218081ff67456.zip
git-057ab54b6646fbdabc8c953299f218081ff67456.tar.gz
git-057ab54b6646fbdabc8c953299f218081ff67456.tar.bz2
completion: fix multiple command removals
Commit 6532f3740b ("completion: allow to customize the completable command list", 2018-05-20) tried to allow multiple space-separated entries in completion.commands. To do this, it copies each parsed token into a strbuf so that the result is NUL-terminated. However, for tokens starting with "-", it accidentally passes the original non-terminated string, meaning that only the final one worked. Switch to using the strbuf. Reported-by: Todd Zullinger <tmz@pobox.com> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'help.c')
-rw-r--r--help.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/help.c b/help.c
index fac7e42..a9e451f 100644
--- a/help.c
+++ b/help.c
@@ -386,8 +386,8 @@ void list_cmds_by_config(struct string_list *list)
const char *p = strchrnul(cmd_list, ' ');
strbuf_add(&sb, cmd_list, p - cmd_list);
- if (*cmd_list == '-')
- string_list_remove(list, cmd_list + 1, 0);
+ if (sb.buf[0] == '-')
+ string_list_remove(list, sb.buf + 1, 0);
else
string_list_insert(list, sb.buf);
strbuf_release(&sb);