mirror of
https://github.com/wfxr/forgit.git
synced 2026-09-10 07:16:23 -04:00
Merge pull request #95 from cjappl/fix-gcf-fish
fixed gcf, and a bunch of other things. Added git status before returns
This commit is contained in:
commit
3f62f39bbe
|
|
@ -83,7 +83,7 @@ end
|
|||
function forgit::add
|
||||
forgit::inside_work_tree || return 1
|
||||
# Add files if passed as arguments
|
||||
count $argv >/dev/null && git add "$argv" && return
|
||||
count $argv >/dev/null && git add "$argv" && git status --short && return
|
||||
|
||||
set changed (git config --get-color color.status.changed red)
|
||||
set unmerged (git config --get-color color.status.unmerged red)
|
||||
|
|
@ -119,6 +119,7 @@ function forgit::add
|
|||
for file in $files
|
||||
echo $file | tr '\n' '\0' | xargs -I{} -0 git add {}
|
||||
end
|
||||
git status --short
|
||||
return
|
||||
end
|
||||
echo 'Nothing to add.'
|
||||
|
|
@ -136,14 +137,16 @@ function forgit::reset::head
|
|||
set files (git diff --cached --name-only --relative | env FZF_DEFAULT_OPTS="$opts" fzf --preview="$cmd")
|
||||
if test -n "$files"
|
||||
for file in $files
|
||||
echo $file | tr '\n' '\0' |xargs -I{} -0 git reset -q HEAD {} && git status --short && return
|
||||
echo $file | tr '\n' '\0' |xargs -I{} -0 git reset -q HEAD {}
|
||||
end
|
||||
git status --short
|
||||
return
|
||||
end
|
||||
echo 'Nothing to unstage.'
|
||||
end
|
||||
|
||||
# git checkout-restore selector
|
||||
function forgit::restore
|
||||
function forgit::checkout_file
|
||||
forgit::inside_work_tree || return 1
|
||||
|
||||
set cmd "git diff --color=always -- {} | $forgit_pager"
|
||||
|
|
@ -156,8 +159,10 @@ function forgit::restore
|
|||
set files (git ls-files --modified "$git_rev_parse" | env FZF_DEFAULT_OPTS="$opts" fzf --preview="$cmd")
|
||||
if test -n "$files"
|
||||
for file in $files
|
||||
echo $file | tr '\n' '\0' |xargs -I{} -0 git checkout {} && git status --short && return
|
||||
echo $file | tr '\n' '\0' | xargs -I{} -0 git checkout -q {}
|
||||
end
|
||||
git status --short
|
||||
return
|
||||
end
|
||||
echo 'Nothing to restore.'
|
||||
end
|
||||
|
|
@ -188,8 +193,10 @@ function forgit::clean
|
|||
|
||||
if test -n "$files"
|
||||
for file in $files
|
||||
echo $file | tr '\n' '\0'|xargs -0 -I{} git clean -xdf {} && return
|
||||
echo $file | tr '\n' '\0'| xargs -0 -I{} git clean -xdf {}
|
||||
end
|
||||
git status --short
|
||||
return
|
||||
end
|
||||
echo 'Nothing to clean.'
|
||||
end
|
||||
|
|
@ -319,9 +326,9 @@ if test -z "$FORGIT_NO_ALIASES"
|
|||
end
|
||||
|
||||
if test -n "$forgit_restore"
|
||||
alias $forgit_restore 'forgit::restore'
|
||||
alias $forgit_restore 'forgit::checkout_file'
|
||||
else
|
||||
alias gcf 'forgit::restore'
|
||||
alias gcf 'forgit::checkout_file'
|
||||
end
|
||||
|
||||
if test -n "$forgit_clean"
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ forgit::diff() {
|
|||
forgit::add() {
|
||||
forgit::inside_work_tree || return 1
|
||||
# Add files if passed as arguments
|
||||
[[ $# -ne 0 ]] && git add "$@" && return
|
||||
[[ $# -ne 0 ]] && git add "$@" && git status -su && return
|
||||
|
||||
local changed unmerged untracked files opts preview extract
|
||||
changed=$(git config --get-color color.status.changed red)
|
||||
|
|
@ -142,7 +142,7 @@ forgit::clean() {
|
|||
"
|
||||
# Note: Postfix '/' in directory path should be removed. Otherwise the directory itself will not be removed.
|
||||
files=$(git clean -xdfn "$@"| sed 's/^Would remove //' | FZF_DEFAULT_OPTS="$opts" fzf |sed 's#/$##')
|
||||
[[ -n "$files" ]] && echo "$files" | tr '\n' '\0' | xargs -0 -I% git clean -xdf '%' && return
|
||||
[[ -n "$files" ]] && echo "$files" | tr '\n' '\0' | xargs -0 -I% git clean -xdf '%' && git status --short && return
|
||||
echo 'Nothing to clean.'
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue