Code

i18n: git-commit basic messages
[git.git] / builtin / commit.c
index ae62a25f52a2a500f4f27f9b03b2279c2197ef31..472c2baed04f549fb1a3c429a2c36747e8229c68 100644 (file)
@@ -243,7 +243,7 @@ static void add_remove_files(struct string_list *list)
 
                if (!lstat(p->string, &st)) {
                        if (add_to_cache(p->string, &st, 0))
-                               die("updating files failed");
+                               die(_("updating files failed"));
                } else
                        remove_file_from_cache(p->string);
        }
@@ -270,7 +270,7 @@ static void create_base_index(void)
        opts.fn = oneway_merge;
        tree = parse_tree_indirect(head_sha1);
        if (!tree)
-               die("failed to unpack HEAD tree object");
+               die(_("failed to unpack HEAD tree object"));
        parse_tree(tree);
        init_tree_desc(&t, tree->buffer, tree->size);
        if (unpack_trees(1, &t, &opts))
@@ -298,9 +298,9 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, int
                refresh_flags |= REFRESH_UNMERGED;
        if (interactive) {
                if (interactive_add(argc, argv, prefix) != 0)
-                       die("interactive add failed");
+                       die(_("interactive add failed"));
                if (read_cache_preload(NULL) < 0)
-                       die("index file corrupt");
+                       die(_("index file corrupt"));
                commit_style = COMMIT_AS_IS;
                return get_index_file();
        }
@@ -309,7 +309,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, int
                pathspec = get_pathspec(prefix, argv);
 
        if (read_cache_preload(pathspec) < 0)
-               die("index file corrupt");
+               die(_("index file corrupt"));
 
        /*
         * Non partial, non as-is commit.
@@ -329,7 +329,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, int
                refresh_cache_or_die(refresh_flags);
                if (write_cache(fd, active_cache, active_nr) ||
                    close_lock_file(&index_lock))
-                       die("unable to write new_index file");
+                       die(_("unable to write new_index file"));
                commit_style = COMMIT_NORMAL;
                return index_lock.filename;
        }
@@ -349,7 +349,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, int
                if (active_cache_changed) {
                        if (write_cache(fd, active_cache, active_nr) ||
                            commit_locked_index(&index_lock))
-                               die("unable to write new_index file");
+                               die(_("unable to write new_index file"));
                } else {
                        rollback_lock_file(&index_lock);
                }
@@ -379,7 +379,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, int
        commit_style = COMMIT_PARTIAL;
 
        if (in_merge)
-               die("cannot do a partial commit during a merge.");
+               die(_("cannot do a partial commit during a merge."));
 
        memset(&partial, 0, sizeof(partial));
        partial.strdup_strings = 1;
@@ -388,14 +388,14 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, int
 
        discard_cache();
        if (read_cache() < 0)
-               die("cannot read the index");
+               die(_("cannot read the index"));
 
        fd = hold_locked_index(&index_lock, 1);
        add_remove_files(&partial);
        refresh_cache(REFRESH_QUIET);
        if (write_cache(fd, active_cache, active_nr) ||
            close_lock_file(&index_lock))
-               die("unable to write new_index file");
+               die(_("unable to write new_index file"));
 
        fd = hold_lock_file_for_update(&false_lock,
                                       git_path("next-index-%"PRIuMAX,
@@ -408,7 +408,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, int
 
        if (write_cache(fd, active_cache, active_nr) ||
            close_lock_file(&false_lock))
-               die("unable to write temporary index file");
+               die(_("unable to write temporary index file"));
 
        discard_cache();
        read_cache_from(false_lock.filename);
@@ -455,7 +455,7 @@ static int is_a_merge(const unsigned char *sha1)
 {
        struct commit *commit = lookup_commit(sha1);
        if (!commit || parse_commit(commit))
-               die("could not parse HEAD commit");
+               die(_("could not parse HEAD commit"));
        return !!(commit->parents && commit->parents->next);
 }
 
@@ -474,13 +474,13 @@ static void determine_author_info(struct strbuf *author_ident)
 
                a = strstr(use_message_buffer, "\nauthor ");
                if (!a)
-                       die("invalid commit: %s", use_message);
+                       die(_("invalid commit: %s"), use_message);
 
                lb = strchrnul(a + strlen("\nauthor "), '<');
                rb = strchrnul(lb, '>');
                eol = strchrnul(rb, '\n');
                if (!*lb || !*rb || !*eol)
-                       die("invalid commit: %s", use_message);
+                       die(_("invalid commit: %s"), use_message);
 
                if (lb == a + strlen("\nauthor "))
                        /* \nauthor <foo@example.com> */
@@ -498,7 +498,7 @@ static void determine_author_info(struct strbuf *author_ident)
                const char *rb = strchr(force_author, '>');
 
                if (!lb || !rb)
-                       die("malformed --author parameter");
+                       die(_("malformed --author parameter"));
                name = xstrndup(force_author, lb - force_author);
                email = xstrndup(lb + 2, rb - (lb + 2));
        }
@@ -554,7 +554,7 @@ static char *cut_ident_timestamp_part(char *string)
 {
        char *ket = strrchr(string, '>');
        if (!ket || ket[1] != ' ')
-               die("Malformed ident string: '%s'", string);
+               die(_("Malformed ident string: '%s'"), string);
        *++ket = '\0';
        return ket;
 }
@@ -587,7 +587,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
                        struct commit *c;
                        c = lookup_commit_reference_by_name(squash_message);
                        if (!c)
-                               die("could not lookup commit %s", squash_message);
+                               die(_("could not lookup commit %s"), squash_message);
                        ctx.output_encoding = get_commit_output_encoding();
                        format_commit_message(c, "squash! %s\n\n", &sb,
                                              &ctx);
@@ -599,19 +599,19 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
                hook_arg1 = "message";
        } else if (logfile && !strcmp(logfile, "-")) {
                if (isatty(0))
-                       fprintf(stderr, "(reading log message from standard input)\n");
+                       fprintf(stderr, _("(reading log message from standard input)\n"));
                if (strbuf_read(&sb, 0, 0) < 0)
-                       die_errno("could not read log from standard input");
+                       die_errno(_("could not read log from standard input"));
                hook_arg1 = "message";
        } else if (logfile) {
                if (strbuf_read_file(&sb, logfile, 0) < 0)
-                       die_errno("could not read log file '%s'",
+                       die_errno(_("could not read log file '%s'"),
                                  logfile);
                hook_arg1 = "message";
        } else if (use_message) {
                buffer = strstr(use_message_buffer, "\n\n");
                if (!buffer || buffer[2] == '\0')
-                       die("commit has empty message");
+                       die(_("commit has empty message"));
                strbuf_add(&sb, buffer + 2, strlen(buffer + 2));
                hook_arg1 = "commit";
                hook_arg2 = use_message;
@@ -620,22 +620,22 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
                struct commit *commit;
                commit = lookup_commit_reference_by_name(fixup_message);
                if (!commit)
-                       die("could not lookup commit %s", fixup_message);
+                       die(_("could not lookup commit %s"), fixup_message);
                ctx.output_encoding = get_commit_output_encoding();
                format_commit_message(commit, "fixup! %s\n\n",
                                      &sb, &ctx);
                hook_arg1 = "message";
        } else if (!stat(git_path("MERGE_MSG"), &statbuf)) {
                if (strbuf_read_file(&sb, git_path("MERGE_MSG"), 0) < 0)
-                       die_errno("could not read MERGE_MSG");
+                       die_errno(_("could not read MERGE_MSG"));
                hook_arg1 = "merge";
        } else if (!stat(git_path("SQUASH_MSG"), &statbuf)) {
                if (strbuf_read_file(&sb, git_path("SQUASH_MSG"), 0) < 0)
-                       die_errno("could not read SQUASH_MSG");
+                       die_errno(_("could not read SQUASH_MSG"));
                hook_arg1 = "squash";
        } else if (template_file && !stat(template_file, &statbuf)) {
                if (strbuf_read_file(&sb, template_file, 0) < 0)
-                       die_errno("could not read '%s'", template_file);
+                       die_errno(_("could not read '%s'"), template_file);
                hook_arg1 = "template";
        }
 
@@ -658,7 +658,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 
        s->fp = fopen(git_path(commit_editmsg), "w");
        if (s->fp == NULL)
-               die_errno("could not open '%s'", git_path(commit_editmsg));
+               die_errno(_("could not open '%s'"), git_path(commit_editmsg));
 
        if (cleanup_mode != CLEANUP_NONE)
                stripspace(&sb, 0);
@@ -682,7 +682,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
        }
 
        if (fwrite(sb.buf, 1, sb.len, s->fp) < sb.len)
-               die_errno("could not write commit template");
+               die_errno(_("could not write commit template"));
 
        strbuf_release(&sb);
 
@@ -752,7 +752,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
                const char *parent = "HEAD";
 
                if (!active_nr && read_cache() < 0)
-                       die("Cannot read index");
+                       die(_("Cannot read index"));
 
                if (amend)
                        parent = "HEAD^1";
@@ -785,7 +785,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
                active_cache_tree = cache_tree();
        if (cache_tree_update(active_cache_tree,
                              active_cache, active_nr, 0, 0) < 0) {
-               error("Error building trees");
+               error(_("Error building trees"));
                return 0;
        }
 
@@ -800,7 +800,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
                snprintf(index, sizeof(index), "GIT_INDEX_FILE=%s", index_file);
                if (launch_editor(git_path(commit_editmsg), NULL, env)) {
                        fprintf(stderr,
-                       "Please supply the message using either -m or -F option.\n");
+                       _("Please supply the message using either -m or -F option.\n"));
                        exit(1);
                }
        }
@@ -880,7 +880,7 @@ static const char *find_author_by_nickname(const char *name)
                format_commit_message(commit, "%an <%ae>", &buf, &ctx);
                return strbuf_detach(&buf, NULL);
        }
-       die("No existing author found with '%s'", name);
+       die(_("No existing author found with '%s'"), name);
 }
 
 
@@ -895,7 +895,7 @@ static void handle_untracked_files_arg(struct wt_status *s)
        else if (!strcmp(untracked_files_arg, "all"))
                s->show_untracked_files = SHOW_ALL_UNTRACKED_FILES;
        else
-               die("Invalid untracked files mode '%s'", untracked_files_arg);
+               die(_("Invalid untracked files mode '%s'"), untracked_files_arg);
 }
 
 static int parse_and_validate_options(int argc, const char *argv[],
@@ -912,7 +912,7 @@ static int parse_and_validate_options(int argc, const char *argv[],
                force_author = find_author_by_nickname(force_author);
 
        if (force_author && renew_authorship)
-               die("Using both --reset-author and --author does not make sense");
+               die(_("Using both --reset-author and --author does not make sense"));
 
        if (logfile || message.len || use_message || fixup_message)
                use_editor = 0;
@@ -926,7 +926,7 @@ static int parse_and_validate_options(int argc, const char *argv[],
 
        /* Sanity check options */
        if (amend && initial_commit)
-               die("You have nothing to amend.");
+               die(_("You have nothing to amend."));
        if (amend && in_merge)
                die("You are in the middle of a merge -- cannot amend.");
        if (fixup_message && squash_message)
@@ -940,22 +940,22 @@ static int parse_and_validate_options(int argc, const char *argv[],
        if (logfile)
                f++;
        if (f > 1)
-               die("Only one of -c/-C/-F/--fixup can be used.");
+               die(_("Only one of -c/-C/-F/--fixup can be used."));
        if (message.len && f > 0)
-               die("Option -m cannot be combined with -c/-C/-F/--fixup.");
+               die((_("Option -m cannot be combined with -c/-C/-F/--fixup.")));
        if (edit_message)
                use_message = edit_message;
        if (amend && !use_message && !fixup_message)
                use_message = "HEAD";
        if (!use_message && renew_authorship)
-               die("--reset-author can be used only with -C, -c or --amend.");
+               die(_("--reset-author can be used only with -C, -c or --amend."));
        if (use_message) {
                const char *out_enc;
                struct commit *commit;
 
                commit = lookup_commit_reference_by_name(use_message);
                if (!commit)
-                       die("could not lookup commit %s", use_message);
+                       die(_("could not lookup commit %s"), use_message);
                out_enc = get_commit_output_encoding();
                use_message_buffer = logmsg_reencode(commit, out_enc);
 
@@ -970,13 +970,13 @@ static int parse_and_validate_options(int argc, const char *argv[],
        }
 
        if (!!also + !!only + !!all + !!interactive > 1)
-               die("Only one of --include/--only/--all/--interactive can be used.");
+               die(_("Only one of --include/--only/--all/--interactive can be used."));
        if (argc == 0 && (also || (only && !amend)))
-               die("No paths with --include/--only does not make sense.");
+               die(_("No paths with --include/--only does not make sense."));
        if (argc == 0 && only && amend)
-               only_include_assumed = "Clever... amending the last one with dirty index.";
+               only_include_assumed = _("Clever... amending the last one with dirty index.");
        if (argc > 0 && !also && !only)
-               only_include_assumed = "Explicit paths specified without -i nor -o; assuming --only paths...";
+               only_include_assumed = _("Explicit paths specified without -i nor -o; assuming --only paths...");
        if (!cleanup_arg || !strcmp(cleanup_arg, "default"))
                cleanup_mode = use_editor ? CLEANUP_ALL : CLEANUP_SPACE;
        else if (!strcmp(cleanup_arg, "verbatim"))
@@ -986,14 +986,14 @@ static int parse_and_validate_options(int argc, const char *argv[],
        else if (!strcmp(cleanup_arg, "strip"))
                cleanup_mode = CLEANUP_ALL;
        else
-               die("Invalid cleanup mode %s", cleanup_arg);
+               die(_("Invalid cleanup mode %s"), cleanup_arg);
 
        handle_untracked_files_arg(s);
 
        if (all && argc > 0)
-               die("Paths with -a does not make sense.");
+               die(_("Paths with -a does not make sense."));
        else if (interactive && argc > 0)
-               die("Paths with --interactive does not make sense.");
+               die(_("Paths with --interactive does not make sense."));
 
        if (null_termination && status_format == STATUS_FORMAT_LONG)
                status_format = STATUS_FORMAT_PORCELAIN;
@@ -1074,7 +1074,7 @@ static int git_status_config(const char *k, const char *v, void *cb)
                else if (!strcmp(v, "all"))
                        s->show_untracked_files = SHOW_ALL_UNTRACKED_FILES;
                else
-                       return error("Invalid untracked files mode '%s'", v);
+                       return error(_("Invalid untracked files mode '%s'"), v);
                return 0;
        }
        return git_diff_ui_config(k, v, NULL);
@@ -1180,9 +1180,9 @@ static void print_summary(const char *prefix, const unsigned char *sha1)
 
        commit = lookup_commit(sha1);
        if (!commit)
-               die("couldn't look up newly created commit");
+               die(_("couldn't look up newly created commit"));
        if (!commit || parse_commit(commit))
-               die("could not parse newly created commit");
+               die(_("could not parse newly created commit"));
 
        strbuf_addstr(&format, "format:%h] %s");
 
@@ -1336,7 +1336,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
                        reflog_msg = "commit (amend)";
                commit = lookup_commit(head_sha1);
                if (!commit || parse_commit(commit))
-                       die("could not parse HEAD commit");
+                       die(_("could not parse HEAD commit"));
 
                for (c = commit->parents; c; c = c->next)
                        pptr = &commit_list_insert(c->item, pptr)->next;
@@ -1349,19 +1349,19 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
                pptr = &commit_list_insert(lookup_commit(head_sha1), pptr)->next;
                fp = fopen(git_path("MERGE_HEAD"), "r");
                if (fp == NULL)
-                       die_errno("could not open '%s' for reading",
+                       die_errno(_("could not open '%s' for reading"),
                                  git_path("MERGE_HEAD"));
                while (strbuf_getline(&m, fp, '\n') != EOF) {
                        unsigned char sha1[20];
                        if (get_sha1_hex(m.buf, sha1) < 0)
-                               die("Corrupt MERGE_HEAD file (%s)", m.buf);
+                               die(_("Corrupt MERGE_HEAD file (%s)"), m.buf);
                        pptr = &commit_list_insert(lookup_commit(sha1), pptr)->next;
                }
                fclose(fp);
                strbuf_release(&m);
                if (!stat(git_path("MERGE_MODE"), &statbuf)) {
                        if (strbuf_read_file(&sb, git_path("MERGE_MODE"), 0) < 0)
-                               die_errno("could not read MERGE_MODE");
+                               die_errno(_("could not read MERGE_MODE"));
                        if (!strcmp(sb.buf, "no-ff"))
                                allow_fast_forward = 0;
                }
@@ -1378,7 +1378,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
        if (strbuf_read_file(&sb, git_path(commit_editmsg), 0) < 0) {
                int saved_errno = errno;
                rollback_index_files();
-               die("could not read commit message: %s", strerror(saved_errno));
+               die(_("could not read commit message: %s"), strerror(saved_errno));
        }
 
        /* Truncate the message just before the diff, if any. */
@@ -1392,14 +1392,14 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
                stripspace(&sb, cleanup_mode == CLEANUP_ALL);
        if (message_is_empty(&sb) && !allow_empty_message) {
                rollback_index_files();
-               fprintf(stderr, "Aborting commit due to empty commit message.\n");
+               fprintf(stderr, _("Aborting commit due to empty commit message.\n"));
                exit(1);
        }
 
        if (commit_tree(sb.buf, active_cache_tree->sha1, parents, commit_sha1,
                        author_ident.buf)) {
                rollback_index_files();
-               die("failed to write commit object");
+               die(_("failed to write commit object"));
        }
        strbuf_release(&author_ident);
 
@@ -1417,11 +1417,11 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 
        if (!ref_lock) {
                rollback_index_files();
-               die("cannot lock HEAD ref");
+               die(_("cannot lock HEAD ref"));
        }
        if (write_ref_sha1(ref_lock, commit_sha1, sb.buf) < 0) {
                rollback_index_files();
-               die("cannot update HEAD ref");
+               die(_("cannot update HEAD ref"));
        }
 
        unlink(git_path("MERGE_HEAD"));
@@ -1430,9 +1430,9 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
        unlink(git_path("SQUASH_MSG"));
 
        if (commit_index_files())
-               die ("Repository has been updated, but unable to write\n"
+               die (_("Repository has been updated, but unable to write\n"
                     "new_index file. Check that disk is not full or quota is\n"
-                    "not exceeded, and then \"git reset HEAD\" to recover.");
+                    "not exceeded, and then \"git reset HEAD\" to recover."));
 
        rerere(0);
        run_hook(get_index_file(), "post-commit", NULL);