From 9409c7a5b33d6a4d68f58ccb1034fa50c92cac68 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sun, 29 Jul 2012 13:43:21 -0700 Subject: config: "git config baa" should exit with status 1 We instead failed with an undocumented exit status 255. Also define a "catch-all" status and document it. Signed-off-by: Junio C Hamano --- builtin/config.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'builtin') diff --git a/builtin/config.c b/builtin/config.c index 33c8820af..b44277c23 100644 --- a/builtin/config.c +++ b/builtin/config.c @@ -160,7 +160,7 @@ static int show_config(const char *key_, const char *value_, void *cb) static int get_value(const char *key_, const char *regex_) { - int ret = -1; + int ret = CONFIG_GENERIC_ERROR; char *global = NULL, *repo_config = NULL; const char *system_wide = NULL, *local; struct config_include_data inc = CONFIG_INCLUDE_INIT; @@ -198,11 +198,14 @@ static int get_value(const char *key_, const char *regex_) if (regcomp(key_regexp, key, REG_EXTENDED)) { fprintf(stderr, "Invalid key pattern: %s\n", key_); free(key); + ret = CONFIG_INVALID_PATTERN; goto free_strings; } } else { - if (git_config_parse_key(key_, &key, NULL)) + if (git_config_parse_key(key_, &key, NULL)) { + ret = CONFIG_INVALID_KEY; goto free_strings; + } } if (regex_) { @@ -214,6 +217,7 @@ static int get_value(const char *key_, const char *regex_) regexp = (regex_t*)xmalloc(sizeof(regex_t)); if (regcomp(regexp, regex_, REG_EXTENDED)) { fprintf(stderr, "Invalid pattern: %s\n", regex_); + ret = CONFIG_INVALID_PATTERN; goto free_strings; } } -- cgit v1.2.1 From 28452655af988094792483a51d188c58137760cd Mon Sep 17 00:00:00 2001 From: Thomas Rast Date: Fri, 3 Aug 2012 14:16:24 +0200 Subject: diff_setup_done(): return void diff_setup_done() has historically returned an error code, but lost the last nonzero return in 943d5b7 (allow diff.renamelimit to be set regardless of -M/-C, 2006-08-09). The callers were in a pretty confused state: some actually checked for the return code, and some did not. Let it return void, and patch all callers to take this into account. This conveniently also gets rid of a handful of different(!) error messages that could never be triggered anyway. Note that the function can still die(). Signed-off-by: Thomas Rast Signed-off-by: Junio C Hamano --- builtin/blame.c | 9 +++------ builtin/checkout.c | 3 +-- builtin/diff.c | 3 +-- builtin/merge.c | 3 +-- 4 files changed, 6 insertions(+), 12 deletions(-) (limited to 'builtin') diff --git a/builtin/blame.c b/builtin/blame.c index 5a67c202f..c0e26a0b1 100644 --- a/builtin/blame.c +++ b/builtin/blame.c @@ -392,8 +392,7 @@ static struct origin *find_origin(struct scoreboard *sb, paths[1] = NULL; diff_tree_setup_paths(paths, &diff_opts); - if (diff_setup_done(&diff_opts) < 0) - die("diff-setup"); + diff_setup_done(&diff_opts); if (is_null_sha1(origin->commit->object.sha1)) do_diff_cache(parent->tree->object.sha1, &diff_opts); @@ -479,8 +478,7 @@ static struct origin *find_rename(struct scoreboard *sb, diff_opts.single_follow = origin->path; paths[0] = NULL; diff_tree_setup_paths(paths, &diff_opts); - if (diff_setup_done(&diff_opts) < 0) - die("diff-setup"); + diff_setup_done(&diff_opts); if (is_null_sha1(origin->commit->object.sha1)) do_diff_cache(parent->tree->object.sha1, &diff_opts); @@ -1065,8 +1063,7 @@ static int find_copy_in_parent(struct scoreboard *sb, paths[0] = NULL; diff_tree_setup_paths(paths, &diff_opts); - if (diff_setup_done(&diff_opts) < 0) - die("diff-setup"); + diff_setup_done(&diff_opts); /* Try "find copies harder" on new path if requested; * we do not want to use diffcore_rename() actually to diff --git a/builtin/checkout.c b/builtin/checkout.c index a76aa2a6f..fc581d8bb 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -315,8 +315,7 @@ static void show_local_changes(struct object *head, struct diff_options *opts) init_revisions(&rev, NULL); rev.diffopt.flags = opts->flags; rev.diffopt.output_format |= DIFF_FORMAT_NAME_STATUS; - if (diff_setup_done(&rev.diffopt) < 0) - die(_("diff_setup_done failed")); + diff_setup_done(&rev.diffopt); add_pending_object(&rev, head, NULL); run_diff_index(&rev, 0); } diff --git a/builtin/diff.c b/builtin/diff.c index 387afa756..a2c45dbdc 100644 --- a/builtin/diff.c +++ b/builtin/diff.c @@ -294,8 +294,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix) argc = setup_revisions(argc, argv, &rev, NULL); if (!rev.diffopt.output_format) { rev.diffopt.output_format = DIFF_FORMAT_PATCH; - if (diff_setup_done(&rev.diffopt) < 0) - die(_("diff_setup_done failed")); + diff_setup_done(&rev.diffopt); } DIFF_OPT_SET(&rev.diffopt, RECURSIVE); diff --git a/builtin/merge.c b/builtin/merge.c index 5126443fd..99825d63c 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -402,8 +402,7 @@ static void finish(struct commit *head_commit, opts.output_format |= DIFF_FORMAT_SUMMARY | DIFF_FORMAT_DIFFSTAT; opts.detect_rename = DIFF_DETECT_RENAME; - if (diff_setup_done(&opts) < 0) - die(_("diff_setup_done failed")); + diff_setup_done(&opts); diff_tree_sha1(head, new_head, "", &opts); diffcore_std(&opts); diff_flush(&opts); -- cgit v1.2.1 From ee922391864026097a196f97ecb14548ab2bf211 Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Thu, 2 Aug 2012 18:25:30 -0400 Subject: apply: delete unused deflate_origlen from patch struct It hasn't been used since 2006, as of commit 3cd4f5e8 "git-apply --binary: clean up and prepare for --reverse" Signed-off-by: Paul Gortmaker Signed-off-by: Junio C Hamano --- builtin/apply.c | 1 - 1 file changed, 1 deletion(-) (limited to 'builtin') diff --git a/builtin/apply.c b/builtin/apply.c index f2edc5281..74f47486f 100644 --- a/builtin/apply.c +++ b/builtin/apply.c @@ -178,7 +178,6 @@ struct patch { int is_new, is_delete; /* -1 = unknown, 0 = false, 1 = true */ int rejected; unsigned ws_rule; - unsigned long deflate_origlen; int lines_added, lines_deleted; int score; unsigned int is_toplevel_relative:1; -- cgit v1.2.1