Fix %(commit) assignment in the diff view

Since commit 0c278556e52b9b78fde9f089cab755a6366d9ce6, the %(commit)
variable is badly overwritten with part of the commit title when we
highlight this line. For instance, browsing a commit message like this:

    linux: add support for [...]

    This text explains the patch
    [...]

will result in the %(commit) variable to be "ux:".
(the offset corresponds to strlen("commit ") which is LINE_COMMIT).

This patch reworks commit 0c278556e52b9b78fde9f089cab755a6366d9ce6:
"Fix regression causing incorect coloring of the commit title", to
set the line type to LINE_DEFAULT instead of LINE_COMMIT.

Closes #179

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
Add example showing how to show display submodule log in diffs

Proposed by Ingo Oeser.
Fixes #171
Provide mkstemps() work-around for platforms lacking it

The function mkstemps() isn't available in all libc implementations. In
glibc it first became available in 2.11. This is likely true of many
non-LINUX platforms as well.

The work-around is based on mkstemps() implementation from libiberty and
is kept inside its own source file under a new compat/ subdirectory. The
work-around can be enabled via configure (and config.make.in), via the
config.make file by adding the line 'NO_MKSTEMPS=y' or when calling make
by adding 'NO_MKSTEMPS=y' to its parameter list.

This fixes breakage that was introduced with a0fdac29 "Create temporary
file with name as suffix."

Fixes #152
Closes #175

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

Original patch by Drew reworked to make it easier to enable the
work-around when not using configure. Also, switched mkstemps()
implementation to that of libiberty instead of the adapted version from
Git.

Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
Provide proper work-around for missing setenv()

This patch removes the set_environment_variable() function that was
introduced by 46ef80d for compatibility reason, for platforms lacking
the setenv() function.

It borrows the setenv.c code from the libiberty. The work-around can be
enabled via configure (and config.make.in), via the config.make file by
adding the line 'NO_SETENV=y' or when calling make by adding
'NO_SETENV=y' to its parameter list.

Based on Drew's work for compat and mkstemps.c.

References: GH #156 #152
Closes #180

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
Add log_select function to find commit from context in log view

This commit introduces and uses the log_select function to find the
correct commit in the unsplit log view. In the log view, if one
scrolls down across a commit line, the current commit (as displayed in
the status bar) gets updated, but not so when scrolling upward across
a commit. The log_select function handles this scenario to do the
``right thing''. In addition, it introduces the log_state structure as
the private entry of the log view to hold a flag that decides whether
to re-evaluate the current commit based on scrolling.

Signed-off-by: Kumar Appaiah <a.kumar@alumni.iitm.ac.in>
Display correct diff the context in split log view

In the log view, when scrolling across a commit, the diff view should
automatically switch to the commit whose context the cursor is on in
the log view. This commit changes things to catch the REQ_ENTER in the
log view and handle recalculation of the commit and diff display from
log_request, rather than delegating it to pager_request. In addition,
it also gets rid of unexpected upward scrolling of the log view.

Fixes GH #155

Signed-Off-By: Kumar Appaiah <a.kumar@alumni.iitm.ac.in>
Revert "Scroll diff with arrow keys in log view"

This reverts commit 888611dd5d407775245d574a3dc5c01b5963a5ba. This is
because, in the re-engineered log view, scrolling the log with the
arrows now updates the diff in the diff view when the screen is
split. This resembles the earlier behaviour, and is also what users of
software like Mutt (which uses the pager view concept) would expect.

Signed-Off-By: Kumar Appaiah <a.kumar@alumni.iitm.ac.in>
Fix %(prompt) variable formatting

Without this patch, "%(prompt" (with a missing ending parenthesis) is
formatted and causes a segmentation fault.

Closes #181

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: Jonas Fonseca <fonseca@diku.dk>