Skip to content

Commit d57d5fc

Browse files
authored
Merge pull request #50 from hyperupcall/some-improvements
2 parents 1997296 + 96e66fb commit d57d5fc

20 files changed

+61
-61
lines changed

git-closest-match

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ range=${3:-30} # 'all' or most recent <num> in current branch?. 'all' can be qui
88
if [ "$range" = 'all' ]; then
99
all=$(git rev-list --all | awk '/^commit/ {print $NF}')
1010
else
11-
all=$(git log -n $range | awk '/^commit/ {print $NF}')
11+
all=$(git log -n "$range" | awk '/^commit/ {print $NF}')
1212
fi
1313

1414
commit=$(for i in $all; do
1515
printf '%s\n' "$i "
1616
# why is there no git diff --shortnumstat ?
17-
git diff -M $spec $i | wc -l
17+
git diff -M "$spec" $i | wc -l
1818
done | sort -k 2 -n | head -n 1 | cut -f 1 -d ' ')
1919
if [ "$mode" = diff ]; then
20-
git log --no-walk $commit | cat -
21-
git diff -M $spec $commit | cat -
20+
git log --no-walk "$commit" | cat -
21+
git diff -M "$spec" "$commit" | cat -
2222
else
2323
printf '%s\n' "$commit: "
24-
git diff -M $spec $commit | wc -l
24+
git diff -M "$spec" "$commit" | wc -l
2525
fi

git-cmpdir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ if [[ "$1" == "--stat" ]]; then
66
shift 1
77
fi
88

9-
git checkout $1
9+
git checkout "$1"
1010
sync
1111
echo ----------------------------------------------------------------------
1212

git-contr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
filePath=$1
44

5-
git blame --line-porcelain -C $filePath | sed -n 's/^author //p' |
5+
git blame --line-porcelain -C "$filePath" | sed -n 's/^author //p' |
66
sort | uniq -c | sort -rn

git-current

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ else
88
fi
99
current="$ancestor"
1010

11-
ancestor=$(git rev-parse $ancestor)
11+
ancestor=$(git rev-parse "$ancestor")
1212

1313
for head in $(git rev-parse --branches); do
14-
if [[ $head != $ancestor ]]; then
15-
if git rev-list -30 $head | grep -q $ancestor; then
16-
current="$current $(git describe --all --abbrev=0 $head | sed 's/heads\///')"
17-
fi
14+
if [[ $head != "$ancestor" ]]; then
15+
if git rev-list -30 "$head" | grep -q "$ancestor"; then
16+
current="$current $(git describe --all --abbrev=0 "$head" | sed 's/heads\///')"
17+
fi
1818
fi
1919
done
2020

21-
git show-branch $current
21+
git show-branch "$current"

git-delete-branch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/sh
22
# remove remote git branch
33

4-
git branch -D $1 && git push origin :$1
4+
git branch -D "$1" && git push origin ":$1"

git-delete-tag

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/sh
22
# remove remote git tag
33

4-
git tag -d $1
5-
git push origin :refs/tags/$1
4+
git tag -d "$1"
5+
git push origin ":refs/tags/$1"

git-diff-directory

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ fi
88

99
HERE=$(pwd)
1010

11-
(cd "$1" && git --git-dir=$HERE/.git diff ${2:-HEAD}) | \
11+
(cd "$1" && git --git-dir="$HERE/.git" diff "${2:-HEAD}") | \
1212
if [[ $stat == true ]]; then \
1313
diffstat | grep -v only$; \
1414
else \

git-discover-large-blobs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
#set -x
2+
#set -x
33

44
# Shows you the largest objects in your repo's pack file.
55
#
@@ -18,9 +18,9 @@
1818
IFS=$'\n';
1919

2020
# find top-level dir of a non-bare repo
21-
_GIT_DIR=`git rev-parse --show-toplevel` || exit 1
21+
_GIT_DIR=$(git rev-parse --show-toplevel) || exit 1
2222

23-
if [ -n ${_GIT_DIR} ] && [ -d ${_GIT_DIR}/.git/objects/pack ]; then
23+
if [ -n "${_GIT_DIR}" ] && [ -d "${_GIT_DIR}"/.git/objects/pack ]; then
2424
PACK_DIR=${_GIT_DIR}/.git/objects/pack
2525
elif [ -d ./objects/pack ]; then
2626
# bare repo
@@ -29,25 +29,25 @@ else
2929
echo "Cannot locate pack directory"
3030
exit 1
3131
fi
32-
32+
3333
# list all objects including their size, sort by size, take top 10
34-
objects=`git verify-pack -v ${PACK_DIR}/pack-*.idx | grep -v chain | sort -k3nr | head`
34+
objects=$(git verify-pack -v "${PACK_DIR}"/pack-*.idx | grep -v chain | sort -k3nr | head)
3535

3636
echo "All sizes are in kB's. The pack column is the size of the object, compressed, inside the pack file."
3737

3838
output="size,pack,SHA,location"
3939
for y in $objects
4040
do
4141
# extract the size in bytes
42-
size=$((`echo $y | cut -f 5 -d ' '`/1024))
42+
size=$(($(echo $y | cut -f 5 -d ' ')/1024))
4343
# extract the compressed size in bytes
44-
compressedSize=$((`echo $y | cut -f 6 -d ' '`/1024))
44+
compressedSize=$(($(echo $y | cut -f 6 -d ' ')/1024))
4545
# extract the SHA
46-
sha=`echo $y | cut -f 1 -d ' '`
46+
sha=$(echo $y | cut -f 1 -d ' ')
4747
# find the objects location in the repository tree
48-
other=`git rev-list --all --objects | grep $sha`
48+
other=$(git rev-list --all --objects | grep "$sha")
4949
#lineBreak=`echo -e "\n"`
5050
output="${output}\n${size},${compressedSize},${other}"
5151
done
5252

53-
echo -e $output | column -t -s ', '
53+
echo -e "$output" | column -t -s ', '

git-empty-branch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh
22

33
git stash
4-
git symbolic-ref HEAD refs/heads/$1
4+
git symbolic-ref HEAD "refs/heads/$1"
55
rm .git/index
66
git clean -f -d

git-fat-objects

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ git rev-list --all --objects | \
66
grep blob | \
77
sort -n -k 3 | \
88
tail -n40 | \
9-
while read hash type size; do
9+
while read -r hash type size; do
1010
echo -n "-e s/$hash/$size/p ";
1111
done) | \
12-
sort -n -k1
12+
sort -n -k1

0 commit comments

Comments
 (0)