[PATCH v7 02/10] help.c: remove common category behavior from drop_prefix() behavior

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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-gitfoo" in command-list.txt this
changes nothing in practice, but it makes the intent of the code
clearer.

When this code was added in cfb22a02ab5 (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 1b81d8cb19d (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 <avarab@xxxxxxxxx>
---
 help.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/help.c b/help.c
index 7e594d291b0..8a09f18a3d9 100644
--- a/help.c
+++ b/help.c
@@ -44,16 +44,17 @@ static struct category_description main_categories[] = {
 static const char *drop_prefix(const char *name, uint32_t category)
 {
 	const char *new_name;
-	const char *prefix = NULL;
+	const char *prefix;
 
-	if (skip_prefix(name, "git-", &new_name))
-		return new_name;
 	switch (category) {
 	case CAT_guide:
 		prefix = "git";
 		break;
+	default:
+		prefix = "git-";
+		break;
 	}
-	if (prefix && skip_prefix(name, prefix, &new_name))
+	if (skip_prefix(name, prefix, &new_name))
 		return new_name;
 
 	return name;
-- 
2.37.1.1232.gc0cde427aa7




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux