From 410d92ed6108e881ef40c88dbbf68c274f833d32 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Sat, 4 Jun 2016 12:26:06 +0200 Subject: git completions: Ignore stderr everywhere This allows us to run git commands outside of a git repo. Fixes #3114. --- share/completions/git.fish | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'share') diff --git a/share/completions/git.fish b/share/completions/git.fish index 8c521663..09359270 100644 --- a/share/completions/git.fish +++ b/share/completions/git.fish @@ -6,7 +6,8 @@ function __fish_git_commits # This allows filtering by subject with the new pager! # Because even subject lines can be quite long, # trim them (abbrev'd hash+tab+subject) to 70 characters - command git log --pretty=tformat:"%h"\t"%s" --all | string replace -r '(.{70}).+' '$1...' + command git log --pretty=tformat:"%h"\t"%s" --all ^/dev/null \ + | string replace -r '(.{70}).+' '$1...' end function __fish_git_branches @@ -34,19 +35,19 @@ end function __fish_git_modified_files # git diff --name-only hands us filenames relative to the git toplevel - set -l root (command git rev-parse --show-toplevel) + set -l root (command git rev-parse --show-toplevel ^/dev/null) # Print files from the current $PWD as-is, prepend all others with ":/" (relative to toplevel in git-speak) # This is a bit simplistic but finding the lowest common directory and then replacing everything else in $PWD with ".." is a bit annoying string replace -- "$PWD/" "" "$root/"(command git diff --name-only ^/dev/null) | string replace "$root/" ":/" end function __fish_git_staged_files - set -l root (command git rev-parse --show-toplevel) + set -l root (command git rev-parse --show-toplevel ^/dev/null) string replace -- "$PWD/" "" "$root/"(command git diff --staged --name-only ^/dev/null) | string replace "$root/" ":/" end function __fish_git_add_files - set -l root (command git rev-parse --show-toplevel) + set -l root (command git rev-parse --show-toplevel ^/dev/null) string replace -- "$PWD/" "" "$root/"(command git -C $root ls-files -mo --exclude-standard ^/dev/null) | string replace "$root/" ":/" end @@ -200,7 +201,7 @@ function __fish_git_possible_commithash end function __fish_git_reflog - command git reflog | string replace -r '[0-9a-f]* (.+@\{[0-9]+\}): (.*)$' '$1\t$2' + command git reflog ^/dev/null | string replace -r '[0-9a-f]* (.+@\{[0-9]+\}): (.*)$' '$1\t$2' end # general options -- cgit v1.2.3