diff --git a/git-addsub b/git-addsub index 0267daa..348eb0f 100755 --- a/git-addsub +++ b/git-addsub @@ -12,7 +12,7 @@ for dir in "$@"; do SUBDIR=$(abspath "$dir") SUBDIR=$(echo $SUBDIR | sed s/$PROJ_RE//) - repo=$(echo $(grep "url = " "$dir/.git/config") | \ + repo=$(grep "url = " "$dir/.git/config" | \ sed 's/.*url = //' | \ sed 's/git@github.com:\([^\/]*\)\//git:\/\/github.com\/\1\//' ) diff --git a/git-clone.sh b/git-clone.sh index fcce503..49527fa 100755 --- a/git-clone.sh +++ b/git-clone.sh @@ -3,28 +3,21 @@ # this script clones a repository, including all its remote branches # Author: julianromera -GIT=$(command -v git) - -if [ "$1" = "" -o "$2" = "" ];then +if [[ -z "$1" || -z "$2" ]];then echo "use: $0 " exit 1 fi -if [ "$GIT" = "" ];then - echo "No git command found. install it" -fi function clone { - $GIT clone -q "$1" "$2" - res=$? - + git clone -q "$1" "$2" cd "$2" - $GIT pull --all + git pull --all - for remote in $($GIT branch -r | grep -v \>); do - $GIT branch --track "${remote#origin/}" "$remote"; + for remote in $(git branch -r | grep -v \>); do + git branch --track "${remote#origin/}" "$remote"; done } diff --git a/git-each b/git-each index 3e3f982..e7c3f3d 100755 --- a/git-each +++ b/git-each @@ -1,13 +1,12 @@ #!/usr/bin/env bash set -e -DIRS="." +dirs="." if [[ "$1" == --dir ]]; then - shift 1 - DIRS="$1" - shift 1 + dirs="$2" + shift 2 fi -exec find $DIRS \( -path '*/.git/config' -o \ +exec find $dirs \( -path '*/.git/config' -o \ -regex '.*/.git/.*/config' \) -type f -print0 \ - | parallel -0 --bar -j0 --delay 1 -k "git --git-dir={//} $@" + | parallel -0 --bar -j0 --delay 1 -k "git --git-dir={//} $*" diff --git a/git-fat-objects b/git-fat-objects index 5e128af..6f7eb3a 100755 --- a/git-fat-objects +++ b/git-fat-objects @@ -6,7 +6,7 @@ git rev-list --all --objects | \ grep blob | \ sort -n -k 3 | \ tail -n40 | \ - while read -r hash type size; do + while read -r hash _type size; do echo -n "-e s/$hash/$size/p "; done) | \ sort -n -k1 diff --git a/git-find-children b/git-find-children deleted file mode 100755 index ba3c185..0000000 --- a/git-find-children +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -if [[ $# == 0 ]]; then - echo usage: git find-children REFS... -fi - -for ref in "$@"; do - for sha1 in $(git rev-list "$@") - do - : - done -done diff --git a/git-fire-subtree/git-fire b/git-fire-subtree/git-fire index 98689cb..982db4a 100755 --- a/git-fire-subtree/git-fire +++ b/git-fire-subtree/git-fire @@ -49,7 +49,7 @@ fire() { done for sha in $(git rev-list -g stash); do - git push origin "$sha":refs/heads/"$(current_branch $initial_branch)"-stash-"$sha" + git push origin "$sha":refs/heads/"$(current_branch "$initial_branch")"-stash-"$sha" done printf "\n\nLeave building!\n" diff --git a/git-pulltree b/git-pulltree index 8850617..d352d27 100755 --- a/git-pulltree +++ b/git-pulltree @@ -1,2 +1,2 @@ #!/usr/bin/env bash -git subtree pull --prefix $1 ext/$(basename $1) master --squash +git subtree pull --prefix "$1" "ext/$(basename "$1")" master --squash diff --git a/git-pushtree b/git-pushtree index 214f328..99de9aa 100755 --- a/git-pushtree +++ b/git-pushtree @@ -1,2 +1,2 @@ #!/usr/bin/env bash -git subtree push --prefix $1 fork/$(basename $1) master +git subtree push --prefix "$1" "fork/$(basename "$1")" master diff --git a/git-remote-in-sync.sh b/git-remote-in-sync.sh index 317d069..900ea02 100755 --- a/git-remote-in-sync.sh +++ b/git-remote-in-sync.sh @@ -12,13 +12,13 @@ # written by Dieter Plaetinck -list="$@" +list="$*" [ -z "$list" ] && list=$(git remote) ret=0 if [ -z "$(git branch)" ] then - if [ $(cd "$(git root)" && ls -Al | egrep -v "^(.git|total)" | wc -l) -gt 0 ] + if [ "$(cd "$(git root)" && ls -Al | grep -Ev "^(.git|total)" | wc -l)" -gt 0 ] then echo "WARN: This repo doesn't contain any branch, but contains a bunch of files!" >&2 ls -Alh "$(git root)" @@ -39,10 +39,10 @@ then echo "WARN: At least one branch, but no remotes found! The content here might be unique!" >&2 ret=1 else - if [ -n "$@" ] + if [ -n "$*" ] then - echo "INFO: working with remote(s): $@" - echo "INFO: fyi, all remotes: "$(git remote) + echo "INFO: working with remote(s): $*" + echo "INFO: fyi, all remotes: $(git remote)" else echo "INFO: working with all remotes: $list" fi @@ -86,13 +86,13 @@ do IFS=$IFS_BACKUP # Check tags - out=$(git push --tags -n $remote 2>&1) + out=$(git push --tags -n "$remote" 2>&1) if [ "$out" != 'Everything up-to-date' ]; then echo -e " WARN: Some tags are not in $remote!\n$out" >&2 ret=1 else - echo " INFO: All tags ("$(git tag)") exist at $remote as well" + echo " INFO: All tags ($(git tag)) exist at $remote as well" fi done @@ -122,7 +122,7 @@ then fi # Check stash -if [ $(git stash list | wc -l) -gt 0 ]; +if [ "$(git stash list | wc -l)" -gt 0 ]; then echo "WARN: Dirty stash:" >&2 GIT_PAGER= git stash list >&2 diff --git a/git-standup b/git-standup index bc6bd89..cf65a49 100755 --- a/git-standup +++ b/git-standup @@ -1,7 +1,7 @@ #!/usr/bin/env bash if [[ $# -gt 2 ]] ; then - >&2 echo "Usage: $0 [fullname] [weekstart-weekend]\nExample: $0 \"John Doe\" MON-FRI" + >&2 printf '%s\n%s' "Usage: $0 [fullname] [weekstart-weekend]" "Example: $0 \"John Doe\" MON-FRI" exit 1 fi