mirror of
https://github.com/wfxr/forgit.git
synced 2026-09-12 08:16:22 -04:00
Refactor: Replace deferred extract variable in _forgit_add with a call to _forgit_get_single_file_from_add_line
This commit is contained in:
parent
64e5353af4
commit
71e691989e
|
|
@ -289,19 +289,13 @@ _forgit_edit_add_file() {
|
|||
# git add selector
|
||||
_forgit_add() {
|
||||
_forgit_inside_work_tree || return 1
|
||||
local changed unmerged untracked files opts extract
|
||||
local changed unmerged untracked files opts
|
||||
# Add files if passed as arguments
|
||||
[[ $# -ne 0 ]] && { _forgit_git_add "$@" && git status -su; return $?; }
|
||||
|
||||
changed=$(git config --get-color color.status.changed red)
|
||||
unmerged=$(git config --get-color color.status.unmerged red)
|
||||
untracked=$(git config --get-color color.status.untracked red)
|
||||
# NOTE: paths listed by 'git status -su' mixed with quoted and unquoted style
|
||||
# remove indicators | remove original path for rename case | remove surrounding quotes
|
||||
extract="
|
||||
sed 's/^.*] //' |
|
||||
sed 's/.* -> //' |
|
||||
sed -e 's/^\\\"//' -e 's/\\\"\$//'"
|
||||
opts="
|
||||
$FORGIT_FZF_DEFAULT_OPTS
|
||||
-0 -m --nth 2..,..
|
||||
|
|
@ -313,7 +307,7 @@ _forgit_add() {
|
|||
grep -F -e "$changed" -e "$unmerged" -e "$untracked" |
|
||||
sed -E 's/^(..[^[:space:]]*)[[:space:]]+(.*)$/[\1] \2/' |
|
||||
FZF_DEFAULT_OPTS="$opts" fzf |
|
||||
sh -c "$extract")
|
||||
_forgit_get_single_file_from_add_line)
|
||||
[[ -n "$files" ]] && echo "$files"| tr '\n' '\0' | _forgit_git_add --pathspec-file-nul --pathspec-from-file - && git status -su && return
|
||||
echo 'Nothing to add.'
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue