prompt: fix memleak of empty strings

The readline-enabled version of read_prompt() was memleaking 1-byte when
readline() returned an empty string. Free it first to fix it.

Refs #302
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Fix test result summary to only count succeeded and failed assertions

The .test-result files also contains the diff and for failures all diff
lines were counted. Now only lines containing "[OK]" or "[FAIL]" are
counted.
Add test option to start tig inside a debugger
Move repo setup method from main/show-changes-test to libgit
Reorder test directory setup and TEST_OPTS parsing
Add test option to show tig trace information
Partly restore old refresh behavior

This ensures that the current view is refreshed after returning from an
external command when `refresh-mode` is set to `after-command`. That was
what Tig used to do before the option was introduced. It special cases
the 'after-command' event to force a refresh in the current view.

The fix is tested to work in both the main and status view.

Fixes #289
Unify the color palette used for graph and ID drawing

Graph rendering will now use up to 14 colors if the terminal supports
boldified (highlighted) colors.

References #305
Add workaround for system dependent date comparison

The date injection used in the tests for the main view's "show-changes"
feature fails on some systems either because the TZ environment variable
does not work as expected or because the time to execute the test causes
the generated timestamp to be off (Cygwin). Fix both issues by simply
replacing the dates with a dummy string.

As reported by Ramsay Jones, the recent commit bac9dcef ("Add test for
displayment of index changes in the main view", 15-06-2014) adds a test
that fails on Linux (Mint 17).

The failures (5 failed assertions in the test/main/show-changes-test
test), are all due to the test expecting the timestamp on Un/staged
changes to be in UTC but they are actually in BST (DST for my timezone).

If I change the test, like so:

    $ git diff
    diff --git a/test/main/show-changes-test b/test/main/show-changes-test
    index df3c318..c337def 100755
    --- a/test/main/show-changes-test
    +++ b/test/main/show-changes-test
    @@ -59,7 +59,7 @@ in_work_dir prepare_git_repo

     test_tig

    -YYY_MM_DD_HH_MM="$(date +"%Y-%m-%d %H:%M")"
    +YYY_MM_DD_HH_MM="$(unset TZ; date +"%Y-%m-%d %H:%M")"

     assert_equals 'main-with-unstaged.screen' <<EOF
     $YYY_MM_DD_HH_MM Unknown    o Unstaged changes
    $

... then the test passes. This is not the fix, of course, it just helps
diagnose the problem. Note that if I run tig thus:

    $ TZ=UTC ./src/tig

... with an unstaged change, then the timestamp still shows as BST.
So, the handling of the tz data in main_add_changes_commit() seems
to be off somehow. (Isn't use of the tz parameter in gettimeofday()
discouraged because it's not portable/reliable?).

I should note that (on a different laptop) on 64-bit cygwin, the test
runs just fine - most of the time! :-P  Occasionally, it will fail with
the timestamp differing by one minute ...
Refresh the view after executing a backgrounded command

Change open_external_viewer to also handle commands executed in the
background so that a view refresh is correctly triggered.

References #289
Fix and improve status/refresh-test

Add a missing assertion for the command mentioned in issue #289 and
extend the test to test both checkout of modified and deleted files.
Change test scripts to always wait for previous command to finish

Simplify the script execution by eliminating the `:wait` command. The
asynchronous behavior only renders the tests non-deterministic.
Add refs/default-test
draw_text_overflow: fix wrong offsets for multibyte text.

[ jf: change to use utf8_length; added test ]
Add command-line option for starting in refs view

Signed-off-by: Sven Wegener <sven.wegener@stealer.net>