From: Junio C Hamano Date: Fri, 22 May 2015 19:41:41 +0000 (-0700) Subject: Merge branch 'dl/branch-error-message' X-Git-Tag: v2.5.0-rc0~102 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/086d0d4ab6c9f2b6f789a16157c1a3685514efb3?hp=-c Merge branch 'dl/branch-error-message' Error messages from "git branch" called remote-tracking branches as "remote branches". * dl/branch-error-message: branch: do not call a "remote-tracking branch" a "remote branch" --- 086d0d4ab6c9f2b6f789a16157c1a3685514efb3 diff --combined builtin/branch.c index 258fe2ff9b,68ac4c4e9f..9cbab189f5 --- a/builtin/branch.c +++ b/builtin/branch.c @@@ -21,10 -21,10 +21,10 @@@ #include "wt-status.h" static const char * const builtin_branch_usage[] = { - N_("git branch [options] [-r | -a] [--merged | --no-merged]"), - N_("git branch [options] [-l] [-f] []"), - N_("git branch [options] [-r] (-d | -D) ..."), - N_("git branch [options] (-m | -M) [] "), + N_("git branch [] [-r | -a] [--merged | --no-merged]"), + N_("git branch [] [-l] [-f] []"), + N_("git branch [] [-r] (-d | -D) ..."), + N_("git branch [] (-m | -M) [] "), NULL }; @@@ -242,7 -242,7 +242,7 @@@ static int delete_branches(int argc, co sha1, &flags); if (!target) { error(remote_branch - ? _("remote branch '%s' not found.") + ? _("remote-tracking branch '%s' not found.") : _("branch '%s' not found."), bname.buf); ret = 1; continue; @@@ -257,7 -257,7 +257,7 @@@ if (delete_ref(name, sha1, REF_NODEREF)) { error(remote_branch - ? _("Error deleting remote branch '%s'") + ? _("Error deleting remote-tracking branch '%s'") : _("Error deleting branch '%s'"), bname.buf); ret = 1; @@@ -265,7 -265,7 +265,7 @@@ } if (!quiet) { printf(remote_branch - ? _("Deleted remote branch %s (was %s).\n") + ? _("Deleted remote-tracking branch %s (was %s).\n") : _("Deleted branch %s (was %s).\n"), bname.buf, (flags & REF_ISBROKEN) ? "broken" @@@ -589,16 -589,9 +589,16 @@@ static char *get_head_description(void else if (state.bisect_in_progress) strbuf_addf(&desc, _("(no branch, bisect started on %s)"), state.branch); - else if (state.detached_from) - strbuf_addf(&desc, _("(detached from %s)"), - state.detached_from); + else if (state.detached_from) { + /* TRANSLATORS: make sure these match _("HEAD detached at ") + and _("HEAD detached from ") in wt-status.c */ + if (state.detached_at) + strbuf_addf(&desc, _("(HEAD detached at %s)"), + state.detached_from); + else + strbuf_addf(&desc, _("(HEAD detached from %s)"), + state.detached_from); + } else strbuf_addstr(&desc, _("(no branch)")); free(state.branch); @@@ -771,6 -764,7 +771,6 @@@ static const char edit_description[] = static int edit_branch_description(const char *branch_name) { - FILE *fp; int status; struct strbuf buf = STRBUF_INIT; struct strbuf name = STRBUF_INIT; @@@ -783,7 -777,8 +783,7 @@@ " %s\n" "Lines starting with '%c' will be stripped.\n", branch_name, comment_line_char); - fp = fopen(git_path(edit_description), "w"); - if ((fwrite(buf.buf, 1, buf.len, fp) < buf.len) || fclose(fp)) { + if (write_file(git_path(edit_description), 0, "%s", buf.buf)) { strbuf_release(&buf); return error(_("could not write branch description template: %s"), strerror(errno)); @@@ -805,7 -800,7 +805,7 @@@ int cmd_branch(int argc, const char **argv, const char *prefix) { - int delete = 0, rename = 0, force_create = 0, list = 0; + int delete = 0, rename = 0, force = 0, list = 0; int verbose = 0, abbrev = -1, detached = 0; int reflog = 0, edit_description = 0; int quiet = 0, unset_upstream = 0; @@@ -853,7 -848,7 +853,7 @@@ OPT_BOOL('l', "create-reflog", &reflog, N_("create the branch's reflog")), OPT_BOOL(0, "edit-description", &edit_description, N_("edit the description for the branch")), - OPT__FORCE(&force_create, N_("force creation (when already exists)")), + OPT__FORCE(&force, N_("force creation, move/rename, deletion")), { OPTION_CALLBACK, 0, "no-merged", &merge_filter_ref, N_("commit"), N_("print only not merged branches"), @@@ -896,7 -891,7 +896,7 @@@ if (with_commit || merge_filter != NO_FILTER) list = 1; - if (!!delete + !!rename + !!force_create + !!new_upstream + + if (!!delete + !!rename + !!new_upstream + list + unset_upstream > 1) usage_with_options(builtin_branch_usage, options); @@@ -909,11 -904,6 +909,11 @@@ colopts = 0; } + if (force) { + delete *= 2; + rename *= 2; + } + if (delete) { if (!argc) die(_("branch name required")); @@@ -1030,7 -1020,7 +1030,7 @@@ branch_existed = ref_exists(branch->refname); create_branch(head, argv[0], (argc == 2) ? argv[1] : head, - force_create, reflog, 0, quiet, track); + force, reflog, 0, quiet, track); /* * We only show the instructions if the user gave us