Skip to content

Commit

Permalink
use command to avoid unexpected behavior (fix #97) (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasLarson committed Dec 5, 2021
1 parent 4bcfcda commit f172b48
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions bin/git-unstage
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ gunstage() {

# check whether we’re in a Git repository
# https://stackoverflow.com/a/53809163
if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
if command git rev-parse --is-inside-work-tree >/dev/null 2>&1; then

case $1 in
-A | --all)

# unstage everything
git reset --quiet HEAD -- "$(git rev-parse --show-toplevel)"
git status
command git reset --quiet HEAD -- "$(command git rev-parse --show-toplevel)"
command git status
;;

*)
Expand All @@ -37,10 +37,10 @@ gunstage() {
for file in "${@:-.}"; do

# https://github.com/gggritso/site/commit/a07b620
git reset --quiet HEAD -- "${file}"
command git reset --quiet HEAD -- "${file}"

# perform a `git status` only if the loop was successful
done && git status
done && command git status

;;
esac
Expand Down
2 changes: 1 addition & 1 deletion gunstage.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# by adding `bin` directory to `PATH`
# without adding an initial colon `:` to `PATH`
# https://unix.stackexchange.com/a/415028
PATH=${PATH:+${PATH}:}$(dirname "$0")/bin
PATH=${PATH:+${PATH}:}$(command dirname "$0")/bin
export PATH

# keep backwards compatibility
Expand Down

0 comments on commit f172b48

Please sign in to comment.