app: Add fallback setStyleSheet() when running tests

The non-GUI code path is used by the tests.  setStyleSheet() is not
available fromm QCoreApplication so provide a stub.

Signed-off-by: David Aguilar <davvid@gmail.com>
settings: Provide default values to simplify the implementation

We were catching KeyError in a number of places to account for the fact
that the user's ~/.config/git-cola/settings json file may have missing
keys.

Instead of doing that, provide a default dictionary that we update with
the contents of that file.  This allows us to safely assume that the
keys are always available.

Signed-off-by: David Aguilar <davvid@gmail.com>
settings: Auto-remove repositories from the "Select Repository" dialog

Adjust the settings reader so that it skips over entries that no longer
exist.  This is done for both bookmarks and the recent repositories
list.

Closes #145

Signed-off-by: David Aguilar <davvid@gmail.com>
settings: Tighten the "repo exists" check

Instead of checking for existence, check that the bookmarked or recent-
repositories list contains git worktrees only.

Signed-off-by: David Aguilar <davvid@gmail.com>
cmds: Allow do() to return the command's result

Allow commands to return their result through the do() wrapper.

Signed-off-by: David Aguilar <davvid@gmail.com>
cmds: Use sys.executable instead of hard-coding 'python'

This makes the "clone + spawn" feature work correctly on
systems that do not have python2.x available as 'python'.

Signed-off-by: David Aguilar <davvid@gmail.com>
guicmds: Catch errors from "git clone"

Catch errors when cloning repositories and display them to the user.
This makes the "clone" operation more robust to typos and misconfigured
remotes.

Closes #156

Reported-by: @manituu via github.com
Signed-off-by: David Aguilar <davvid@gmail.com>
grep: Add a "Refresh" button

Ctrl+R now re-runs the grep and updates the output.  I found myself
needing this very often.

Signed-off-by: David Aguilar <davvid@gmail.com>
Makefile: Use a variable for all commands

This is a little more verbose in places but it lets folks have these
tools in non-standard locations.  This also cleans up the uninstall
target so that every command is on its own line.

Signed-off-by: David Aguilar <davvid@gmail.com>
Makefile: Export DESTDIR

Set DESTDIR in the environment to ensure that the documentation sub-
Makefiles honor the specified DESTDIR.

Signed-off-by: David Aguilar <davvid@gmail.com>
main.view: Avoid ambiguosly overloaded shortcut

Alt+D is the "Diffstat" shortcut but it was also being used to
trigger the "Diff" entry on the main menu.

Remove the main menu shortcut so that the "Diffstat" action
does not conflict with it.

Closes #159

Reported-by: Rustam Safin <rustiksnegovik@gmail.com>
Signed-off-by: David Aguilar <davvid@gmail.com>
widgets.diff: Save and restore selection across updates

git-cola's inotify integration causes it to automatically refresh itself
when files are changed by another process.

This can be problematic because refreshing the "diff" viewer causes it
to lose the user's selection.

Teach the "diff" viewer to save and restore the selection when its
contents change.  When no selection is present, restore the previous
cursor position.

Closes #155

Reported-by: Peter Júnoš <petoju@gmail.com>
Signed-off-by: David Aguilar <davvid@gmail.com>
cmds: Move the "commit" shortcut definition into the Commit class

We've been moving the shortcut definitions next to the commands for
simplicity.

Signed-off-by: David Aguilar <davvid@gmail.com>
utils: Make the text wrapper more robust

Import python 2.7's textwrap module as cola.textwrap.  Teach it to honor
a "tabwidth" setting so that we can replace our implementation with it.

utils.word_wrap() now wraps each line individually.  We special-case
sign-off lines and delegate to the TextWrapper otherwise.

Signed-off-by: David Aguilar <davvid@gmail.com>
utils: Do not quote repository paths on Windows

Older versions(?) of msysgit required us to quote repository
paths when passing them to "git clone".  Modern msysgit
(or Windows 8, I do not know) no longer requires this and
does the right thing as-is.

Simplify things by removing this outdated workaround.

Signed-off-by: David Aguilar <davvid@gmail.com>
commit: Alert the user when "git commit" fails

Show an informative dialog box when "git commit" returns a
non-zero exit status.  This prevents git-cola from failing
silently when a pre-commit hook aborts the commit.

Closes #160

Reported-by: Kerrick Staley <mail@kerrickstaley.com>
Signed-off-by: David Aguilar <davvid@gmail.com>
version: be more robust when parsing Git versions

We cannot assume that the last element is the git version
string.  Apple's build of git, for example, adds an extra
"(Apple build XX)" to the end of the version string.

Make the parsing more robust by splitting like we did
before, but taking the 3rd element instead of assuming
that the last element is the one that contains the
version string.
qtcompat: move setStyleSheet() patching here

Signed-off-by: David Aguilar <davvid@gmail.com>
diffparse: remove unused variable

Signed-off-by: David Aguilar <davvid@gmail.com>
widgets.completion: scrub trailing whitespace

Signed-off-by: David Aguilar <davvid@gmail.com>