From: Junio C Hamano Date: Wed, 6 Jul 2016 17:02:57 +0000 (-0700) Subject: Merge branch 'jk/common-main-2.8' into jk/common-main X-Git-Tag: v2.10.0-rc0~107^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=de61cebde72a15b85b6e6a06ef4c3614b6afdac8;p=thirdparty%2Fgit.git Merge branch 'jk/common-main-2.8' into jk/common-main * jk/common-main-2.8: mingw: declare main()'s argv as const common-main: call git_setup_gettext() common-main: call restore_sigpipe_to_default() common-main: call sanitize_stdfds() common-main: call git_extract_argv0_path() add an extra level of indirection to main() --- de61cebde72a15b85b6e6a06ef4c3614b6afdac8 diff --cc t/helper/test-match-trees.c index d446b8eaca,afcdc143b5..e939502863 --- a/t/helper/test-match-trees.c +++ b/t/helper/test-match-trees.c @@@ -1,9 -1,9 +1,9 @@@ #include "cache.h" #include "tree.h" - int main(int ac, char **av) + int cmd_main(int ac, const char **av) { - unsigned char hash1[20], hash2[20], shifted[20]; + struct object_id hash1, hash2, shifted; struct tree *one, *two; setup_git_directory(); diff --cc t/helper/test-parse-options.c index 8a1235d03e,7adae43b87..d51d29251e --- a/t/helper/test-parse-options.c +++ b/t/helper/test-parse-options.c @@@ -39,62 -30,7 +39,62 @@@ static int number_callback(const struc return 0; } +static int collect_expect(const struct option *opt, const char *arg, int unset) +{ + struct string_list *expect; + struct string_list_item *item; + struct strbuf label = STRBUF_INIT; + const char *colon; + + if (!arg || unset) + die("malformed --expect option"); + + expect = (struct string_list *)opt->value; + colon = strchr(arg, ':'); + if (!colon) + die("malformed --expect option, lacking a colon"); + strbuf_add(&label, arg, colon - arg); + item = string_list_insert(expect, strbuf_detach(&label, NULL)); + if (item->util) + die("malformed --expect option, duplicate %s", label.buf); + item->util = (void *)arg; + return 0; +} + +__attribute__((format (printf,3,4))) +static void show(struct string_list *expect, int *status, const char *fmt, ...) +{ + struct string_list_item *item; + struct strbuf buf = STRBUF_INIT; + va_list args; + + va_start(args, fmt); + strbuf_vaddf(&buf, fmt, args); + va_end(args); + + if (!expect->nr) + printf("%s\n", buf.buf); + else { + char *colon = strchr(buf.buf, ':'); + if (!colon) + die("malformed output format, output lacking colon: %s", fmt); + *colon = '\0'; + item = string_list_lookup(expect, buf.buf); + *colon = ':'; + if (!item) + ; /* not among entries being checked */ + else { + if (strcmp((const char *)item->util, buf.buf)) { + printf("-%s\n", (char *)item->util); + printf("+%s\n", buf.buf); + *status = 1; + } + } + } + strbuf_release(&buf); +} + - int main(int argc, char **argv) + int cmd_main(int argc, const char **argv) { const char *prefix = "prefix/"; const char *usage[] = {