mirror of
https://github.com/wfxr/forgit.git
synced 2026-09-10 07:16:23 -04:00
Modify multiple files at once in ga & gcf (#279)
Checkout/Add files in a single command in _forgit_add and _forgit_checkout_file() instead of processing each file individually with xargs. This has the following benefits:
It's faster
Prevents git from spamming "Updated 1 path from the index" for each file when checking out files
This commit is contained in:
parent
be8c306c18
commit
c098bf2fb1
|
|
@ -170,7 +170,7 @@ _forgit_add() {
|
|||
sed -E 's/^(..[^[:space:]]*)[[:space:]]+(.*)$/[\1] \2/' |
|
||||
FZF_DEFAULT_OPTS="$opts" fzf |
|
||||
sh -c "$extract")
|
||||
[[ -n "$files" ]] && echo "$files"| tr '\n' '\0' |xargs -0 -I% git add % && git status -su && return
|
||||
[[ -n "$files" ]] && echo "$files"| tr '\n' '\0' | git add --pathspec-file-nul --pathspec-from-file - && git status -su && return
|
||||
echo 'Nothing to add.'
|
||||
}
|
||||
|
||||
|
|
@ -396,7 +396,7 @@ _forgit_checkout_file() {
|
|||
$FORGIT_CHECKOUT_FILE_FZF_OPTS
|
||||
"
|
||||
files="$(git ls-files --modified "$(git rev-parse --show-toplevel)"| FZF_DEFAULT_OPTS="$opts" fzf)"
|
||||
[[ -n "$files" ]] && echo "$files" | tr '\n' '\0' | xargs -0 -I% git checkout %
|
||||
[[ -n "$files" ]] && echo "$files" | tr '\n' '\0' | git checkout --pathspec-file-nul --pathspec-from-file -
|
||||
}
|
||||
|
||||
# git checkout-branch selector
|
||||
|
|
|
|||
Loading…
Reference in a new issue