help: include <common-cmds.h> only in one file
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>
Junio C Hamano committed
Jan 18, 2013 at 22:35 UTC
1542d4cdad9287896fd80d84a4c2256197087308
2 files changed
+17
-18
builtin/help.c
-18
@@ -6,7 +6,6 @@
6
#include "cache.h"
7
#include "builtin.h"
8
#include "exec_cmd.h"
9
-#include "common-cmds.h"
9
#include "parse-options.h"
10
#include "run-command.h"
11
#include "column.h"
@@ -287,23 +286,6 @@ static int git_help_config(const char *var, const char *value, void *cb)
286
287
static struct cmdnames main_cmds, other_cmds;
288
290
-void list_common_cmds_help(void)
291
-{
292
- int i, longest = 0;
293
-
294
- for (i = 0; i < ARRAY_SIZE(common_cmds); i++) {
295
- if (longest < strlen(common_cmds[i].name))
296
- longest = strlen(common_cmds[i].name);
297
- }
298
-
299
- puts(_("The most commonly used git commands are:"));
300
- for (i = 0; i < ARRAY_SIZE(common_cmds); i++) {
301
- printf(" %s ", common_cmds[i].name);
302
- mput_char(' ', longest - strlen(common_cmds[i].name));
303
- puts(_(common_cmds[i].help));
304
- }
305
-}
306
-
289
static int is_git_command(const char *s)
290
{
291
return is_in_cmdlist(&main_cmds, s) ||
help.c
+17
@@ -223,6 +223,23 @@ void list_commands(unsigned int colopts,
223
}
224
}
225
226
+void list_common_cmds_help(void)
227
+{
228
+ int i, longest = 0;
229
+
230
+ for (i = 0; i < ARRAY_SIZE(common_cmds); i++) {
231
+ if (longest < strlen(common_cmds[i].name))
232
+ longest = strlen(common_cmds[i].name);
233
+ }
234
+
235
+ puts(_("The most commonly used git commands are:"));
236
+ for (i = 0; i < ARRAY_SIZE(common_cmds); i++) {
237
+ printf(" %s ", common_cmds[i].name);
238
+ mput_char(' ', longest - strlen(common_cmds[i].name));
239
+ puts(_(common_cmds[i].help));
240
+ }
241
+}
242
+
243
int is_in_cmdlist(struct cmdnames *c, const char *s)
244
{
245
int i;