git-p4: fix copy detection test
[gitweb.git] / wt-status.c
index 9bf96c3af064bcc71ea62c97018312bd084e9273..b8841e1dcaa73223345b6c24eec3a91de74a0222 100644 (file)
@@ -17,7 +17,7 @@
 #include "strbuf.h"
 #include "utf8.h"
 
-static char cut_line[] =
+static const char cut_line[] =
 "------------------------ >8 ------------------------\n";
 
 static char default_wt_status_colors[][COLOR_MAXLEN] = {
@@ -188,7 +188,7 @@ static void wt_status_print_unmerged_header(struct wt_status *s)
        } else {
                status_printf_ln(s, c, _("  (use \"git add/rm <file>...\" as appropriate to mark resolution)"));
        }
-       status_printf_ln(s, c, "");
+       status_printf_ln(s, c, "%s", "");
 }
 
 static void wt_status_print_cached_header(struct wt_status *s)
@@ -204,7 +204,7 @@ static void wt_status_print_cached_header(struct wt_status *s)
                status_printf_ln(s, c, _("  (use \"git reset %s <file>...\" to unstage)"), s->reference);
        else
                status_printf_ln(s, c, _("  (use \"git rm --cached <file>...\" to unstage)"));
-       status_printf_ln(s, c, "");
+       status_printf_ln(s, c, "%s", "");
 }
 
 static void wt_status_print_dirty_header(struct wt_status *s,
@@ -223,7 +223,7 @@ static void wt_status_print_dirty_header(struct wt_status *s,
        status_printf_ln(s, c, _("  (use \"git checkout -- <file>...\" to discard changes in working directory)"));
        if (has_dirty_submodules)
                status_printf_ln(s, c, _("  (commit or discard the untracked or modified content in submodules)"));
-       status_printf_ln(s, c, "");
+       status_printf_ln(s, c, "%s", "");
 }
 
 static void wt_status_print_other_header(struct wt_status *s,
@@ -235,12 +235,12 @@ static void wt_status_print_other_header(struct wt_status *s,
        if (!s->hints)
                return;
        status_printf_ln(s, c, _("  (use \"git %s <file>...\" to include in what will be committed)"), how);
-       status_printf_ln(s, c, "");
+       status_printf_ln(s, c, "%s", "");
 }
 
 static void wt_status_print_trailer(struct wt_status *s)
 {
-       status_printf_ln(s, color(WT_STATUS_HEADER, s), "");
+       status_printf_ln(s, color(WT_STATUS_HEADER, s), "%s", "");
 }
 
 #define quote_path quote_path_relative
@@ -826,7 +826,7 @@ static void wt_status_print_other(struct wt_status *s,
        string_list_clear(&output, 0);
        strbuf_release(&buf);
 conclude:
-       status_printf_ln(s, GIT_COLOR_NORMAL, "");
+       status_printf_ln(s, GIT_COLOR_NORMAL, "%s", "");
 }
 
 void wt_status_truncate_message_at_cut_line(struct strbuf *buf)
@@ -841,6 +841,17 @@ void wt_status_truncate_message_at_cut_line(struct strbuf *buf)
        strbuf_release(&pattern);
 }
 
+void wt_status_add_cut_line(FILE *fp)
+{
+       const char *explanation = _("Do not touch the line above.\nEverything below will be removed.");
+       struct strbuf buf = STRBUF_INIT;
+
+       fprintf(fp, "%c %s", comment_line_char, cut_line);
+       strbuf_add_commented_lines(&buf, explanation, strlen(explanation));
+       fputs(buf.buf, fp);
+       strbuf_release(&buf);
+}
+
 static void wt_status_print_verbose(struct wt_status *s)
 {
        struct rev_info rev;
@@ -866,14 +877,8 @@ static void wt_status_print_verbose(struct wt_status *s)
         * diff before committing.
         */
        if (s->fp != stdout) {
-               const char *explanation = _("Do not touch the line above.\nEverything below will be removed.");
-               struct strbuf buf = STRBUF_INIT;
-
                rev.diffopt.use_color = 0;
-               fprintf(s->fp, "%c %s", comment_line_char, cut_line);
-               strbuf_add_commented_lines(&buf, explanation, strlen(explanation));
-               fputs(buf.buf, s->fp);
-               strbuf_release(&buf);
+               wt_status_add_cut_line(s->fp);
        }
        run_diff_index(&rev, 1);
 }
@@ -908,7 +913,7 @@ static void wt_status_print_tracking(struct wt_status *s)
                color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "%c",
                                 comment_line_char);
        else
-               fprintf_ln(s->fp, "");
+               fputs("", s->fp);
 }
 
 static int has_unmerged(struct wt_status *s)
@@ -1324,7 +1329,7 @@ void wt_status_print(struct wt_status *s)
                                on_what = _("Not currently on any branch.");
                        }
                }
-               status_printf(s, color(WT_STATUS_HEADER, s), "");
+               status_printf(s, color(WT_STATUS_HEADER, s), "%s", "");
                status_printf_more(s, branch_status_color, "%s", on_what);
                status_printf_more(s, branch_color, "%s\n", branch_name);
                if (!s->is_initial)
@@ -1337,9 +1342,9 @@ void wt_status_print(struct wt_status *s)
        free(state.detached_from);
 
        if (s->is_initial) {
-               status_printf_ln(s, color(WT_STATUS_HEADER, s), "");
+               status_printf_ln(s, color(WT_STATUS_HEADER, s), "%s", "");
                status_printf_ln(s, color(WT_STATUS_HEADER, s), _("Initial commit"));
-               status_printf_ln(s, color(WT_STATUS_HEADER, s), "");
+               status_printf_ln(s, color(WT_STATUS_HEADER, s), "%s", "");
        }
 
        wt_status_print_updated(s);
@@ -1356,7 +1361,7 @@ void wt_status_print(struct wt_status *s)
                if (s->show_ignored_files)
                        wt_status_print_other(s, &s->ignored, _("Ignored files"), "add -f");
                if (advice_status_u_option && 2000 < s->untracked_in_ms) {
-                       status_printf_ln(s, GIT_COLOR_NORMAL, "");
+                       status_printf_ln(s, GIT_COLOR_NORMAL, "%s", "");
                        status_printf_ln(s, GIT_COLOR_NORMAL,
                                         _("It took %.2f seconds to enumerate untracked files. 'status -uno'\n"
                                           "may speed it up, but you have to be careful not to forget to add\n"