Skip to content

Commit

Permalink
wt-status.c: move cut-line print code out to wt_status_add_cut_line
Browse files Browse the repository at this point in the history
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Nguyễn Thái Ngọc Duy authored and Junio C Hamano committed Feb 18, 2014
1 parent 983dc69 commit fcef931
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
19 changes: 12 additions & 7 deletions wt-status.c
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,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;
Expand All @@ -833,14 +844,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);
}
Expand Down
1 change: 1 addition & 0 deletions wt-status.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ struct wt_status_state {
};

void wt_status_truncate_message_at_cut_line(struct strbuf *);
void wt_status_add_cut_line(FILE *fp);
void wt_status_prepare(struct wt_status *s);
void wt_status_print(struct wt_status *s);
void wt_status_collect(struct wt_status *s);
Expand Down

0 comments on commit fcef931

Please sign in to comment.