i18n: apply: mark parseopt strings for translation
[gitweb.git] / builtin / branch.c
index 9634c71ea20777964c0aa86416d4849103be793d..d51648fee4e73ef7fb72f32c722b79a913d6b275 100644 (file)
@@ -153,26 +153,28 @@ static int branch_merged(int kind, const char *name,
        return merged;
 }
 
-static int delete_branches(int argc, const char **argv, int force, int kinds)
+static int delete_branches(int argc, const char **argv, int force, int kinds,
+                          int quiet)
 {
        struct commit *rev, *head_rev = NULL;
        unsigned char sha1[20];
        char *name = NULL;
-       const char *fmt, *remote;
+       const char *fmt;
        int i;
        int ret = 0;
+       int remote_branch = 0;
        struct strbuf bname = STRBUF_INIT;
 
        switch (kinds) {
        case REF_REMOTE_BRANCH:
                fmt = "refs/remotes/%s";
-               /* TRANSLATORS: This is "remote " in "remote branch '%s' not found" */
-               remote = _("remote ");
+               /* For subsequent UI messages */
+               remote_branch = 1;
+
                force = 1;
                break;
        case REF_LOCAL_BRANCH:
                fmt = "refs/heads/%s";
-               remote = "";
                break;
        default:
                die(_("cannot use -a with -d"));
@@ -196,8 +198,9 @@ static int delete_branches(int argc, const char **argv, int force, int kinds)
 
                name = xstrdup(mkpath(fmt, bname.buf));
                if (read_ref(name, sha1)) {
-                       error(_("%sbranch '%s' not found."),
-                                       remote, bname.buf);
+                       error(remote_branch
+                             ? _("remote branch '%s' not found.")
+                             : _("branch '%s' not found."), bname.buf);
                        ret = 1;
                        continue;
                }
@@ -218,14 +221,19 @@ static int delete_branches(int argc, const char **argv, int force, int kinds)
                }
 
                if (delete_ref(name, sha1, 0)) {
-                       error(_("Error deleting %sbranch '%s'"), remote,
+                       error(remote_branch
+                             ? _("Error deleting remote branch '%s'")
+                             : _("Error deleting branch '%s'"),
                              bname.buf);
                        ret = 1;
                } else {
                        struct strbuf buf = STRBUF_INIT;
-                       printf(_("Deleted %sbranch %s (was %s).\n"), remote,
-                              bname.buf,
-                              find_unique_abbrev(sha1, DEFAULT_ABBREV));
+                       if (!quiet)
+                               printf(remote_branch
+                                      ? _("Deleted remote branch %s (was %s).\n")
+                                      : _("Deleted branch %s (was %s).\n"),
+                                      bname.buf,
+                                      find_unique_abbrev(sha1, DEFAULT_ABBREV));
                        strbuf_addf(&buf, "branch.%s", bname.buf);
                        if (git_config_rename_section(buf.buf, NULL) < 0)
                                warning(_("Update of config-file failed"));
@@ -542,6 +550,10 @@ static int print_ref_list(int kinds, int detached, int verbose, int abbrev, stru
        if (merge_filter != NO_FILTER) {
                struct commit *filter;
                filter = lookup_commit_reference_gently(merge_filter_ref, 0);
+               if (!filter)
+                       die("object '%s' does not point to a commit",
+                           sha1_to_hex(merge_filter_ref));
+
                filter->object.flags |= UNINTERESTING;
                add_pending_object(&ref_list.revs,
                                   (struct object *) filter, "");
@@ -663,7 +675,7 @@ static int edit_branch_description(const char *branch_name)
        fp = fopen(git_path(edit_description), "w");
        if ((fwrite(buf.buf, 1, buf.len, fp) < buf.len) || fclose(fp)) {
                strbuf_release(&buf);
-               return error(_("could not write branch description template: %s\n"),
+               return error(_("could not write branch description template: %s"),
                             strerror(errno));
        }
        strbuf_reset(&buf);
@@ -686,6 +698,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
        int delete = 0, rename = 0, force_create = 0, list = 0;
        int verbose = 0, abbrev = -1, detached = 0;
        int reflog = 0, edit_description = 0;
+       int quiet = 0;
        enum branch_track track;
        int kinds = REF_LOCAL_BRANCH;
        struct commit_list *with_commit = NULL;
@@ -694,6 +707,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
                OPT_GROUP("Generic options"),
                OPT__VERBOSE(&verbose,
                        "show hash and subject, give twice for upstream branch"),
+               OPT__QUIET(&quiet, "suppress informational messages"),
                OPT_SET_INT('t', "track",  &track, "set up tracking mode (see git-pull(1))",
                        BRANCH_TRACK_EXPLICIT),
                OPT_SET_INT( 0, "set-upstream",  &track, "change upstream info",
@@ -782,7 +796,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
        }
 
        if (delete)
-               return delete_branches(argc, argv, delete > 1, kinds);
+               return delete_branches(argc, argv, delete > 1, kinds, quiet);
        else if (list) {
                int ret = print_ref_list(kinds, detached, verbose, abbrev,
                                         with_commit, argv);
@@ -828,7 +842,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
                if (kinds != REF_LOCAL_BRANCH)
                        die(_("-a and -r options to 'git branch' do not make sense with a branch name"));
                create_branch(head, argv[0], (argc == 2) ? argv[1] : head,
-                             force_create, reflog, 0, track);
+                             force_create, reflog, 0, quiet, track);
        } else
                usage_with_options(builtin_branch_usage, options);