Merge remote-tracking branch 'lenormf/fix-git-tools'

This commit is contained in:
Maxime Coste 2019-09-22 09:29:19 +10:00
commit 891a9f5fe6

View File

@ -36,6 +36,14 @@ Available commands:\n add\n rm\n blame\n commit\n checkout\n diff\n hide-
fi fi
} \ } \
git %{ evaluate-commands %sh{ git %{ evaluate-commands %sh{
cd_bufdir() {
dirname_buffer="${kak_buffile%/*}"
cd "${dirname_buffer}" 2>/dev/null || {
printf 'echo -markup {Error}Unable to change the current working directory to: %s' "${dirname_buffer}"
exit 1
}
}
show_git_cmd_output() { show_git_cmd_output() {
local filetype local filetype
case "$1" in case "$1" in
@ -56,6 +64,7 @@ Available commands:\n add\n rm\n blame\n commit\n checkout\n diff\n hide-
run_git_blame() { run_git_blame() {
( (
cd_bufdir
printf %s "evaluate-commands -client '$kak_client' %{ printf %s "evaluate-commands -client '$kak_client' %{
try %{ add-highlighter window/git-blame flag-lines Information git_blame_flags } try %{ add-highlighter window/git-blame flag-lines Information git_blame_flags }
set-option buffer=$kak_bufname git_blame_flags '$kak_timestamp' set-option buffer=$kak_bufname git_blame_flags '$kak_timestamp'
@ -91,7 +100,9 @@ Available commands:\n add\n rm\n blame\n commit\n checkout\n diff\n hide-
} }
update_diff() { update_diff() {
( cd "${kak_buffile%/*}" && git --no-pager diff -U0 "$kak_buffile" | perl -e ' (
cd_bufdir
git --no-pager diff -U0 "$kak_buffile" | perl -e '
$flags = $ENV{"kak_timestamp"}; $flags = $ENV{"kak_timestamp"};
foreach $line (<STDIN>) { foreach $line (<STDIN>) {
if ($line =~ /@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))?/) { if ($line =~ /@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))?/) {