diff options
author | Josh Triplett <josh@joshtriplett.org> | 2024-02-27 10:16:09 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-02-27 18:40:46 +0100 |
commit | 688a0a751e9ee032be9fb70d7d63220bc85acae1 (patch) | |
tree | 74511084cdb4bc7539b685175b629f63d82e6358 /wt-status.c | |
parent | Git 2.43.3 (diff) | |
download | git-688a0a751e9ee032be9fb70d7d63220bc85acae1.tar.xz git-688a0a751e9ee032be9fb70d7d63220bc85acae1.zip |
commit: avoid redundant scissor line with --cleanup=scissors -v
`git commit --cleanup=scissors -v` prints two scissors lines:
one at the start of the comment lines, and the other right before the
diff. This is redundant, and pushes the diff further down in the user's
editor than it needs to be.
Make wt_status_add_cut_line() remember if it has added a cut line before,
and avoid adding a redundant one.
Add a test for this.
Signed-off-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'wt-status.c')
-rw-r--r-- | wt-status.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/wt-status.c b/wt-status.c index 9e8c08003b..b17ca58f8b 100644 --- a/wt-status.c +++ b/wt-status.c @@ -1107,12 +1107,15 @@ void wt_status_append_cut_line(struct strbuf *buf) strbuf_add_commented_lines(buf, explanation, strlen(explanation), comment_line_char); } -void wt_status_add_cut_line(FILE *fp) +void wt_status_add_cut_line(struct wt_status *s) { struct strbuf buf = STRBUF_INIT; + if (s->added_cut_line) + return; + s->added_cut_line = 1; wt_status_append_cut_line(&buf); - fputs(buf.buf, fp); + fputs(buf.buf, s->fp); strbuf_release(&buf); } @@ -1143,11 +1146,12 @@ static void wt_longstatus_print_verbose(struct wt_status *s) * file (and even the "auto" setting won't work, since it * will have checked isatty on stdout). But we then do want * to insert the scissor line here to reliably remove the - * diff before committing. + * diff before committing, if we didn't already include one + * before. */ if (s->fp != stdout) { rev.diffopt.use_color = 0; - wt_status_add_cut_line(s->fp); + wt_status_add_cut_line(s); } if (s->verbose > 1 && s->committable) { /* print_updated() printed a header, so do we */ |