mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 04:43:10 +00:00
Fix the git completion
Commit 6e56637cf
ran fish_indent on the git completion and mangled some
of it. Manually revert the non-essential changes.
This commit is contained in:
parent
61ab3aea8c
commit
358e9def5b
1 changed files with 17 additions and 13 deletions
|
@ -6,18 +6,25 @@ function __fish_git_commits
|
||||||
# This allows filtering by subject with the new pager!
|
# This allows filtering by subject with the new pager!
|
||||||
# Because even subject lines can be quite long,
|
# Because even subject lines can be quite long,
|
||||||
# trim them (abbrev'd hash+tab+subject) to 73 characters
|
# trim them (abbrev'd hash+tab+subject) to 73 characters
|
||||||
command git log --pretty=tformat:"%h"\t"%s" --all --max-count=1000 2>/dev/null | string replace -r '(.{73}).+' '$1…'
|
command git log --pretty=tformat:"%h"\t"%s" --all --max-count=1000 2>/dev/null \
|
||||||
|
| string replace -r '(.{73}).+' '$1…'
|
||||||
end
|
end
|
||||||
|
|
||||||
function __fish_git_recent_commits
|
function __fish_git_recent_commits
|
||||||
# Like __fish_git_commits, but not on all branches and limited to
|
# Like __fish_git_commits, but not on all branches and limited to
|
||||||
# the last 50 commits. Used for fixup, where only the current branch
|
# the last 50 commits. Used for fixup, where only the current branch
|
||||||
# and the latest commits make sense.
|
# and the latest commits make sense.
|
||||||
command git log --pretty=tformat:"%h"\t"%s" --max-count=50 2>/dev/null | string replace -r '(.{73}).+' '$1…'
|
command git log --pretty=tformat:"%h"\t"%s" --max-count=50 2>/dev/null \
|
||||||
|
| string replace -r '(.{73}).+' '$1…'
|
||||||
end
|
end
|
||||||
|
|
||||||
function __fish_git_branches
|
function __fish_git_branches
|
||||||
command git branch --no-color -a $argv 2>/dev/null # Filter out detached heads and such ("(HEAD detached at SOMESHA)", localized). | string match -v '\* (*)' | string match -r -v ' -> ' | string trim -c "* " # We assume anything that's not remote is a local branch. | string replace -r '^(?!remotes/)(.*)' '$1\tLocal Branch' | string replace -r "^remotes/(.*)" '$1\tRemote Branch'
|
command git branch --no-color -a $argv 2>/dev/null \
|
||||||
|
# Filter out detached heads and such ("(HEAD detached at SOMESHA)", localized).
|
||||||
|
| string match -v '\* (*)' | string match -r -v ' -> ' | string trim -c "* " \
|
||||||
|
# We assume anything that's not remote is a local branch.
|
||||||
|
| string replace -r '^(?!remotes/)(.*)' '$1\tLocal Branch' \
|
||||||
|
| string replace -r "^remotes/(.*)" '$1\tRemote Branch'
|
||||||
end
|
end
|
||||||
|
|
||||||
function __fish_git_tags
|
function __fish_git_tags
|
||||||
|
@ -89,7 +96,8 @@ function __fish_git_files
|
||||||
# E.g. `git reset $submodule` won't do anything (not even print an error).
|
# E.g. `git reset $submodule` won't do anything (not even print an error).
|
||||||
# --ignore-submodules=all was added in git 1.7.2, released July 2010.
|
# --ignore-submodules=all was added in git 1.7.2, released July 2010.
|
||||||
set -l use_next
|
set -l use_next
|
||||||
command git status --porcelain -z --ignore-submodules=all | while read -lz -d '' line
|
command git status --porcelain -z --ignore-submodules=all \
|
||||||
|
| while read -lz -d '' line
|
||||||
# The entire line is the "from" from a rename.
|
# The entire line is the "from" from a rename.
|
||||||
if set -q use_next[1]
|
if set -q use_next[1]
|
||||||
if contains -- $use_next $argv
|
if contains -- $use_next $argv
|
||||||
|
@ -136,8 +144,7 @@ function __fish_git_files
|
||||||
case 'A ' AM AD
|
case 'A ' AM AD
|
||||||
# Additions are only shown here if they are staged.
|
# Additions are only shown here if they are staged.
|
||||||
# Otherwise it's an untracked file.
|
# Otherwise it's an untracked file.
|
||||||
contains -- added $argv
|
contains -- added $argv; or contains -- all-staged $argv
|
||||||
or contains -- all-staged $argv
|
|
||||||
and printf '%s\t%s\n' "$file" $added_desc
|
and printf '%s\t%s\n' "$file" $added_desc
|
||||||
case '*M'
|
case '*M'
|
||||||
# Modified
|
# Modified
|
||||||
|
@ -148,8 +155,7 @@ function __fish_git_files
|
||||||
# which means it is staged.
|
# which means it is staged.
|
||||||
# This is useless for many commands - e.g. `checkout` won't do anything with this.
|
# This is useless for many commands - e.g. `checkout` won't do anything with this.
|
||||||
# So it needs to be requested explicitly.
|
# So it needs to be requested explicitly.
|
||||||
contains -- modified-staged $argv
|
contains -- modified-staged $argv; or contains -- all-staged $argv
|
||||||
or contains -- all-staged $argv
|
|
||||||
and printf '%s\t%s\n' "$file" $staged_modified_desc
|
and printf '%s\t%s\n' "$file" $staged_modified_desc
|
||||||
case '*D'
|
case '*D'
|
||||||
contains -- deleted $argv
|
contains -- deleted $argv
|
||||||
|
@ -159,8 +165,7 @@ function __fish_git_files
|
||||||
# There is both X unmodified and Y either M or D ("not updated")
|
# There is both X unmodified and Y either M or D ("not updated")
|
||||||
# and Y is D and X is unmodified or [MARC] ("deleted in work tree").
|
# and Y is D and X is unmodified or [MARC] ("deleted in work tree").
|
||||||
# For our purposes, we assume this is a staged deletion.
|
# For our purposes, we assume this is a staged deletion.
|
||||||
contains -- deleted-staged $argv
|
contains -- deleted-staged $argv; or contains -- all-staged $argv
|
||||||
or contains -- all-staged $argv
|
|
||||||
and printf '%s\t%s\n' "$file" $staged_deleted_desc
|
and printf '%s\t%s\n' "$file" $staged_deleted_desc
|
||||||
case '\?\?'
|
case '\?\?'
|
||||||
# Untracked
|
# Untracked
|
||||||
|
@ -196,8 +201,7 @@ end
|
||||||
function __fish_git_needs_command
|
function __fish_git_needs_command
|
||||||
set cmd (commandline -opc)
|
set cmd (commandline -opc)
|
||||||
set -l skip_next 1
|
set -l skip_next 1
|
||||||
set -q cmd[2]
|
set -q cmd[2]; or return 0
|
||||||
or return 0
|
|
||||||
# Skip first word because it's "git" or a wrapper
|
# Skip first word because it's "git" or a wrapper
|
||||||
for c in $cmd[2..-1]
|
for c in $cmd[2..-1]
|
||||||
test $skip_next -eq 0
|
test $skip_next -eq 0
|
||||||
|
|
Loading…
Reference in a new issue