#!/bin/sh

. libtest.sh
. libgit.sh
. "$source_dir/util.sh"

export LINES=5

steps '
	:save-display main-with-unstaged.screen

	:exec @git add a
	:save-display main-after-add-a.screen

	:exec @git add -u
	:save-display main-after-add-all.screen

	:exec @git commit -m "Commit changes"
	:save-display main-after-commit.screen

	:exec @git reset --soft HEAD^
	:save-display main-after-reset-soft.screen

	:exec @git reset a b.c
	:save-display main-after-reset-a-and-bc.screen

	:exec @git reset --hard
	:save-display main-after-reset-hard.screen
'

tigrc <<EOF
set refresh-mode = after-command
EOF

in_work_dir create_dirty_workdir

export GIT_AUTHOR_DATE="$(expr "$author_date" + "$author_date_delta")"
export GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"

test_tig

assert_equals 'main-with-unstaged.screen' <<EOF
$YYY_MM_DD_HH_MM +0000 Not Committed Yet o Unstaged changes
2009-02-13 23:31 +0000 A. U. Thor I [master] Initial commit

[main] Unstaged changes                                                     100%
EOF

assert_equals 'main-after-add-a.screen' <<EOF
$YYY_MM_DD_HH_MM +0000 Not Committed Yet o Unstaged changes
$YYY_MM_DD_HH_MM +0000 Not Committed Yet o Staged changes
2009-02-13 23:31 +0000 A. U. Thor I [master] Initial commit
[main] Unstaged changes                                                     100%
EOF

assert_equals 'main-after-add-all.screen' <<EOF
$YYY_MM_DD_HH_MM +0000 Not Committed Yet o Staged changes
2009-02-13 23:31 +0000 A. U. Thor I [master] Initial commit

[main] Staged changes                                                       100%
EOF

assert_equals 'main-after-commit.screen' <<EOF
2009-02-22 11:53 +0000 Committer  o [master] Commit changes
2009-02-13 23:31 +0000 A. U. Thor I Initial commit

[main] 559565d219fd061c3cec4f2071025374533bdfc6 - commit 1 of 2             100%
EOF

assert_equals 'main-after-reset-soft.screen' <<EOF
$YYY_MM_DD_HH_MM +0000 Not Committed Yet o Staged changes
2009-02-13 23:31 +0000 A. U. Thor I [master] Initial commit

[main] Staged changes                                                       100%
EOF

assert_equals 'main-after-reset-a-and-bc.screen' <<EOF
$YYY_MM_DD_HH_MM +0000 Not Committed Yet o Unstaged changes
$YYY_MM_DD_HH_MM +0000 Not Committed Yet o Staged changes
2009-02-13 23:31 +0000 A. U. Thor I [master] Initial commit
[main] Unstaged changes                                                     100%
EOF

assert_equals 'main-after-reset-hard.screen' <<EOF
2009-02-13 23:31 +0000 A. U. Thor I [master] Initial commit


[main] ca34b8bb5a0034fc5b5ab9840f74cae1fab2c3a9 - commit 1 of 1             100%
EOF
