@matheusbsbs / matheus-bagliano / commits / 53a1116c61
Fork 0

update-server-info: make builtin, use parseopt

Convert git update-server-info to a built-in command and use parseopt. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Aug 29, 2009 at 11:04 UTC 53a1116c611e9e717d90e1406b29d97648460773
5 files changed +28 -29
Makefile
+1 -1
@@ -357,7 +357,6 @@ PROGRAMS += git-patch-id$X
357 PROGRAMS += git-shell$X
358 PROGRAMS += git-show-index$X
359 PROGRAMS += git-unpack-file$X
360 -PROGRAMS += git-update-server-info$X
360 PROGRAMS += git-upload-pack$X
361 PROGRAMS += git-var$X
362
@@ -636,6 +635,7 @@ BUILTIN_OBJS += builtin-tar-tree.o
635 BUILTIN_OBJS += builtin-unpack-objects.o
636 BUILTIN_OBJS += builtin-update-index.o
637 BUILTIN_OBJS += builtin-update-ref.o
638 +BUILTIN_OBJS += builtin-update-server-info.o
639 BUILTIN_OBJS += builtin-upload-archive.o
640 BUILTIN_OBJS += builtin-verify-pack.o
641 BUILTIN_OBJS += builtin-verify-tag.o
builtin-update-server-info.c new
+25
@@ -0,0 +1,25 @@
1 +#include "cache.h"
2 +#include "builtin.h"
3 +#include "parse-options.h"
4 +
5 +static const char * const update_server_info_usage[] = {
6 + "git update-server-info [--force]",
7 + NULL
8 +};
9 +
10 +int cmd_update_server_info(int argc, const char **argv, const char *prefix)
11 +{
12 + int force = 0;
13 + struct option options[] = {
14 + OPT_BOOLEAN('f', "force", &force,
15 + "update the info files from scratch"),
16 + OPT_END()
17 + };
18 +
19 + argc = parse_options(argc, argv, prefix, options,
20 + update_server_info_usage, 0);
21 + if (argc > 0)
22 + usage_with_options(update_server_info_usage, options);
23 +
24 + return !!update_server_info(force);
25 +}
builtin.h
+1
@@ -102,6 +102,7 @@ extern int cmd_tar_tree(int argc, const char **argv, const char *prefix);
102 extern int cmd_unpack_objects(int argc, const char **argv, const char *prefix);
103 extern int cmd_update_index(int argc, const char **argv, const char *prefix);
104 extern int cmd_update_ref(int argc, const char **argv, const char *prefix);
105 +extern int cmd_update_server_info(int argc, const char **argv, const char *prefix);
106 extern int cmd_upload_archive(int argc, const char **argv, const char *prefix);
107 extern int cmd_upload_tar(int argc, const char **argv, const char *prefix);
108 extern int cmd_verify_tag(int argc, const char **argv, const char *prefix);
git.c
+1
@@ -359,6 +359,7 @@ static void handle_internal_command(int argc, const char **argv)
359 { "unpack-objects", cmd_unpack_objects, RUN_SETUP },
360 { "update-index", cmd_update_index, RUN_SETUP },
361 { "update-ref", cmd_update_ref, RUN_SETUP },
362 + { "update-server-info", cmd_update_server_info, RUN_SETUP },
363 { "upload-archive", cmd_upload_archive },
364 { "verify-tag", cmd_verify_tag, RUN_SETUP },
365 { "version", cmd_version },
update-server-info.c deleted
-28
@@ -1,28 +0,0 @@
1 -#include "cache.h"
2 -#include "exec_cmd.h"
3 -
4 -static const char update_server_info_usage[] =
5 -"git update-server-info [--force]";
6 -
7 -int main(int ac, char **av)
8 -{
9 - int i;
10 - int force = 0;
11 - for (i = 1; i < ac; i++) {
12 - if (av[i][0] == '-') {
13 - if (!strcmp("--force", av[i]) ||
14 - !strcmp("-f", av[i]))
15 - force = 1;
16 - else
17 - usage(update_server_info_usage);
18 - }
19 - }
20 - if (i != ac)
21 - usage(update_server_info_usage);
22 -
23 - git_extract_argv0_path(av[0]);
24 -
25 - setup_git_directory();
26 -
27 - return !!update_server_info(force);
28 -}