Fix blame and status to work from within directories starting with a dot

When running `tig blame ../io.h' or `tig status' inside the directory
`.dir', the command:

	git rev-parse --git-dir --is-inside-work-tree --show-cdup --show-prefix

will print:

	/tig/.git
	true
	../
	.dir/

This cause read_repo_info() to confuse the show-prefix option output was
the output of the show-cdup option.

Fixes #172 reported by Azat Khuzhin.
Enable tilde expansion in ~/.tigrc "source" commands

... as used in the examples of the 'SOURCE COMMAND' section of tigrc(5).
Thanks to Johann Visagie for reporting this and providing an initial
patch.

Fixes #168
Fix unicode_width for combining characters

Combining characters have an effective width of zero because they just
modify an adjacent character. The commit fixes tree indentation issues
when using those kinds of characters.

Fixes #170

Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
Fix regression when running tig with no arguments and custom encoding

Since c7d67ab running "tig" with no options has failed with the error
"tig: No revisions match the given arguments." This was due to a change
in how the arguments for the back-end git call was being constructed.
This change caused the blank field left in place of "%(encoding_arg)"
when it is empty to not overwrite "buf" which then caused the value in
"buf" to be copied into dst_argv twice. The resulting git command failed
if there was no available revision named "log" as shown in the trace.

From the TIG_TRACE log:
git log log --no-color --pretty=raw --parents --parents --
fatal: bad revision 'log'

This fix works by properly and fully initializing "buf" before each use.

Fixes #167

Signed-off-by: Drew Northup <n1xim.email@gmail.com>

Minor edits of commit message and change patch to use sizeof(buf).

Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
Open editor at selected line also for multi-file diffs in the stage view

Refactor out diff_common_edit(), which extracts the diffed file path and
line numbers so it can be used for the case in stage_request() where
there's not a single file.
Introduce the stash view

This patch adds a new "stash" view, bound to the 'y' key.
This view displays the list of stashes. Pressing Enter on one of them
displays the corresponding change in a split view.

Running 'tig stash' opens directly the stash view.

A new %(stash) variable is added for bindings and commands.

A built-in command to pop the current stash is bound to 'P' in this
view. Other bindings may be added in the ~/.tigrc file, for instance:

    bind stash D !?git stash drop %(stash)
    bind stash A !?git stash apply %(stash)
    bind status S !?git stash save --keep-index %(prompt)

Fixes #169
Closes #174

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
Prepend the path to the repository root when editing a diff file

Fixes #165
Scroll diff with arrow keys in log view

This commit introduces the VIEW_NO_PARENT_NAV flag and adds it to the
log view. This allows the scrolling commands to fall through from the
pager to the diff when the diff is viewed in the log mode.

Signed-Off-By: Kumar Appaiah <a.kumar@alumni.iitm.ac.in>
Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
Crop text when title-overflow is enabled

Limit the length of the title text if less columns are available when
drawing the title. This fixes a glitch introduced with the original
title-overflow patch, where the title text would wrap to the next line
when rendered.

Improve the rendering when only part of the "non-overflowing" title text
is displayed by showing the '~' character to indicate that the text was
cropped.

Fixes #166
Only set LINES and COLUMNS environment variables for external commands

Setting the LINES/COLUMNS environment variables to a constant number
breaks ncurses' getmaxyx() logic, so dynamic resizing doesn't work as
pointed out by Marcel Partap in a comment to the fix for issue #151
(https://github.com/jonas/tig/commit/f0ad1f74#commitcomment-3528715).

As a work-around, only set LINES/COLUMNS when forking Git processes. This
way diff stats will still use the whole terminal width and resizing works
as intended.

Fixes #109
iconv: Ignore unrepresentable characters when transliterating

Certain characters where causing iconv() to fail, which resulted in
buggy rendering. By adding "//IGNORE" to the already existing
"//TRANSLIT" flag unrepresentable characters are automatically removed
from the resulting output.

    > echo "Nguyễn Thái Ngọc Duy" | iconv -f UTF-8 -t ASCII//TRANSLIT
    Nguy
    iconv: (stdin):1:4: cannot convert
    > echo "Nguyễn Thái Ngọc Duy" | iconv -f UTF-8 -t ASCII//TRANSLIT//IGNORE
    Nguyn Th'ai Ngc Duy
iconv: Move draw_chars encoding code to IO module
iconv: Convert characters before trimming text before rendering

By first trimming and then transliterating, characters which need two
characters to represent would cause the rendered text to get out of
alignment. An example can be seen by running:

	$ LANG=C ./tig 2324d6120c5de58f63b32b876bd33e99d7375dbb

Fix the misalignment by reversing the operations so that text is trimmed
after it has been transliterated.

Fixes #86
iconv: Remove unnecessary length argument to encoding_iconv
iconv: Consolidate convert methods into one single backend
stash: Use main view infrastructure for the stash view

Change the output to use "--pretty=raw", which is compatible with the
main view. This simplifies the parsing of the 'stash{X}' ID by using the
emitted 'Reflog' line and displays the stash date for free.

The reference to the stash is stored as the commit->id for easy access
when updating the status line (view->ref).

Fixes #169
stash: Refactor ID drawing method

Simpify the main method (draw_id) and add custom method for more
advanced requirements.
stash: Ensure that the whole stash@{_} text is shown

Fixes #169
stash: Highlight the diffstat of combined diffs

Fixes #169
Add utility method to help copy commit ID to revision buffer