]> git.ipfire.org Git - thirdparty/git.git/blobdiff - wt-status.c
status: disable display of '#' comment prefix by default
[thirdparty/git.git] / wt-status.c
index 853813f5607731a4c840269f5648f1aa21c17b0a..3c795da5ed71df8b27db4150037cee4a6fad1147 100644 (file)
@@ -46,9 +46,11 @@ static void status_vprintf(struct wt_status *s, int at_bol, const char *color,
 
        strbuf_vaddf(&sb, fmt, ap);
        if (!sb.len) {
-               strbuf_addch(&sb, comment_line_char);
-               if (!trail)
-                       strbuf_addch(&sb, ' ');
+               if (s->display_comment_prefix) {
+                       strbuf_addch(&sb, comment_line_char);
+                       if (!trail)
+                               strbuf_addch(&sb, ' ');
+               }
                color_print_strbuf(s->fp, color, &sb);
                if (trail)
                        fprintf(s->fp, "%s", trail);
@@ -59,7 +61,7 @@ static void status_vprintf(struct wt_status *s, int at_bol, const char *color,
                eol = strchr(line, '\n');
 
                strbuf_reset(&linebuf);
-               if (at_bol) {
+               if (at_bol && s->display_comment_prefix) {
                        strbuf_addch(&linebuf, comment_line_char);
                        if (*line != '\n' && *line != '\t')
                                strbuf_addch(&linebuf, ' ');
@@ -129,6 +131,7 @@ void wt_status_prepare(struct wt_status *s)
        s->untracked.strdup_strings = 1;
        s->ignored.strdup_strings = 1;
        s->show_branch = -1;  /* unspecified */
+       s->display_comment_prefix = 0;
 }
 
 static void wt_status_print_unmerged_header(struct wt_status *s)
@@ -707,9 +710,11 @@ static void wt_status_print_submodule_summary(struct wt_status *s, int uncommitt
        strbuf_addbuf(&summary, &cmd_stdout);
        strbuf_release(&cmd_stdout);
 
-       summary_content = strbuf_detach(&summary, &len);
-       strbuf_add_commented_lines(&summary, summary_content, len);
-       free(summary_content);
+       if (s->display_comment_prefix) {
+               summary_content = strbuf_detach(&summary, &len);
+               strbuf_add_commented_lines(&summary, summary_content, len);
+               free(summary_content);
+       }
 
        fputs(summary.buf, s->fp);
        strbuf_release(&summary);
@@ -748,8 +753,9 @@ static void wt_status_print_other(struct wt_status *s,
        if (!column_active(s->colopts))
                return;
 
-       strbuf_addf(&buf, "%s#\t%s",
+       strbuf_addf(&buf, "%s%s\t%s",
                    color(WT_STATUS_HEADER, s),
+                   s->display_comment_prefix ? "#" : "",
                    color(WT_STATUS_UNTRACKED, s));
        memset(&copts, 0, sizeof(copts));
        copts.padding = 1;
@@ -793,6 +799,8 @@ static void wt_status_print_tracking(struct wt_status *s)
        struct strbuf sb = STRBUF_INIT;
        const char *cp, *ep;
        struct branch *branch;
+       char comment_line_string[3];
+       int i;
 
        assert(s->branch && !s->is_initial);
        if (prefixcmp(s->branch, "refs/heads/"))
@@ -801,12 +809,22 @@ static void wt_status_print_tracking(struct wt_status *s)
        if (!format_tracking_info(branch, &sb))
                return;
 
+       i = 0;
+       if (s->display_comment_prefix) {
+               comment_line_string[i++] = comment_line_char;
+               comment_line_string[i++] = ' ';
+       }
+       comment_line_string[i] = '\0';
+
        for (cp = sb.buf; (ep = strchr(cp, '\n')) != NULL; cp = ep + 1)
                color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s),
-                                "%c %.*s", comment_line_char,
+                                "%s%.*s", comment_line_string,
                                 (int)(ep - cp), cp);
-       color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "%c",
-                        comment_line_char);
+       if (s->display_comment_prefix)
+               color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "%c",
+                                comment_line_char);
+       else
+               fprintf_ln(s->fp, "");
 }
 
 static int has_unmerged(struct wt_status *s)