Skip to content

Commit 936b8eb

Browse files
avargitster
authored andcommitted
help.c: remove common category behavior from drop_prefix() behavior
Change the behavior of the "git" prefix stripping for CAT_guide so that we don't try to strip the "git-" prefix in that case. We should be stripping either "git" or "git-" depending on the category. This change makes it easier to add extra "category" conditions in subsequent commits. Before this we'd in principle strip a "git-" prefix from a "guide" in command-list.txt, in practice we have no such entry there. As we don't have any entry that looks like "git-foo" in command-list.txt this changes nothing in practice, but it makes the intent of the code clearer. In that hypothetical case we'd now strip it down to "-foo", not "foo". When this code was added in cfb22a0 (help: use command-list.h for common command list, 2018-05-10) the only entries in command-list.txt that didn't begin with "git-" were "gitweb" and "gitk". Then when the "guides" special-case was added in 1b81d8c (help: use command-list.txt for the source of guides, 2018-05-20) we had the various "git" (not "git-") prefixed "guide" entries, which the "CAT_guide" case handles. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2f8b3ea commit 936b8eb

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

help.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,17 @@ static struct category_description main_categories[] = {
4444
static const char *drop_prefix(const char *name, uint32_t category)
4545
{
4646
const char *new_name;
47-
const char *prefix = NULL;
47+
const char *prefix;
4848

49-
if (skip_prefix(name, "git-", &new_name))
50-
return new_name;
5149
switch (category) {
5250
case CAT_guide:
5351
prefix = "git";
5452
break;
53+
default:
54+
prefix = "git-";
55+
break;
5556
}
56-
if (prefix && skip_prefix(name, prefix, &new_name))
57+
if (skip_prefix(name, prefix, &new_name))
5758
return new_name;
5859

5960
return name;

0 commit comments

Comments
 (0)