add an extra level of indirection to main()

There are certain startup tasks that we expect every git process to do. In some cases this is just to improve the quality of the program (e.g., setting up gettext()). In others it is a requirement for using certain functions in libgit.a (e.g., system_path() expects that you have called git_extract_argv0_path()). Most commands are builtins and are covered by the git.c version of main(). However, there are still a few external commands that use their own main(). Each of these has to remember to include the correct startup sequence, and we are not always consistent. Rather than just fix the inconsistencies, let's make this harder to get wrong by providing a common main() that can run this standard startup. We basically have two options to do this: - the compat/mingw.h file already does something like this by adding a #define that replaces the definition of main with a wrapper that calls mingw_startup(). The upside is that the code in each program doesn't need to be changed at all; it's rewritten on the fly by the preprocessor. The downside is that it may make debugging of the startup sequence a bit more confusing, as the preprocessor is quietly inserting new code. - the builtin functions are all of the form cmd_foo(), and git.c's main() calls them. This is much more explicit, which may make things more obvious to somebody reading the code. It's also more flexible (because of course we have to figure out _which_ cmd_foo() to call). The downside is that each of the builtins must define cmd_foo(), instead of just main(). This patch chooses the latter option, preferring the more explicit approach, even though it is more invasive. We introduce a new file common-main.c, with the "real" main. It expects to call cmd_main() from whatever other objects it is linked against. We link common-main.o against anything that links against libgit.a, since we know that such programs will need to do this setup. Note that common-main.o can't actually go inside libgit.a, as the linker would not pick up its main() function automatically (it has no callers). The rest of the patch is just adjusting all of the various external programs (mostly in t/helper) to use cmd_main(). I've provided a global declaration for cmd_main(), which means that all of the programs also need to match its signature. In particular, many functions need to switch to "const char **" instead of "char **" for argv. This effect ripples out to a few other variables and functions, as well. This makes the patch even more invasive, but the end result is much better. We should be treating argv strings as const anyway, and now all programs conform to the same signature (which also matches the way builtins are defined). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Jul 1, 2016 at 01:58 UTC 3f2e2297b9c88a6ab5fc4bff02cf2a07ce057589
52 files changed +91 -69
Makefile
+13 -4
@@ -943,7 +943,7 @@ BUILTIN_OBJS += builtin/verify-tag.o
943 BUILTIN_OBJS += builtin/worktree.o
944 BUILTIN_OBJS += builtin/write-tree.o
945
946 -GITLIBS = $(LIB_FILE) $(XDIFF_LIB)
946 +GITLIBS = common-main.o $(LIB_FILE) $(XDIFF_LIB)
947 EXTLIBS =
948
949 GIT_USER_AGENT = git/$(GIT_VERSION)
@@ -1572,7 +1572,15 @@ TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH))
1572 DIFF_SQ = $(subst ','\'',$(DIFF))
1573 PERLLIB_EXTRA_SQ = $(subst ','\'',$(PERLLIB_EXTRA))
1574
1575 -LIBS = $(GITLIBS) $(EXTLIBS)
1575 +# We must filter out any object files from $(GITLIBS),
1576 +# as it is typically used like:
1577 +#
1578 +# foo: foo.o $(GITLIBS)
1579 +# $(CC) $(filter %.o,$^) $(LIBS)
1580 +#
1581 +# where we use it as a dependency. Since we also pull object files
1582 +# from the dependency list, that would make each entry appear twice.
1583 +LIBS = $(filter-out %.o, $(GITLIBS)) $(EXTLIBS)
1584
1585 BASIC_CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER_SQ)' \
1586 $(COMPAT_CFLAGS)
@@ -1708,8 +1716,8 @@ git.sp git.s git.o: EXTRA_CPPFLAGS = \
1716 '-DGIT_INFO_PATH="$(infodir_relative_SQ)"'
1717
1718 git$X: git.o GIT-LDFLAGS $(BUILTIN_OBJS) $(GITLIBS)
1711 - $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) git.o \
1712 - $(BUILTIN_OBJS) $(LIBS)
1719 + $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) \
1720 + $(filter %.o,$^) $(LIBS)
1721
1722 help.sp help.s help.o: common-cmds.h
1723
@@ -1902,6 +1910,7 @@ TEST_OBJS := $(patsubst test-%$X,test-%.o,$(TEST_PROGRAMS))
1910 OBJECTS := $(LIB_OBJS) $(BUILTIN_OBJS) $(PROGRAM_OBJS) $(TEST_OBJS) \
1911 $(XDIFF_OBJS) \
1912 $(VCSSVN_OBJS) \
1913 + common-main.o \
1914 git.o
1915 ifndef NO_CURL
1916 OBJECTS += http.o http-walker.o remote-curl.o
common-main.c new
+12
@@ -0,0 +1,12 @@
1 +#include "git-compat-util.h"
2 +
3 +int main(int argc, char **av)
4 +{
5 + /*
6 + * This const trickery is explained in
7 + * 84d32bf7678259c08406571cd6ce4b7a6724dcba
8 + */
9 + const char **argv = (const char **)av;
10 +
11 + return cmd_main(argc, argv);
12 +}
credential-cache--daemon.c
+1 -1
@@ -257,7 +257,7 @@ static void init_socket_directory(const char *path)
257 free(path_copy);
258 }
259
260 -int main(int argc, const char **argv)
260 +int cmd_main(int argc, const char **argv)
261 {
262 const char *socket_path;
263 int ignore_sighup = 0;
credential-cache.c
+1 -1
@@ -83,7 +83,7 @@ static void do_cache(const char *socket, const char *action, int timeout,
83 strbuf_release(&buf);
84 }
85
86 -int main(int argc, const char **argv)
86 +int cmd_main(int argc, const char **argv)
87 {
88 char *socket_path = NULL;
89 int timeout = 900;
credential-store.c
+1 -1
@@ -142,7 +142,7 @@ static void lookup_credential(const struct string_list *fns, struct credential *
142 return; /* Found credential */
143 }
144
145 -int main(int argc, char **argv)
145 +int cmd_main(int argc, const char **argv)
146 {
147 const char * const usage[] = {
148 "git credential-store [<options>] <action>",
daemon.c
+4 -4
@@ -32,7 +32,7 @@ static const char daemon_usage[] =
32 " [<directory>...]";
33
34 /* List of acceptable pathname prefixes */
35 -static char **ok_paths;
35 +static const char **ok_paths;
36 static int strict_paths;
37
38 /* If this is set, git-daemon-export-ok is not required */
@@ -240,7 +240,7 @@ static const char *path_ok(const char *directory, struct hostinfo *hi)
240 }
241
242 if ( ok_paths && *ok_paths ) {
243 - char **pp;
243 + const char **pp;
244 int pathlen = strlen(path);
245
246 /* The validation is done on the paths after enter_repo
@@ -1178,7 +1178,7 @@ static int serve(struct string_list *listen_addr, int listen_port,
1178 return service_loop(&socklist);
1179 }
1180
1181 -int main(int argc, char **argv)
1181 +int cmd_main(int argc, const char **argv)
1182 {
1183 int listen_port = 0;
1184 struct string_list listen_addr = STRING_LIST_INIT_NODUP;
@@ -1193,7 +1193,7 @@ int main(int argc, char **argv)
1193 git_extract_argv0_path(argv[0]);
1194
1195 for (i = 1; i < argc; i++) {
1196 - char *arg = argv[i];
1196 + const char *arg = argv[i];
1197 const char *v;
1198
1199 if (skip_prefix(arg, "--listen=", &v)) {
fast-import.c
+2 -2
@@ -300,7 +300,7 @@ static int failure;
300 static FILE *pack_edges;
301 static unsigned int show_stats = 1;
302 static int global_argc;
303 -static char **global_argv;
303 +static const char **global_argv;
304
305 /* Memory pools */
306 static size_t mem_pool_alloc = 2*1024*1024 - sizeof(struct mem_pool);
@@ -3381,7 +3381,7 @@ static void parse_argv(void)
3381 read_marks();
3382 }
3383
3384 -int main(int argc, char **argv)
3384 +int cmd_main(int argc, const char **argv)
3385 {
3386 unsigned int i;
3387
git-compat-util.h
+2
@@ -1043,3 +1043,5 @@ struct tm *git_gmtime_r(const time_t *, struct tm *);
1043 #endif
1044
1045 #endif
1046 +
1047 +extern int cmd_main(int, const char **);
git.c
+1 -2
@@ -630,9 +630,8 @@ static void restore_sigpipe_to_default(void)
630 signal(SIGPIPE, SIG_DFL);
631 }
632
633 -int main(int argc, char **av)
633 +int cmd_main(int argc, const char **argv)
634 {
635 - const char **argv = (const char **) av;
635 const char *cmd;
636 int done_help = 0;
637
http-backend.c
+1 -1
@@ -632,7 +632,7 @@ static struct service_cmd {
632 {"POST", "/git-receive-pack$", service_rpc}
633 };
634
635 -int main(int argc, char **argv)
635 +int cmd_main(int argc, const char **argv)
636 {
637 char *method = getenv("REQUEST_METHOD");
638 char *dir;
http-fetch.c
+1 -1
@@ -6,7 +6,7 @@
6 static const char http_fetch_usage[] = "git http-fetch "
7 "[-c] [-t] [-a] [-v] [--recover] [-w ref] [--stdin] commit-id url";
8
9 -int main(int argc, const char **argv)
9 +int cmd_main(int argc, const char **argv)
10 {
11 struct walker *walker;
12 int commits_on_stdin = 0;
http-push.c
+3 -3
@@ -1692,12 +1692,12 @@ static void run_request_queue(void)
1692 #endif
1693 }
1694
1695 -int main(int argc, char **argv)
1695 +int cmd_main(int argc, const char **argv)
1696 {
1697 struct transfer_request *request;
1698 struct transfer_request *next_request;
1699 int nr_refspec = 0;
1700 - char **refspec = NULL;
1700 + const char **refspec = NULL;
1701 struct remote_lock *ref_lock = NULL;
1702 struct remote_lock *info_ref_lock = NULL;
1703 struct rev_info revs;
@@ -1717,7 +1717,7 @@ int main(int argc, char **argv)
1717
1718 argv++;
1719 for (i = 1; i < argc; i++, argv++) {
1720 - char *arg = *argv;
1720 + const char *arg = *argv;
1721
1722 if (*arg == '-') {
1723 if (!strcmp(arg, "--all")) {
imap-send.c
+1 -1
@@ -1494,7 +1494,7 @@ static int curl_append_msgs_to_imap(struct imap_server_conf *server,
1494 }
1495 #endif
1496
1497 -int main(int argc, char **argv)
1497 +int cmd_main(int argc, const char **argv)
1498 {
1499 struct strbuf all_msgs = STRBUF_INIT;
1500 int total;
remote-curl.c
+1 -1
@@ -984,7 +984,7 @@ static void parse_push(struct strbuf *buf)
984 free(specs);
985 }
986
987 -int main(int argc, const char **argv)
987 +int cmd_main(int argc, const char **argv)
988 {
989 struct strbuf buf = STRBUF_INIT;
990 int nongit;
remote-testsvn.c
+1 -1
@@ -284,7 +284,7 @@ static int do_command(struct strbuf *line)
284 return 0;
285 }
286
287 -int main(int argc, char **argv)
287 +int cmd_main(int argc, const char **argv)
288 {
289 struct strbuf buf = STRBUF_INIT, url_sb = STRBUF_INIT,
290 private_ref_sb = STRBUF_INIT, marksfilename_sb = STRBUF_INIT,
sh-i18n--envsubst.c
+1 -1
@@ -64,7 +64,7 @@ static void note_variables (const char *string);
64 static void subst_from_stdin (void);
65
66 int
67 -main (int argc, char *argv[])
67 +cmd_main (int argc, const char *argv[])
68 {
69 /* Default values for command line options. */
70 /* unsigned short int show_variables = 0; */
shell.c
+1 -1
@@ -138,7 +138,7 @@ static struct commands {
138 { NULL },
139 };
140
141 -int main(int argc, char **argv)
141 +int cmd_main(int argc, const char **argv)
142 {
143 char *prog;
144 const char **user_argv;
show-index.c
+1 -1
@@ -4,7 +4,7 @@
4 static const char show_index_usage[] =
5 "git show-index";
6
7 -int main(int argc, char **argv)
7 +int cmd_main(int argc, const char **argv)
8 {
9 int i;
10 unsigned nr;
test-chmtime.c
+1 -1
@@ -56,7 +56,7 @@ static int timespec_arg(const char *arg, long int *set_time, int *set_eq)
56 return 1;
57 }
58
59 -int main(int argc, char *argv[])
59 +int cmd_main(int argc, const char **argv)
60 {
61 static int verbose;
62
test-config.c
+1 -1
@@ -33,7 +33,7 @@
33 */
34
35
36 -int main(int argc, char **argv)
36 +int cmd_main(int argc, const char **argv)
37 {
38 int i, val;
39 const char *v;
test-ctype.c
+1 -1
@@ -28,7 +28,7 @@ static int is_in(const char *s, int ch)
28 #define LOWER "abcdefghijklmnopqrstuvwxyz"
29 #define UPPER "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
30
31 -int main(int argc, char **argv)
31 +int cmd_main(int argc, const char **argv)
32 {
33 TEST_CLASS(isdigit, DIGIT);
34 TEST_CLASS(isspace, " \n\r\t");
test-date.c
+4 -4
@@ -5,7 +5,7 @@ static const char *usage_msg = "\n"
5 " test-date parse [date]...\n"
6 " test-date approxidate [date]...\n";
7
8 -static void show_dates(char **argv, struct timeval *now)
8 +static void show_dates(const char **argv, struct timeval *now)
9 {
10 struct strbuf buf = STRBUF_INIT;
11
@@ -17,7 +17,7 @@ static void show_dates(char **argv, struct timeval *now)
17 strbuf_release(&buf);
18 }
19
20 -static void parse_dates(char **argv, struct timeval *now)
20 +static void parse_dates(const char **argv, struct timeval *now)
21 {
22 struct strbuf result = STRBUF_INIT;
23
@@ -36,7 +36,7 @@ static void parse_dates(char **argv, struct timeval *now)
36 strbuf_release(&result);
37 }
38
39 -static void parse_approxidate(char **argv, struct timeval *now)
39 +static void parse_approxidate(const char **argv, struct timeval *now)
40 {
41 for (; *argv; argv++) {
42 time_t t;
@@ -45,7 +45,7 @@ static void parse_approxidate(char **argv, struct timeval *now)
45 }
46 }
47
48 -int main(int argc, char **argv)
48 +int cmd_main(int argc, const char **argv)
49 {
50 struct timeval now;
51 const char *x;
test-delta.c
+1 -1
@@ -15,7 +15,7 @@
15 static const char usage_str[] =
16 "test-delta (-d|-p) <from_file> <data_file> <out_file>";
17
18 -int main(int argc, char *argv[])
18 +int cmd_main(int argc, const char **argv)
19 {
20 int fd;
21 struct stat st;
test-dump-cache-tree.c
+1 -1
@@ -54,7 +54,7 @@ static int dump_cache_tree(struct cache_tree *it,
54 return errs;
55 }
56
57 -int main(int ac, char **av)
57 +int cmd_main(int ac, const char **av)
58 {
59 struct index_state istate;
60 struct cache_tree *another = cache_tree();
test-dump-split-index.c
+1 -1
@@ -7,7 +7,7 @@ static void show_bit(size_t pos, void *data)
7 printf(" %d", (int)pos);
8 }
9
10 -int main(int ac, char **av)
10 +int cmd_main(int ac, const char **av)
11 {
12 struct split_index *si;
13 int i;
test-dump-untracked-cache.c
+1 -1
@@ -40,7 +40,7 @@ static void dump(struct untracked_cache_dir *ucd, struct strbuf *base)
40 strbuf_setlen(base, len);
41 }
42
43 -int main(int ac, char **av)
43 +int cmd_main(int ac, const char **av)
44 {
45 struct untracked_cache *uc;
46 struct strbuf base = STRBUF_INIT;
test-fake-ssh.c
+1 -1
@@ -2,7 +2,7 @@
2 #include "run-command.h"
3 #include "strbuf.h"
4
5 -int main(int argc, char **argv)
5 +int cmd_main(int argc, const char **argv)
6 {
7 const char *trash_directory = getenv("TRASH_DIRECTORY");
8 struct strbuf buf = STRBUF_INIT;
test-genrandom.c
+1 -1
@@ -6,7 +6,7 @@
6
7 #include "git-compat-util.h"
8
9 -int main(int argc, char *argv[])
9 +int cmd_main(int argc, const char **argv)
10 {
11 unsigned long count, next = 0;
12 unsigned char *c;
test-hashmap.c
+1 -1
@@ -138,7 +138,7 @@ static void perf_hashmap(unsigned int method, unsigned int rounds)
138 *
139 * perfhashmap method rounds -> test hashmap.[ch] performance
140 */
141 -int main(int argc, char *argv[])
141 +int cmd_main(int argc, const char **argv)
142 {
143 char line[1024];
144 struct hashmap map;
test-index-version.c
+1 -1
@@ -1,6 +1,6 @@
1 #include "cache.h"
2
3 -int main(int argc, char **argv)
3 +int cmd_main(int argc, const char **argv)
4 {
5 struct cache_header hdr;
6 int version;
test-line-buffer.c
+1 -1
@@ -50,7 +50,7 @@ static void handle_line(const char *line, struct line_buffer *stdin_buf)
50 handle_command(line, arg + 1, stdin_buf);
51 }
52
53 -int main(int argc, char *argv[])
53 +int cmd_main(int argc, const char **argv)
54 {
55 struct line_buffer stdin_buf = LINE_BUFFER_INIT;
56 struct line_buffer file_buf = LINE_BUFFER_INIT;
test-match-trees.c
+1 -1
@@ -1,7 +1,7 @@
1 #include "cache.h"
2 #include "tree.h"
3
4 -int main(int ac, char **av)
4 +int cmd_main(int ac, const char **av)
5 {
6 unsigned char hash1[20], hash2[20], shifted[20];
7 struct tree *one, *two;
test-mergesort.c
+1 -1
@@ -22,7 +22,7 @@ static int compare_strings(const void *a, const void *b)
22 return strcmp(x->text, y->text);
23 }
24
25 -int main(int argc, char **argv)
25 +int cmd_main(int argc, const char **argv)
26 {
27 struct line *line, *p = NULL, *lines = NULL;
28 struct strbuf sb = STRBUF_INIT;
test-mktemp.c
+1 -1
@@ -3,7 +3,7 @@
3 */
4 #include "git-compat-util.h"
5
6 -int main(int argc, char *argv[])
6 +int cmd_main(int argc, const char **argv)
7 {
8 if (argc != 2)
9 usage("Expected 1 parameter defining the temporary file template");
test-parse-options.c
+1 -1
@@ -30,7 +30,7 @@ static int number_callback(const struct option *opt, const char *arg, int unset)
30 return 0;
31 }
32
33 -int main(int argc, char **argv)
33 +int cmd_main(int argc, const char **argv)
34 {
35 const char *prefix = "prefix/";
36 const char *usage[] = {
test-path-utils.c
+2 -2
@@ -156,7 +156,7 @@ static struct test_data dirname_data[] = {
156 { NULL, NULL }
157 };
158
159 -int main(int argc, char **argv)
159 +int cmd_main(int argc, const char **argv)
160 {
161 if (argc == 3 && !strcmp(argv[1], "normalize_path_copy")) {
162 char *buf = xmallocz(strlen(argv[2]));
@@ -213,7 +213,7 @@ int main(int argc, char **argv)
213 }
214
215 if (argc >= 4 && !strcmp(argv[1], "prefix_path")) {
216 - char *prefix = argv[2];
216 + const char *prefix = argv[2];
217 int prefix_len = strlen(prefix);
218 int nongit_ok;
219 setup_git_directory_gently(&nongit_ok);
test-prio-queue.c
+1 -1
@@ -16,7 +16,7 @@ static void show(int *v)
16 free(v);
17 }
18
19 -int main(int argc, char **argv)
19 +int cmd_main(int argc, const char **argv)
20 {
21 struct prio_queue pq = { intcmp };
22
test-read-cache.c
+1 -1
@@ -1,6 +1,6 @@
1 #include "cache.h"
2
3 -int main (int argc, char **argv)
3 +int cmd_main(int argc, const char **argv)
4 {
5 int i, cnt = 1;
6 if (argc == 2)
test-regex.c
+1 -1
@@ -1,6 +1,6 @@
1 #include "git-compat-util.h"
2
3 -int main(int argc, char **argv)
3 +int cmd_main(int argc, const char **argv)
4 {
5 char *pat = "[^={} \t]+";
6 char *str = "={}\nfred";
test-revision-walking.c
+1 -1
@@ -45,7 +45,7 @@ static int run_revision_walk(void)
45 return got_revision;
46 }
47
48 -int main(int argc, char **argv)
48 +int cmd_main(int argc, const char **argv)
49 {
50 if (argc < 2)
51 return 1;
test-run-command.c
+1 -1
@@ -49,7 +49,7 @@ static int task_finished(int result,
49 return 1;
50 }
51
52 -int main(int argc, char **argv)
52 +int cmd_main(int argc, const char **argv)
53 {
54 struct child_process proc = CHILD_PROCESS_INIT;
55 int jobs;
test-scrap-cache-tree.c
+1 -1
@@ -5,7 +5,7 @@
5
6 static struct lock_file index_lock;
7
8 -int main(int ac, char **av)
8 +int cmd_main(int ac, const char **av)
9 {
10 hold_locked_index(&index_lock, 1);
11 if (read_cache() < 0)
test-sha1-array.c
+1 -1
@@ -6,7 +6,7 @@ static void print_sha1(const unsigned char sha1[20], void *data)
6 puts(sha1_to_hex(sha1));
7 }
8
9 -int main(int argc, char **argv)
9 +int cmd_main(int argc, const char **argv)
10 {
11 struct sha1_array array = SHA1_ARRAY_INIT;
12 struct strbuf line = STRBUF_INIT;
test-sha1.c
+1 -1
@@ -1,6 +1,6 @@
1 #include "cache.h"
2
3 -int main(int ac, char **av)
3 +int cmd_main(int ac, const char **av)
4 {
5 git_SHA_CTX ctx;
6 unsigned char sha1[20];
test-sigchain.c
+1 -1
@@ -13,7 +13,7 @@ X(two)
13 X(three)
14 #undef X
15
16 -int main(int argc, char **argv) {
16 +int cmd_main(int argc, const char **argv) {
17 sigchain_push(SIGTERM, one);
18 sigchain_push(SIGTERM, two);
19 sigchain_push(SIGTERM, three);
test-string-list.c
+1 -1
@@ -41,7 +41,7 @@ static int prefix_cb(struct string_list_item *item, void *cb_data)
41 return starts_with(item->string, prefix);
42 }
43
44 -int main(int argc, char **argv)
44 +int cmd_main(int argc, const char **argv)
45 {
46 if (argc == 5 && !strcmp(argv[1], "split")) {
47 struct string_list list = STRING_LIST_INIT_DUP;
test-submodule-config.c
+3 -3
@@ -2,7 +2,7 @@
2 #include "submodule-config.h"
3 #include "submodule.h"
4
5 -static void die_usage(int argc, char **argv, const char *msg)
5 +static void die_usage(int argc, const char **argv, const char *msg)
6 {
7 fprintf(stderr, "%s\n", msg);
8 fprintf(stderr, "Usage: %s [<commit> <submodulepath>] ...\n", argv[0]);
@@ -14,9 +14,9 @@ static int git_test_config(const char *var, const char *value, void *cb)
14 return parse_submodule_config_option(var, value);
15 }
16
17 -int main(int argc, char **argv)
17 +int cmd_main(int argc, const char **argv)
18 {
19 - char **arg = argv;
19 + const char **arg = argv;
20 int my_argc = argc;
21 int output_url = 0;
22 int lookup_name = 0;
test-subprocess.c
+1 -1
@@ -1,7 +1,7 @@
1 #include "cache.h"
2 #include "run-command.h"
3
4 -int main(int argc, char **argv)
4 +int cmd_main(int argc, const char **argv)
5 {
6 struct child_process cp = CHILD_PROCESS_INIT;
7 int nogit = 0;
test-svn-fe.c
+2 -2
@@ -11,7 +11,7 @@
11 static const char test_svnfe_usage[] =
12 "test-svn-fe (<dumpfile> | [-d] <preimage> <delta> <len>)";
13
14 -static int apply_delta(int argc, char *argv[])
14 +static int apply_delta(int argc, const char **argv)
15 {
16 struct line_buffer preimage = LINE_BUFFER_INIT;
17 struct line_buffer delta = LINE_BUFFER_INIT;
@@ -35,7 +35,7 @@ static int apply_delta(int argc, char *argv[])
35 return 0;
36 }
37
38 -int main(int argc, char *argv[])
38 +int cmd_main(int argc, const char **argv)
39 {
40 if (argc == 2) {
41 if (svndump_init(argv[1]))
test-urlmatch-normalization.c
+1 -1
@@ -1,7 +1,7 @@
1 #include "git-compat-util.h"
2 #include "urlmatch.h"
3
4 -int main(int argc, char **argv)
4 +int cmd_main(int argc, const char **argv)
5 {
6 const char usage[] = "test-urlmatch-normalization [-p | -l] <url1> | <url1> <url2>";
7 char *url1, *url2;
test-wildmatch.c
+1 -1
@@ -1,6 +1,6 @@
1 #include "cache.h"
2
3 -int main(int argc, char **argv)
3 +int cmd_main(int argc, const char **argv)
4 {
5 int i;
6 for (i = 2; i < argc; i++) {
upload-pack.c
+3 -3
@@ -817,9 +817,9 @@ static int upload_pack_config(const char *var, const char *value, void *unused)
817 return parse_hide_refs_config(var, value, "uploadpack");
818 }
819
820 -int main(int argc, char **argv)
820 +int cmd_main(int argc, const char **argv)
821 {
822 - char *dir;
822 + const char *dir;
823 int i;
824 int strict = 0;
825
@@ -830,7 +830,7 @@ int main(int argc, char **argv)
830 check_replace_refs = 0;
831
832 for (i = 1; i < argc; i++) {
833 - char *arg = argv[i];
833 + const char *arg = argv[i];
834
835 if (arg[0] != '-')
836 break;