summaryrefslogtreecommitdiff
path: root/help.c
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2021-03-03 15:16:15 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2021-03-03 15:16:15 +0900
commit25fc9ef35e9544c5fe62c8c6379ce828bdc975b2 (patch)
tree82abd85ecc8e05c398fbfe11a483224788a9b3e7 /help.c
parent2376b62f539bf17c1458795e0cea9c9df4b4927d (diff)
downloadgit-25fc9ef35e9544c5fe62c8c6379ce828bdc975b2.tar.gz
git-25fc9ef35e9544c5fe62c8c6379ce828bdc975b2.tar.bz2
git-25fc9ef35e9544c5fe62c8c6379ce828bdc975b2.zip
Imported Upstream version 2.14.0upstream/2.14.0
Diffstat (limited to 'help.c')
-rw-r--r--help.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/help.c b/help.c
index 9d2811ef..88a3aeae 100644
--- a/help.c
+++ b/help.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "config.h"
#include "builtin.h"
#include "exec_cmd.h"
#include "run-command.h"
@@ -9,6 +10,7 @@
#include "column.h"
#include "version.h"
#include "refs.h"
+#include "parse-options.h"
void add_cmdname(struct cmdnames *cmds, const char *name, int len)
{
@@ -267,9 +269,8 @@ static void add_cmd_list(struct cmdnames *cmds, struct cmdnames *old)
for (i = 0; i < old->cnt; i++)
cmds->names[cmds->cnt++] = old->names[i];
- free(old->names);
+ FREE_AND_NULL(old->names);
old->cnt = 0;
- old->names = NULL;
}
/* An empirically derived magic number */
@@ -389,16 +390,30 @@ const char *help_unknown_cmd(const char *cmd)
int cmd_version(int argc, const char **argv, const char *prefix)
{
+ int build_options = 0;
+ const char * const usage[] = {
+ N_("git version [<options>]"),
+ NULL
+ };
+ struct option options[] = {
+ OPT_BOOL(0, "build-options", &build_options,
+ "also print build options"),
+ OPT_END()
+ };
+
+ argc = parse_options(argc, argv, prefix, options, usage, 0);
+
/*
* The format of this string should be kept stable for compatibility
* with external projects that rely on the output of "git version".
+ *
+ * Always show the version, even if other options are given.
*/
printf("git version %s\n", git_version_string);
- while (*++argv) {
- if (!strcmp(*argv, "--build-options")) {
- printf("sizeof-long: %d\n", (int)sizeof(long));
- /* NEEDSWORK: also save and output GIT-BUILD_OPTIONS? */
- }
+
+ if (build_options) {
+ printf("sizeof-long: %d\n", (int)sizeof(long));
+ /* NEEDSWORK: also save and output GIT-BUILD_OPTIONS? */
}
return 0;
}