Merge pull request #344 from Somasis/master

Prevent strange input and environment variables from causing issues
This commit is contained in:
hemanth.hm 2015-04-09 09:21:25 +05:30
commit c00202d51e
8 changed files with 10 additions and 8 deletions

View file

@ -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), \

View file

@ -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

View file

@ -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

View file

@ -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
}

View file

@ -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"

View file

@ -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() {

View file

@ -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(){

2
helper/reset-env Normal file
View file

@ -0,0 +1,2 @@
# reset environment variables that could interfere with normal usage
export GREP_OPTIONS=