From: Junio C Hamano Date: Tue, 29 Nov 2016 21:28:02 +0000 (-0800) Subject: Merge branch 'jk/create-branch-remove-unused-param' into maint X-Git-Tag: v2.10.3~5 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/af8d6a9821d79f18c8b645582b5b5d251066ae2f?ds=inline;hp=-c Merge branch 'jk/create-branch-remove-unused-param' into maint Code clean-up. * jk/create-branch-remove-unused-param: create_branch: drop unused "head" parameter --- af8d6a9821d79f18c8b645582b5b5d251066ae2f diff --combined builtin/branch.c index 7df05437f1,6c3b570cf7..6810c3ac44 --- a/builtin/branch.c +++ b/builtin/branch.c @@@ -212,7 -212,7 +212,7 @@@ static int delete_branches(int argc, co die(_("Couldn't look up commit object for HEAD")); } for (i = 0; i < argc; i++, strbuf_release(&bname)) { - const char *target; + char *target = NULL; int flags = 0; strbuf_branchname(&bname, argv[i]); @@@ -231,11 -231,11 +231,11 @@@ } } - target = resolve_ref_unsafe(name, - RESOLVE_REF_READING - | RESOLVE_REF_NO_RECURSE - | RESOLVE_REF_ALLOW_BAD_NAME, - sha1, &flags); + target = resolve_refdup(name, + RESOLVE_REF_READING + | RESOLVE_REF_NO_RECURSE + | RESOLVE_REF_ALLOW_BAD_NAME, + sha1, &flags); if (!target) { error(remote_branch ? _("remote-tracking branch '%s' not found.") @@@ -248,7 -248,7 +248,7 @@@ check_branch_commit(bname.buf, name, sha1, head_rev, kinds, force)) { ret = 1; - continue; + goto next; } if (delete_ref(name, is_null_sha1(sha1) ? NULL : sha1, @@@ -258,7 -258,7 +258,7 @@@ : _("Error deleting branch '%s'"), bname.buf); ret = 1; - continue; + goto next; } if (!quiet) { printf(remote_branch @@@ -270,9 -270,6 +270,9 @@@ : find_unique_abbrev(sha1, DEFAULT_ABBREV)); } delete_branch_config(bname.buf); + + next: + free(target); } free(name); @@@ -617,11 -614,14 +617,11 @@@ static int edit_branch_description(cons if (!buf.len || buf.buf[buf.len-1] != '\n') strbuf_addch(&buf, '\n'); strbuf_commented_addf(&buf, - "Please edit the description for the branch\n" - " %s\n" - "Lines starting with '%c' will be stripped.\n", + _("Please edit the description for the branch\n" + " %s\n" + "Lines starting with '%c' will be stripped.\n"), branch_name, comment_line_char); - if (write_file_gently(git_path(edit_description), "%s", buf.buf)) { - strbuf_release(&buf); - return error_errno(_("could not write branch description template")); - } + write_file_buf(git_path(edit_description), buf.buf, buf.len); strbuf_reset(&buf); if (launch_editor(git_path(edit_description), &buf, NULL)) { strbuf_release(&buf); @@@ -807,7 -807,7 +807,7 @@@ int cmd_branch(int argc, const char **a * create_branch takes care of setting up the tracking * info and making sure new_upstream is correct */ - create_branch(head, branch->name, new_upstream, 0, 0, 0, quiet, BRANCH_TRACK_OVERRIDE); + create_branch(branch->name, new_upstream, 0, 0, 0, quiet, BRANCH_TRACK_OVERRIDE); } else if (unset_upstream) { struct branch *branch = branch_get(argv[0]); struct strbuf buf = STRBUF_INIT; @@@ -853,7 -853,7 +853,7 @@@ strbuf_release(&buf); branch_existed = ref_exists(branch->refname); - create_branch(head, argv[0], (argc == 2) ? argv[1] : head, + create_branch(argv[0], (argc == 2) ? argv[1] : head, force, reflog, 0, quiet, track); /* diff --combined builtin/checkout.c index 32cf317ec2,d561f7491d..899bd8db0b --- a/builtin/checkout.c +++ b/builtin/checkout.c @@@ -154,8 -154,8 +154,8 @@@ static int check_stages(unsigned stages return 0; } -static int checkout_stage(int stage, struct cache_entry *ce, int pos, - struct checkout *state) +static int checkout_stage(int stage, const struct cache_entry *ce, int pos, + const struct checkout *state) { while (pos < active_nr && !strcmp(active_cache[pos]->name, ce->name)) { @@@ -169,7 -169,7 +169,7 @@@ return error(_("path '%s' does not have their version"), ce->name); } -static int checkout_merged(int pos, struct checkout *state) +static int checkout_merged(int pos, const struct checkout *state) { struct cache_entry *ce = active_cache[pos]; const char *path = ce->name; @@@ -276,7 -276,7 +276,7 @@@ static int checkout_paths(const struct hold_locked_index(lock_file, 1); if (read_cache_preload(&opts->pathspec) < 0) - return error(_("corrupt index file")); + return error(_("index file corrupt")); if (opts->source_tree) read_tree_some(opts->source_tree, &opts->pathspec); @@@ -470,7 -470,7 +470,7 @@@ static int merge_working_tree(const str hold_locked_index(lock_file, 1); if (read_cache_preload(NULL) < 0) - return error(_("corrupt index file")); + return error(_("index file corrupt")); resolve_undo_clear(); if (opts->force) { @@@ -548,7 -548,7 +548,7 @@@ * entries in the index. */ - add_files_to_cache(NULL, NULL, 0, 0); + add_files_to_cache(NULL, NULL, 0); /* * NEEDSWORK: carrying over local changes * when branches have different end-of-line @@@ -567,13 -567,10 +567,13 @@@ o.ancestor = old->name; o.branch1 = new->name; o.branch2 = "local"; - merge_trees(&o, new->commit->tree, work, + ret = merge_trees(&o, new->commit->tree, work, old->commit->tree, &result); + if (ret < 0) + exit(128); ret = reset_tree(new->commit->tree, opts, 0, writeout_error); + strbuf_release(&o.obuf); if (ret) return ret; } @@@ -631,7 -628,7 +631,7 @@@ static void update_refs_for_switch(cons } } else - create_branch(old->name, opts->new_branch, new->name, + create_branch(opts->new_branch, new->name, opts->new_branch_force ? 1 : 0, opts->new_branch_log, opts->new_branch_force ? 1 : 0, @@@ -985,7 -982,7 +985,7 @@@ static int parse_branchname_arg(int arg int recover_with_dwim = dwim_new_local_branch_ok; if (!has_dash_dash && - (check_filename(NULL, arg) || !no_wildcard(arg))) + (check_filename(opts->prefix, arg) || !no_wildcard(arg))) recover_with_dwim = 0; /* * Accept "git checkout foo" and "git checkout foo --" @@@ -1038,7 -1035,7 +1038,7 @@@ if (!*source_tree) /* case (1): want a tree */ die(_("reference is not a tree: %s"), arg); - if (!has_dash_dash) {/* case (3).(d) -> (1) */ + if (!has_dash_dash) { /* case (3).(d) -> (1) */ /* * Do not complain the most common case * git checkout branch @@@ -1046,7 -1043,7 +1046,7 @@@ * it would be extremely annoying. */ if (argc) - verify_non_filename(NULL, arg); + verify_non_filename(opts->prefix, arg); } else { argcount++; argv++; @@@ -1141,7 -1138,7 +1141,7 @@@ int cmd_checkout(int argc, const char * OPT_STRING('B', NULL, &opts.new_branch_force, N_("branch"), N_("create/reset and checkout a branch")), OPT_BOOL('l', NULL, &opts.new_branch_log, N_("create reflog for new branch")), - OPT_BOOL(0, "detach", &opts.force_detach, N_("detach the HEAD at named commit")), + OPT_BOOL(0, "detach", &opts.force_detach, N_("detach HEAD at named commit")), OPT_SET_INT('t', "track", &opts.track, N_("set upstream info for new branch"), BRANCH_TRACK_EXPLICIT), OPT_STRING(0, "orphan", &opts.new_orphan_branch, N_("new-branch"), N_("new unparented branch")),