#!/bin/sh

. libtest.sh
. libgit.sh

export COLUMNS=181

steps '
	:save-view view.data
'

tigrc <<EOF
set line-graphics = utf-8
EOF

in_work_dir create_repo_from_tgz "$base_dir/files/scala-js-benchmarks.tgz"

test_tig show <<EOF
commit 1b4c64b595aeb4de1d317d669faacd3c1d82f0b0
Author: A. U. Thor <author@example.com>
Date:   Sun Jul 2 15:01:24 2017 +0200

    Diff stat examples
---
 added                          |   40 +++++++++++
 remove                         |  124 --------------------------
 updated                        |   14 +----
 rename.from => rename.to       |    0
 dir/{rename.from => rename.to} |    0
 .../truncated file name        |   11 ++---
 binary add                     |  Bin 0 -> 1234 bytes
 binary update                  |  Bin 1234 -> 2345 bytes
 binary copy                    |  Bin
 binary del                     |  Bin 16787 -> 0 bytes
 unmerged                       | Unmerged
 42 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/file.c b/src/file.c
...
EOF

assert_equals 'view.data' <<EOF
View: diff
Ref: 1b4c64b595aeb4de1d317d669faacd3c1d82f0b0
Dimensions: height=28 width=181
Position: offset=0 column=0 lineno=0
line[  0] type=commit selected=1
line[  0] cells=1 text=[commit 1b4c64b595aeb4de1d317d669faacd3c1d82f0b0]
line[  1] type= selected=0
line[  1] cells=1 text=[Author: A. U. Thor <author@example.com>]
line[  2] type= selected=0
line[  2] cells=1 text=[Date:   Sun Jul 2 15:01:24 2017 +0200]
line[  3] type=default selected=0
line[  3] cells=1 text=[]
line[  4] type=default selected=0
line[  4] cells=1 text=[    Diff stat examples]
line[  5] type=diff-start selected=0
line[  5] cells=1 text=[---]
line[  6] type=diff-stat selected=0
line[  6] cells=3 text=[ added                          ][|   40 ][+++++++++++]
line[  7] type=diff-stat selected=0
line[  7] cells=3 text=[ remove                         ][|  124 ][--------------------------]
line[  8] type=diff-stat selected=0
line[  8] cells=4 text=[ updated                        ][|   14 ][+][----]
line[  9] type=diff-stat selected=0
line[  9] cells=2 text=[ rename.from => rename.to       ][|    0]
line[ 10] type=diff-stat selected=0
line[ 10] cells=2 text=[ dir/{rename.from => rename.to} ][|    0]
line[ 11] type=diff-stat selected=0
line[ 11] cells=4 text=[ .../truncated file name        ][|   11 ][++][---]
line[ 12] type=diff-stat selected=0
line[ 12] cells=7 text=[ binary add                     ][|  ][Bin][ 0 ][->][ 1234 ][bytes]
line[ 13] type=diff-stat selected=0
line[ 13] cells=7 text=[ binary update                  ][|  ][Bin][ 1234 ][->][ 2345 ][bytes]
line[ 14] type=diff-stat selected=0
line[ 14] cells=3 text=[ binary copy                    ][|  ][Bin]
line[ 15] type=diff-stat selected=0
line[ 15] cells=7 text=[ binary del                     ][|  ][Bin][ 16787 ][->][ 0 ][bytes]
line[ 16] type=diff-stat selected=0
line[ 16] cells=2 text=[ unmerged                       ][| Unmerged]
line[ 17] type=default selected=0
line[ 17] cells=1 text=[ 42 file changed, 5 insertions(+), 2 deletions(-)]
line[ 18] type=default selected=0
line[ 18] cells=1 text=[]
line[ 19] type=diff-header selected=0
line[ 19] cells=1 text=[diff --git a/src/file.c b/src/file.c]
line[ 20] type=default selected=0
line[ 20] cells=1 text=[...]
EOF
