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

[PATCH] help: ensure that common-cmds.h is only included by help.c

From
David Aguilar <davvid@gmail.com>
Date
Sep 14, 2014, 01:11 UTC
Message-ID
<1410657073-3089-1-git-send-email-davvid@gmail.com>

Add a #ifndef guard to ensure that common-cmds.h can only be included by help.c.

Suggested-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: David Aguilar <davvid@gmail.com>
---
 generate-cmdlist.sh | 4 ++++
 help.c              | 3 ++-
 2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/generate-cmdlist.sh b/generate-cmdlist.sh
index 9a4c9b9..99cd140 100755
--- a/generate-cmdlist.sh
+++ b/generate-cmdlist.sh
@@ -1,6 +1,10 @@
 #!/bin/sh
 
 echo "/* Automatically generated by $0 */
+#ifndef GIT_HELP_INTERNAL
+#error \"common-cmds.h can only be included by help.c\"
+#endif
+
 struct cmdname_help {
     char name[16];
     char help[80];
diff --git a/help.c b/help.c
index 7af65e2..abf1689 100644
--- a/help.c
+++ b/help.c
@@ -3,11 +3,12 @@
 #include "exec_cmd.h"
 #include "levenshtein.h"
 #include "help.h"
-#include "common-cmds.h"
 #include "string-list.h"
 #include "column.h"
 #include "version.h"
 #include "refs.h"
+#define GIT_HELP_INTERNAL
+#include "common-cmds.h"
 
 void add_cmdname(struct cmdnames *cmds, const char *name, int len)
 {
-- 
2.1.0.241.ga16d620
Next: Perry Hutchison
Message 1 of 6 in “help: ensure that common-cmds.h is only included by help.c”
  1. help: ensure that common-cmds.h is only included by help.cDavid Aguilar, Sep 14, 2014
  2. Perry HutchisonSep 14, 2014
  3. Junio C HamanoSep 14, 2014
  4. David AguilarSep 14, 2014
  5. Perry HutchisonSep 14, 2014
  6. David AguilarSep 14, 2014

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.