git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/2] help: include <common-cmds.h> only in one file

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 19, 2013, 08:00 UTC
Message-ID
<7vpq11ob4w.fsf_-_@alter.siamese.dyndns.org>
In-Reply-To
<7vwqv9obie.fsf_-_@alter.siamese.dyndns.org>

This header not only declares but also defines the contents of the array that holds the list of command names and help text. Do not include it in multiple places to waste text space.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 * This is a real "cleanup" patch.
 builtin/help.c | 18 ------------------
 help.c         | 17 +++++++++++++++++
 2 files changed, 17 insertions(+), 18 deletions(-)
diff --git a/builtin/help.c b/builtin/help.c
index bd86253..6067a61 100644
--- a/builtin/help.c
+++ b/builtin/help.c
@@ -6,7 +6,6 @@
 #include "cache.h"
 #include "builtin.h"
 #include "exec_cmd.h"
-#include "common-cmds.h"
 #include "parse-options.h"
 #include "run-command.h"
 #include "column.h"
@@ -287,23 +286,6 @@ static int git_help_config(const char *var, const char *value, void *cb)
 
 static struct cmdnames main_cmds, other_cmds;
 
-void list_common_cmds_help(void)
-{
-	int i, longest = 0;
-
-	for (i = 0; i < ARRAY_SIZE(common_cmds); i++) {
-		if (longest < strlen(common_cmds[i].name))
-			longest = strlen(common_cmds[i].name);
-	}
-
-	puts(_("The most commonly used git commands are:"));
-	for (i = 0; i < ARRAY_SIZE(common_cmds); i++) {
-		printf("   %s   ", common_cmds[i].name);
-		mput_char(' ', longest - strlen(common_cmds[i].name));
-		puts(_(common_cmds[i].help));
-	}
-}
-
 static int is_git_command(const char *s)
 {
 	return is_in_cmdlist(&main_cmds, s) ||
diff --git a/help.c b/help.c
index 2a42ec6..1dfa0b0 100644
--- a/help.c
+++ b/help.c
@@ -223,6 +223,23 @@ void list_commands(unsigned int colopts,
 	}
 }
 
+void list_common_cmds_help(void)
+{
+	int i, longest = 0;
+
+	for (i = 0; i < ARRAY_SIZE(common_cmds); i++) {
+		if (longest < strlen(common_cmds[i].name))
+			longest = strlen(common_cmds[i].name);
+	}
+
+	puts(_("The most commonly used git commands are:"));
+	for (i = 0; i < ARRAY_SIZE(common_cmds); i++) {
+		printf("   %s   ", common_cmds[i].name);
+		mput_char(' ', longest - strlen(common_cmds[i].name));
+		puts(_(common_cmds[i].help));
+	}
+}
+
 int is_in_cmdlist(struct cmdnames *c, const char *s)
 {
 	int i;
-- 
1.8.1.1.454.g48d39c0
Previous: Junio C HamanoNext: Junio C Hamano
Message 20 of 32 in “attr: fix off-by-one directory component length calculation”
  1. attr: fix off-by-one directory component length calculationNguyễn Thái Ngọc Duy, Jan 15, 2013
  2. Junio C HamanoJan 15, 2013
  3. Jean-Noël AVILAJan 15, 2013
  4. Junio C HamanoJan 15, 2013
  5. Jean-Noël AVILAJan 15, 2013
  6. Junio C HamanoJan 15, 2013
  7. Jeff KingJan 15, 2013
  8. Torsten BögershausenJan 16, 2013
  9. Jean-Noël AVILAJan 17, 2013
  10. Jonathan NiederJan 18, 2013
  11. Junio C HamanoJan 18, 2013
  12. Torsten BögershausenJan 18, 2013
  13. Junio C HamanoJan 18, 2013
  14. Junio C HamanoJan 18, 2013
  15. Jean-Noël AVILAJan 18, 2013
  16. Junio C HamanoJan 18, 2013
  17. Junio C HamanoJan 18, 2013
  18. Torsten BögershausenJan 19, 2013
  19. Re* t9902 failsJunio C Hamano, Jan 19, 2013
  20. 1/2 help: include <common-cmds.h> only in one fileJunio C Hamano, Jan 19, 2013
  21. 2/2 help --standard: list standard commandsJunio C Hamano, Jan 19, 2013
  22. Jean-Noël AVILAJan 19, 2013
  23. Jean-Noël AVILAJan 19, 2013
  24. Jean-Noël AVILAJan 19, 2013
  25. Duy NguyenJan 16, 2013
  26. Duy NguyenJan 16, 2013
  27. Junio C HamanoJan 16, 2013
  28. Duy NguyenJan 16, 2013
  29. Junio C HamanoJan 16, 2013
  30. Duy NguyenJan 16, 2013
  31. Junio C HamanoJan 16, 2013
  32. Duy NguyenJan 16, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.