From: Junio C Hamano Date: Sun, 20 Mar 2011 06:24:19 +0000 (-0700) Subject: Merge branch 'jn/status-translatable' X-Git-Tag: v1.7.5-rc0~57 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=f4784b3eab2e12e7a8fda7431572753f3a970c63;p=git.git Merge branch 'jn/status-translatable' * jn/status-translatable: commit, status: use status_printf{,_ln,_more} helpers commit: refer to commit template as s->fp wt-status: add helpers for printing wt-status lines Conflicts: builtin/commit.c --- f4784b3eab2e12e7a8fda7431572753f3a970c63 diff --cc builtin/commit.c index de0e11137,ae62a25f5..3979b823e --- a/builtin/commit.c +++ b/builtin/commit.c @@@ -742,34 -693,33 +741,36 @@@ static int prepare_to_commit(const cha strbuf_addstr(&committer_ident, git_committer_info(0)); if (use_editor && include_status) { char *ai_tmp, *ci_tmp; - if (in_merge) + if (whence != FROM_COMMIT) - fprintf(fp, - "#\n" - "# It looks like you may be committing a %s.\n" - "# If this is not correct, please remove the file\n" - "# %s\n" - "# and try again.\n" - "#\n", + status_printf_ln(s, GIT_COLOR_NORMAL, + "\n" - "It looks like you may be committing a MERGE.\n" ++ "It looks like you may be committing a %s.\n" + "If this is not correct, please remove the file\n" + " %s\n" + "and try again.\n" + "", - git_path("MERGE_HEAD")); + whence_s(), + git_path(whence == FROM_MERGE + ? "MERGE_HEAD" + : "CHERRY_PICK_HEAD")); - fprintf(fp, - "\n" - "# Please enter the commit message for your changes."); + + fprintf(s->fp, "\n"); + status_printf(s, GIT_COLOR_NORMAL, + "Please enter the commit message for your changes."); if (cleanup_mode == CLEANUP_ALL) - fprintf(fp, + status_printf_more(s, GIT_COLOR_NORMAL, " Lines starting\n" - "# with '#' will be ignored, and an empty" + "with '#' will be ignored, and an empty" " message aborts the commit.\n"); else /* CLEANUP_SPACE, that is. */ - fprintf(fp, + status_printf_more(s, GIT_COLOR_NORMAL, " Lines starting\n" - "# with '#' will be kept; you may remove them" + "with '#' will be kept; you may remove them" " yourself if you want to.\n" - "# An empty message aborts the commit.\n"); + "An empty message aborts the commit.\n"); if (only_include_assumed) - fprintf(fp, "# %s\n", only_include_assumed); + status_printf_ln(s, GIT_COLOR_NORMAL, + "%s", only_include_assumed); ai_tmp = cut_ident_timestamp_part(author_ident->buf); ci_tmp = cut_ident_timestamp_part(committer_ident.buf); @@@ -814,14 -764,9 +815,14 @@@ } strbuf_release(&committer_ident); - fclose(fp); + fclose(s->fp); - if (!commitable && !in_merge && !allow_empty && + /* + * Reject an attempt to record a non-merge empty commit without + * explicit --allow-empty. In the cherry-pick case, it may be + * empty due to conflict resolution, which the user should okay. + */ + if (!commitable && whence != FROM_MERGE && !allow_empty && !(amend && is_a_merge(head_sha1))) { run_status(stdout, index_file, prefix, 0, s); if (amend) diff --cc wt-status.c index 4daa8bb52,c14cbe48d..53558d7e5 --- a/wt-status.c +++ b/wt-status.c @@@ -57,33 -131,33 +131,33 @@@ static void wt_status_print_unmerged_he { const char *c = color(WT_STATUS_HEADER, s); - color_fprintf_ln(s->fp, c, "# Unmerged paths:"); + status_printf_ln(s, c, "Unmerged paths:"); if (!advice_status_hints) return; - if (s->in_merge) + if (s->whence != FROM_COMMIT) ; else if (!s->is_initial) - color_fprintf_ln(s->fp, c, "# (use \"git reset %s ...\" to unstage)", s->reference); + status_printf_ln(s, c, " (use \"git reset %s ...\" to unstage)", s->reference); else - color_fprintf_ln(s->fp, c, "# (use \"git rm --cached ...\" to unstage)"); - color_fprintf_ln(s->fp, c, "# (use \"git add/rm ...\" as appropriate to mark resolution)"); - color_fprintf_ln(s->fp, c, "#"); + status_printf_ln(s, c, " (use \"git rm --cached ...\" to unstage)"); + status_printf_ln(s, c, " (use \"git add/rm ...\" as appropriate to mark resolution)"); + status_printf_ln(s, c, ""); } static void wt_status_print_cached_header(struct wt_status *s) { const char *c = color(WT_STATUS_HEADER, s); - color_fprintf_ln(s->fp, c, "# Changes to be committed:"); + status_printf_ln(s, c, "Changes to be committed:"); if (!advice_status_hints) return; - if (s->in_merge) + if (s->whence != FROM_COMMIT) ; /* NEEDSWORK: use "git reset --unresolve"??? */ else if (!s->is_initial) - color_fprintf_ln(s->fp, c, "# (use \"git reset %s ...\" to unstage)", s->reference); + status_printf_ln(s, c, " (use \"git reset %s ...\" to unstage)", s->reference); else - color_fprintf_ln(s->fp, c, "# (use \"git rm --cached ...\" to unstage)"); - color_fprintf_ln(s->fp, c, "#"); + status_printf_ln(s, c, " (use \"git rm --cached ...\" to unstage)"); + status_printf_ln(s, c, ""); } static void wt_status_print_dirty_header(struct wt_status *s,