summaryrefslogtreecommitdiff
path: root/pretty.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2016-07-06 13:38:12 -0700
committerJunio C Hamano <gitster@pobox.com>2016-07-06 13:38:12 -0700
commitf2140c3890780301760ee290f21be01f61726221 (patch)
treefe441f41a0fa1c572c3f672fb2abdac32c61966a /pretty.c
parent979f030359f6830fbaebd0c76e9aad5f86993fef (diff)
parent066790d7cb0fa22e64f1276d8a0e33d18484f62a (diff)
downloadgit-f2140c3890780301760ee290f21be01f61726221.tar.gz
Merge branch 'nd/graph-width-padded'
"log --graph --format=" learned that "%>|(N)" specifies the width relative to the terminal's left edge, not relative to the area to draw text that is to the right of the ancestry-graph section. It also now accepts negative N that means the column limit is relative to the right border. * nd/graph-width-padded: pretty.c: support <direction>|(<negative number>) forms pretty: pass graph width to pretty formatting for use in '%>|(N)'
Diffstat (limited to 'pretty.c')
-rw-r--r--pretty.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/pretty.c b/pretty.c
index 929e5aef97..330a5e0015 100644
--- a/pretty.c
+++ b/pretty.c
@@ -1024,9 +1024,15 @@ static size_t parse_padding_placeholder(struct strbuf *sb,
int width;
if (!end || end == start)
return 0;
- width = strtoul(start, &next, 10);
+ width = strtol(start, &next, 10);
if (next == start || width == 0)
return 0;
+ if (width < 0) {
+ if (to_column)
+ width += term_columns();
+ if (width < 0)
+ return 0;
+ }
c->padding = to_column ? -width : width;
c->flush_type = flush_type;
@@ -1301,6 +1307,7 @@ static size_t format_and_pad_commit(struct strbuf *sb, /* in UTF-8 */
if (!start)
start = sb->buf;
occupied = utf8_strnwidth(start, -1, 1);
+ occupied += c->pretty_ctx->graph_width;
padding = (-padding) - occupied;
}
while (1) {