From: Junio C Hamano Date: Mon, 26 Oct 2015 22:55:18 +0000 (-0700) Subject: Merge branch 'rt/placeholder-in-usage' X-Git-Tag: v2.7.0-rc0~79 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/0884726b43e356d5710db3d516c788fd0b95a57c?hp=-c Merge branch 'rt/placeholder-in-usage' A couple of commands still showed "[options]" in their usage string to note where options should come on their command line, but we spell that "[]" in most places these days. * rt/placeholder-in-usage: am, credential-cache: add angle brackets to usage string --- 0884726b43e356d5710db3d516c788fd0b95a57c diff --combined builtin/am.c index 6c8bbca226,98992cd013..fc6d3d21aa --- a/builtin/am.c +++ b/builtin/am.c @@@ -1589,38 -1589,6 +1589,38 @@@ static int build_fake_ancestor(const st return 0; } +/** + * Do the three-way merge using fake ancestor, his tree constructed + * from the fake ancestor and the postimage of the patch, and our + * state. + */ +static int run_fallback_merge_recursive(const struct am_state *state, + unsigned char *orig_tree, + unsigned char *our_tree, + unsigned char *his_tree) +{ + struct child_process cp = CHILD_PROCESS_INIT; + int status; + + cp.git_cmd = 1; + + argv_array_pushf(&cp.env_array, "GITHEAD_%s=%.*s", + sha1_to_hex(his_tree), linelen(state->msg), state->msg); + if (state->quiet) + argv_array_push(&cp.env_array, "GIT_MERGE_VERBOSITY=0"); + + argv_array_push(&cp.args, "merge-recursive"); + argv_array_push(&cp.args, sha1_to_hex(orig_tree)); + argv_array_push(&cp.args, "--"); + argv_array_push(&cp.args, sha1_to_hex(our_tree)); + argv_array_push(&cp.args, sha1_to_hex(his_tree)); + + status = run_command(&cp) ? (-1) : 0; + discard_cache(); + read_cache(); + return status; +} + /** * Attempt a threeway merge, using index_path as the temporary index. */ @@@ -1628,6 -1596,10 +1628,6 @@@ static int fall_back_threeway(const str { unsigned char orig_tree[GIT_SHA1_RAWSZ], his_tree[GIT_SHA1_RAWSZ], our_tree[GIT_SHA1_RAWSZ]; - const unsigned char *bases[1] = {orig_tree}; - struct merge_options o; - struct commit *result; - char *his_tree_name; if (get_sha1("HEAD", our_tree) < 0) hashcpy(our_tree, EMPTY_TREE_SHA1_BIN); @@@ -1679,11 -1651,22 +1679,11 @@@ * changes. */ - init_merge_options(&o); - - o.branch1 = "HEAD"; - his_tree_name = xstrfmt("%.*s", linelen(state->msg), state->msg); - o.branch2 = his_tree_name; - - if (state->quiet) - o.verbosity = 0; - - if (merge_recursive_generic(&o, our_tree, his_tree, 1, bases, &result)) { + if (run_fallback_merge_recursive(state, orig_tree, our_tree, his_tree)) { rerere(state->allow_rerere_autoupdate); - free(his_tree_name); return error(_("Failed to merge in the changes.")); } - free(his_tree_name); return 0; } @@@ -2225,17 -2208,6 +2225,17 @@@ enum resume_mode RESUME_ABORT }; +static int git_am_config(const char *k, const char *v, void *cb) +{ + int status; + + status = git_gpg_config(k, v, NULL); + if (status) + return status; + + return git_default_config(k, v, NULL); +} + int cmd_am(int argc, const char **argv, const char *prefix) { struct am_state state; @@@ -2246,8 -2218,8 +2246,8 @@@ int in_progress; const char * const usage[] = { - N_("git am [options] [(|)...]"), - N_("git am [options] (--continue | --skip | --abort)"), + N_("git am [] [(|)...]"), + N_("git am [] (--continue | --skip | --abort)"), NULL }; @@@ -2336,7 -2308,7 +2336,7 @@@ OPT_END() }; - git_config(git_default_config, NULL); + git_config(git_am_config, NULL); am_state_init(&state, git_path("rebase-apply"));