diff --git a/attr.c b/attr.c index 8250b06953..42ad6de8c7 100644 --- a/attr.c +++ b/attr.c @@ -23,10 +23,6 @@ static const char git_attr__unknown[] = "(builtin)unknown"; #define ATTR__UNSET NULL #define ATTR__UNKNOWN git_attr__unknown -#ifndef DEBUG_ATTR -#define DEBUG_ATTR 0 -#endif - struct git_attr { int attr_nr; /* unique attribute number */ char name[FLEX_ARRAY]; /* attribute name */ @@ -807,33 +803,6 @@ static struct attr_stack *read_attr(struct index_state *istate, return res; } -#if DEBUG_ATTR -static void debug_info(const char *what, struct attr_stack *elem) -{ - fprintf(stderr, "%s: %s\n", what, elem->origin ? elem->origin : "()"); -} -static void debug_set(const char *what, const char *match, struct git_attr *attr, const void *v) -{ - const char *value = v; - - if (ATTR_TRUE(value)) - value = "set"; - else if (ATTR_FALSE(value)) - value = "unset"; - else if (ATTR_UNSET(value)) - value = "unspecified"; - - fprintf(stderr, "%s: %s => %s (%s)\n", - what, attr->name, (char *) value, match); -} -#define debug_push(a) debug_info("push", (a)) -#define debug_pop(a) debug_info("pop", (a)) -#else -#define debug_push(a) do { ; } while (0) -#define debug_pop(a) do { ; } while (0) -#define debug_set(a,b,c,d) do { ; } while (0) -#endif /* DEBUG_ATTR */ - static const char *git_etc_gitattributes(void) { static const char *system_wide; @@ -954,7 +923,6 @@ static void prepare_attr_stack(struct index_state *istate, (!namelen || path[namelen] == '/')) break; - debug_pop(elem); *stack = elem->prev; attr_stack_free(elem); } @@ -1028,7 +996,7 @@ static int path_matches(const char *pathname, int pathlen, static int macroexpand_one(struct all_attrs_item *all_attrs, int nr, int rem); -static int fill_one(const char *what, struct all_attrs_item *all_attrs, +static int fill_one(struct all_attrs_item *all_attrs, const struct match_attr *a, int rem) { int i; @@ -1039,9 +1007,6 @@ static int fill_one(const char *what, struct all_attrs_item *all_attrs, const char *v = a->state[i].setto; if (*n == ATTR__UNKNOWN) { - debug_set(what, - a->is_macro ? a->u.attr->name : a->u.pat.pattern, - attr, v); *n = v; rem--; rem = macroexpand_one(all_attrs, attr->attr_nr, rem); @@ -1064,7 +1029,7 @@ static int fill(const char *path, int pathlen, int basename_offset, continue; if (path_matches(path, pathlen, basename_offset, &a->u.pat, base, stack->originlen)) - rem = fill_one("fill", all_attrs, a, rem); + rem = fill_one(all_attrs, a, rem); } } @@ -1076,7 +1041,7 @@ static int macroexpand_one(struct all_attrs_item *all_attrs, int nr, int rem) const struct all_attrs_item *item = &all_attrs[nr]; if (item->macro && item->value == ATTR__TRUE) - return fill_one("expand", all_attrs, item->macro, rem); + return fill_one(all_attrs, item->macro, rem); else return rem; } diff --git a/builtin/commit.c b/builtin/commit.c index fcf9c85947..d9de4ef008 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -139,7 +139,7 @@ static int opt_pass_trailer(const struct option *opt, const char *arg, int unset { BUG_ON_OPT_NEG(unset); - strvec_pushl(&trailer_args, "--trailer", arg, NULL); + strvec_pushl(opt->value, "--trailer", arg, NULL); return 0; } @@ -1633,7 +1633,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix) OPT_STRING(0, "fixup", &fixup_message, N_("[(amend|reword):]commit"), N_("use autosquash formatted message to fixup or amend/reword specified commit")), OPT_STRING(0, "squash", &squash_message, N_("commit"), N_("use autosquash formatted message to squash specified commit")), OPT_BOOL(0, "reset-author", &renew_authorship, N_("the commit is authored by me now (used with -C/-c/--amend)")), - OPT_CALLBACK_F(0, "trailer", NULL, N_("trailer"), N_("add custom trailer(s)"), PARSE_OPT_NONEG, opt_pass_trailer), + OPT_CALLBACK_F(0, "trailer", &trailer_args, N_("trailer"), N_("add custom trailer(s)"), PARSE_OPT_NONEG, opt_pass_trailer), OPT_BOOL('s', "signoff", &signoff, N_("add a Signed-off-by trailer")), OPT_FILENAME('t', "template", &template_file, N_("use specified template file")), OPT_BOOL('e', "edit", &edit_flag, N_("force edit of commit")), diff --git a/builtin/multi-pack-index.c b/builtin/multi-pack-index.c index 9b126d6ce0..9a18a82b05 100644 --- a/builtin/multi-pack-index.c +++ b/builtin/multi-pack-index.c @@ -56,11 +56,12 @@ static struct opts_multi_pack_index { static int parse_object_dir(const struct option *opt, const char *arg, int unset) { - free(opts.object_dir); + char **value = opt->value; + free(*value); if (unset) - opts.object_dir = xstrdup(get_object_directory()); + *value = xstrdup(get_object_directory()); else - opts.object_dir = real_pathdup(arg, 1); + *value = real_pathdup(arg, 1); return 0; } diff --git a/t/helper/test-submodule.c b/t/helper/test-submodule.c index e0e0c53d38..b7d117cd55 100644 --- a/t/helper/test-submodule.c +++ b/t/helper/test-submodule.c @@ -85,10 +85,17 @@ static int cmd__submodule_is_active(int argc, const char **argv) return !is_submodule_active(the_repository, argv[0]); } -static int resolve_relative_url(int argc, const char **argv) +static int cmd__submodule_resolve_relative_url(int argc, const char **argv) { char *remoteurl, *res; const char *up_path, *url; + struct option options[] = { + OPT_END() + }; + argc = parse_options(argc, argv, "test-tools", options, + submodule_resolve_relative_url_usage, 0); + if (argc != 3) + usage_with_options(submodule_resolve_relative_url_usage, options); up_path = argv[0]; remoteurl = xstrdup(argv[1]); @@ -104,19 +111,6 @@ static int resolve_relative_url(int argc, const char **argv) return 0; } -static int cmd__submodule_resolve_relative_url(int argc, const char **argv) -{ - struct option options[] = { - OPT_END() - }; - argc = parse_options(argc, argv, "test-tools", options, - submodule_resolve_relative_url_usage, 0); - if (argc != 3) - usage_with_options(submodule_resolve_relative_url_usage, options); - - return resolve_relative_url(argc, argv); -} - static struct test_cmd cmds[] = { { "check-name", cmd__submodule_check_name }, { "is-active", cmd__submodule_is_active },