Merge branch 'jn/status-translatable'
authorJunio C Hamano <gitster@pobox.com>
Sun, 20 Mar 2011 06:24:19 +0000 (23:24 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sun, 20 Mar 2011 06:24:19 +0000 (23:24 -0700)
* 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

1  2 
builtin/commit.c
wt-status.c
wt-status.h

@@@ -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);
        }
        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
@@@ -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 <file>...\" to unstage)", s->reference);
+               status_printf_ln(s, c, "  (use \"git reset %s <file>...\" to unstage)", s->reference);
        else
-               color_fprintf_ln(s->fp, c, "#   (use \"git rm --cached <file>...\" to unstage)");
-       color_fprintf_ln(s->fp, c, "#   (use \"git add/rm <file>...\" as appropriate to mark resolution)");
-       color_fprintf_ln(s->fp, c, "#");
+               status_printf_ln(s, c, "  (use \"git rm --cached <file>...\" to unstage)");
+       status_printf_ln(s, c, "  (use \"git add/rm <file>...\" 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 <file>...\" to unstage)", s->reference);
+               status_printf_ln(s, c, "  (use \"git reset %s <file>...\" to unstage)", s->reference);
        else
-               color_fprintf_ln(s->fp, c, "#   (use \"git rm --cached <file>...\" to unstage)");
-       color_fprintf_ln(s->fp, c, "#");
+               status_printf_ln(s, c, "  (use \"git rm --cached <file>...\" to unstage)");
+       status_printf_ln(s, c, "");
  }
  
  static void wt_status_print_dirty_header(struct wt_status *s,
diff --cc wt-status.h
Simple merge