From 336501382ecec8324f8d826f1148d256764b3234 Mon Sep 17 00:00:00 2001 From: Kylie McClain Date: Wed, 8 Apr 2015 18:50:41 -0400 Subject: [PATCH 1/2] helper/reset-env: helper to prevent GREP_OPTIONS from causing issues --- Makefile | 2 +- helper/reset-env | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 helper/reset-env diff --git a/Makefile b/Makefile index d3a6a64..f52064d 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ BINS = $(wildcard bin/git-*) MANS = $(wildcard man/git-*.md) MAN_HTML = $(MANS:.md=.html) MAN_PAGES = $(MANS:.md=.1) -LIB = "helper/git-extra-utility" +LIB = "helper/reset-env" "helper/git-extra-utility" COMMANDS_USED_WITHOUT_GIT_REPO = git-alias git-extras git-fork git-setup COMMANDS_USED_WITH_GIT_REPO = $(filter-out $(COMMANDS_USED_WITHOUT_GIT_REPO), \ diff --git a/helper/reset-env b/helper/reset-env new file mode 100644 index 0000000..bef6bf9 --- /dev/null +++ b/helper/reset-env @@ -0,0 +1,2 @@ +# reset environment variables that could interfere with normal usage +export GREP_OPTIONS= From 5b1ac3ccc69f65f8670746f5e0b9c14653cf6685 Mon Sep 17 00:00:00 2001 From: Kylie McClain Date: Wed, 8 Apr 2015 18:51:30 -0400 Subject: [PATCH 2/2] use argument separator for usages of `grep` which can choke on weird input --- bin/git-alias | 2 +- bin/git-contrib | 4 ++-- bin/git-ignore | 2 +- bin/git-scp | 2 +- bin/git-squash | 2 +- etc/bash_completion.sh | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bin/git-alias b/bin/git-alias index 7d7437b..5a93f0d 100755 --- a/bin/git-alias +++ b/bin/git-alias @@ -2,6 +2,6 @@ case $# in 0) git config --get-regexp 'alias.*' | colrm 1 6 | sed 's/[ ]/ = /' | sort ;; - 1) git alias | grep -e "$1" ;; + 1) git alias | grep -e -- "$1" ;; *) git config --global "alias.$1" "$2" ;; esac diff --git a/bin/git-contrib b/bin/git-contrib index b4320a3..1dbea52 100755 --- a/bin/git-contrib +++ b/bin/git-contrib @@ -4,6 +4,6 @@ user="$*" test -z "$user" && echo "user name required." 1>&2 && exit 1 -count=`git log --oneline --pretty="format: %an" | grep "$user" | wc -l` +count=`git log --oneline --pretty="format: %an" | grep -- "$user" | wc -l` test $count -eq 0 && echo "$user did not contribute." && exit 1 -git shortlog | grep "$user (" -A $count +git shortlog | grep -- "$user (" -A $count diff --git a/bin/git-ignore b/bin/git-ignore index 0938297..62207b2 100755 --- a/bin/git-ignore +++ b/bin/git-ignore @@ -32,7 +32,7 @@ function add_patterns { local file="${1/#~/$HOME}" for pattern in "${@:2}"; do echo "... adding '$pattern'" - (test -f "$file" && test "$pattern" && grep -q "$pattern" "$file") || echo "$pattern" >> "$file" + (test -f "$file" && test "$pattern" && grep -q -- "$pattern" "$file") || echo "$pattern" >> "$file" done } diff --git a/bin/git-scp b/bin/git-scp index 6ae8298..ae9737a 100755 --- a/bin/git-scp +++ b/bin/git-scp @@ -18,7 +18,7 @@ function _test_git_scp() function set_remote() { remote=$1 - if [ $(git remote | grep -c ^$remote$) -eq 0 ] + if [ $(git remote | grep -c -- ^$remote$) -eq 0 ] then COLOR_RED echo "Remote $remote does not exist in your git config" diff --git a/bin/git-squash b/bin/git-squash index a240b0b..249db5e 100755 --- a/bin/git-squash +++ b/bin/git-squash @@ -14,7 +14,7 @@ is_commit_reference() { is_on_current_branch() { local commit_sha=`git rev-parse "$src"` git rev-list HEAD | - grep -q "$commit_sha" + grep -q -- "$commit_sha" } commit_if_msg_provided() { diff --git a/etc/bash_completion.sh b/etc/bash_completion.sh index 645ee06..fb780e0 100644 --- a/etc/bash_completion.sh +++ b/etc/bash_completion.sh @@ -69,7 +69,7 @@ _git_extras(){ } __git_extras_workflow(){ - __gitcomp "$(__git_heads | grep ^$1/ | sed s/^$1\\///g) finish" + __gitcomp "$(__git_heads | grep -- ^$1/ | sed s/^$1\\///g) finish" } _git_feature(){