summaryrefslogtreecommitdiff
path: root/wt-status.c
diff options
context:
space:
mode:
authorMatthieu Moy <Matthieu.Moy@imag.fr>2013-09-06 19:43:07 +0200
committerJunio C Hamano <gitster@pobox.com>2013-09-06 13:33:18 -0700
commit2556b9962e7c0353d562b7bf70eed11d8f29d0b0 (patch)
tree7f1e9ca52eac054c468bd7ab54e8be32940907a5 /wt-status.c
parent3ba7407b8b7b7a75f720641327207d6cfdb163a2 (diff)
downloadgit-2556b9962e7c0353d562b7bf70eed11d8f29d0b0.tar.gz
status: disable display of '#' comment prefix by default
Historically, "git status" needed to prefix each output line with '#' so that the output could be added as comment to the commit message. This prefix comment has no real purpose when "git status" is ran from the command-line, and this may distract users from the real content. Disable this prefix comment by default, and make it re-activable for users needing backward compatibility with status.displayCommentPrefix. Obviously, "git commit" ignores status.displayCommentPrefix and keeps the comment unconditionnaly when writing to COMMIT_EDITMSG (but not when writing to stdout for an error message or with --dry-run). Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'wt-status.c')
-rw-r--r--wt-status.c40
1 files changed, 29 insertions, 11 deletions
diff --git a/wt-status.c b/wt-status.c
index 853813f560..3c795da5ed 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -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)