Skip to content

Commit

Permalink
Properly display error messages during startup
Browse files Browse the repository at this point in the history
As reported by John Keeping, running "tig blame master" results in:

    user@host ~/src/tig $ tig blame master
    user@host ~/src/tig $d options to blame

    tig 2.0.3 (Dec 20 2014)

    Usage: tig        [options] [revs] [--] [paths]
       or: tig log    [options] [revs] [--] [paths]
       or: tig show   [options] [revs] [--] [paths]
       or: tig blame  [options] [rev] [--] path
       or: tig grep   [options] [pattern]
       or: tig refs
       or: tig stash
       or: tig status
       or: tig <      [git command output]

    Options:
      +<number>       Select line <number> in the first view
      -v, --version   Show version and exit
      -h, --help      Show help message and exit

with the cursor positioned on the second prompt above most of the error
output.

The problem is that done_display() and therefore endwin() is called
twice when die() is called. First via die_callback (which always points
to done_display() once init_display() has been called), and again by the
atexit() handler also installed once init_display() has been called.
atexit() must be there so that ncurses is "shutdown" when Tig exits due
to a signal. The fix therefore checks the "cursed" flag before calling
endwin().

Fixes #385
  • Loading branch information
jonas committed Mar 9, 2015
1 parent c6aea2e commit 277d5d8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions NEWS.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Bug fixes:
- Fix segfault when updating changes in a maximized stage view opened via the
main view. (GH #376)
- Handle line number configs where the interval is not specified. (GH #378)
- Fix display of error messages during startup. (GH #385)

tig-2.0.3
---------
Expand Down
4 changes: 3 additions & 1 deletion src/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,9 @@ report(const char *msg, ...)
static void
done_display(void)
{
endwin();
if (cursed)
endwin();
cursed = FALSE;
}

void
Expand Down

0 comments on commit 277d5d8

Please sign in to comment.