From 9f54c8d88b4e02f8b6b3f74c18dd57060ef035c4 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Tue, 29 Jun 2021 23:25:09 +0200 Subject: [PATCH] completions/git: don't offer deleted files to "git diff" unless we have a "--" Fixes #8090 --- share/completions/git.fish | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/share/completions/git.fish b/share/completions/git.fish index 5ce892abb..d79868ca4 100644 --- a/share/completions/git.fish +++ b/share/completions/git.fish @@ -1104,7 +1104,11 @@ complete -c git -n '__fish_git_using_command diff' -s 1 -l base -d 'Compare the complete -c git -n '__fish_git_using_command diff' -s 2 -l ours -d 'Compare the working tree with the "our branch"' complete -c git -n '__fish_git_using_command diff' -s 3 -l theirs -d 'Compare the working tree with the "their branch"' complete -c git -n '__fish_git_using_command diff' -s 0 -d 'Omit diff output for unmerged entries and just show "Unmerged"' -complete -c git -n '__fish_git_using_command diff; and not __fish_contains_opt cached staged' -a '(__fish_git_files modified deleted modified-staged-deleted)' +complete -c git -n '__fish_git_using_command diff; and not __fish_contains_opt cached staged' -a '( + set -l kinds modified + contains -- -- (commandline -opc) && set -a kinds deleted modified-staged-deleted + __fish_git_files $kinds +)' complete -c git -n '__fish_git_using_command diff; and __fish_contains_opt cached staged' -fa '(__fish_git_files all-staged)' ### Function to list available tools for git difftool and mergetool @@ -1121,7 +1125,11 @@ end complete -c git -n __fish_git_needs_command -a difftool -d 'Open diffs in a visual tool' complete -c git -n '__fish_git_using_command difftool; and not contains -- -- (commandline -opc)' -k -a '(__fish_git_ranges)' complete -c git -n '__fish_git_using_command difftool' -l cached -d 'Visually show diff of changes in the index' -complete -f -c git -n '__fish_git_using_command difftool' -a '(__fish_git_files modified deleted modified-staged-deleted)' +complete -f -c git -n '__fish_git_using_command difftool' -a '( + set -l kinds modified + contains -- -- (commandline -opc) && set -a kinds deleted modified-staged-deleted + __fish_git_files $kinds +)' complete -f -c git -n '__fish_git_using_command difftool' -s g -l gui -d 'Use `diff.guitool` instead of `diff.tool`' complete -f -c git -n '__fish_git_using_command difftool' -s d -l dir-diff -d 'Perform a full-directory diff' complete -c git -n '__fish_git_using_command difftool' -l prompt -d 'Prompt before each invocation of the diff tool'