Skip to content

Commit

Permalink
chore: Improve quoting
Browse files Browse the repository at this point in the history
  • Loading branch information
hyperupcall committed Jan 22, 2023
1 parent dc529e6 commit 96e66fb
Show file tree
Hide file tree
Showing 20 changed files with 61 additions and 61 deletions.
10 changes: 5 additions & 5 deletions git-closest-match
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ range=${3:-30} # 'all' or most recent <num> in current branch?. 'all' can be qui
if [ "$range" = 'all' ]; then
all=$(git rev-list --all | awk '/^commit/ {print $NF}')
else
all=$(git log -n $range | awk '/^commit/ {print $NF}')
all=$(git log -n "$range" | awk '/^commit/ {print $NF}')
fi

commit=$(for i in $all; do
printf '%s\n' "$i "
# why is there no git diff --shortnumstat ?
git diff -M $spec $i | wc -l
git diff -M "$spec" $i | wc -l
done | sort -k 2 -n | head -n 1 | cut -f 1 -d ' ')
if [ "$mode" = diff ]; then
git log --no-walk $commit | cat -
git diff -M $spec $commit | cat -
git log --no-walk "$commit" | cat -
git diff -M "$spec" "$commit" | cat -
else
printf '%s\n' "$commit: "
git diff -M $spec $commit | wc -l
git diff -M "$spec" "$commit" | wc -l
fi
2 changes: 1 addition & 1 deletion git-cmpdir
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if [[ "$1" == "--stat" ]]; then
shift 1
fi

git checkout $1
git checkout "$1"
sync
echo ----------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion git-contr
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

filePath=$1

git blame --line-porcelain -C $filePath | sed -n 's/^author //p' |
git blame --line-porcelain -C "$filePath" | sed -n 's/^author //p' |
sort | uniq -c | sort -rn
12 changes: 6 additions & 6 deletions git-current
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ else
fi
current="$ancestor"

ancestor=$(git rev-parse $ancestor)
ancestor=$(git rev-parse "$ancestor")

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

git show-branch $current
git show-branch "$current"
2 changes: 1 addition & 1 deletion git-delete-branch
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
# remove remote git branch

git branch -D $1 && git push origin :$1
git branch -D "$1" && git push origin ":$1"
4 changes: 2 additions & 2 deletions git-delete-tag
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
# remove remote git tag

git tag -d $1
git push origin :refs/tags/$1
git tag -d "$1"
git push origin ":refs/tags/$1"
2 changes: 1 addition & 1 deletion git-diff-directory
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fi

HERE=$(pwd)

(cd "$1" && git --git-dir=$HERE/.git diff ${2:-HEAD}) | \
(cd "$1" && git --git-dir="$HERE/.git" diff "${2:-HEAD}") | \
if [[ $stat == true ]]; then \
diffstat | grep -v only$; \
else \
Expand Down
20 changes: 10 additions & 10 deletions git-discover-large-blobs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
#set -x
#set -x

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

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

if [ -n ${_GIT_DIR} ] && [ -d ${_GIT_DIR}/.git/objects/pack ]; then
if [ -n "${_GIT_DIR}" ] && [ -d "${_GIT_DIR}"/.git/objects/pack ]; then
PACK_DIR=${_GIT_DIR}/.git/objects/pack
elif [ -d ./objects/pack ]; then
# bare repo
Expand All @@ -29,25 +29,25 @@ else
echo "Cannot locate pack directory"
exit 1
fi

# list all objects including their size, sort by size, take top 10
objects=`git verify-pack -v ${PACK_DIR}/pack-*.idx | grep -v chain | sort -k3nr | head`
objects=$(git verify-pack -v "${PACK_DIR}"/pack-*.idx | grep -v chain | sort -k3nr | head)

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

output="size,pack,SHA,location"
for y in $objects
do
# extract the size in bytes
size=$((`echo $y | cut -f 5 -d ' '`/1024))
size=$(($(echo $y | cut -f 5 -d ' ')/1024))
# extract the compressed size in bytes
compressedSize=$((`echo $y | cut -f 6 -d ' '`/1024))
compressedSize=$(($(echo $y | cut -f 6 -d ' ')/1024))
# extract the SHA
sha=`echo $y | cut -f 1 -d ' '`
sha=$(echo $y | cut -f 1 -d ' ')
# find the objects location in the repository tree
other=`git rev-list --all --objects | grep $sha`
other=$(git rev-list --all --objects | grep "$sha")
#lineBreak=`echo -e "\n"`
output="${output}\n${size},${compressedSize},${other}"
done

echo -e $output | column -t -s ', '
echo -e "$output" | column -t -s ', '
2 changes: 1 addition & 1 deletion git-empty-branch
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

git stash
git symbolic-ref HEAD refs/heads/$1
git symbolic-ref HEAD "refs/heads/$1"
rm .git/index
git clean -f -d
4 changes: 2 additions & 2 deletions git-fat-objects
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ git rev-list --all --objects | \
grep blob | \
sort -n -k 3 | \
tail -n40 | \
while read hash type size; do
while read -r hash type size; do
echo -n "-e s/$hash/$size/p ";
done) | \
sort -n -k1
sort -n -k1
2 changes: 1 addition & 1 deletion git-fetch-github
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env bash
REMOTE=${1:-origin}
git config remote.${REMOTE}.fetch "+refs/pull/*:refs/remotes/${REMOTE}/pr/*"
git config "remote.${REMOTE}.fetch" "+refs/pull/*:refs/remotes/${REMOTE}/pr/*"
2 changes: 1 addition & 1 deletion git-filemerge
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ TMPDIR1=$(mktemp -d)
git archive --format=tar $OLD | (cd "$TMPDIR1"; tar xf -)
if test -z "$NEW"; then
TMPDIR2=$(git rev-parse --show-cdup)
test -z "$cdup" && TMPDIR2=.
test -z "$TMPDIR2" && TMPDIR2=.
else
TMPDIR2=$(mktemp -d)
git archive --format=tar $NEW | (cd "$TMPDIR2"; tar xf -)
Expand Down
6 changes: 3 additions & 3 deletions git-find-blob
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ filename=$1

want=$(git hash-object "$filename")

git rev-list --since="6 months ago" HEAD | while read commit ; do
git ls-tree -r $commit | while read perm type hash filename; do
git rev-list --since="6 months ago" HEAD | while read -r commit ; do
git ls-tree -r "$commit" | while read -r perm type hash filename; do
if test "$want" = "$hash"; then
echo matched $filename in commit $commit
echo "matched $filename in commit $commit"
fi
done
done
2 changes: 1 addition & 1 deletion git-find-useful-dangling-trees
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ depth=${1:-all} # 'all' or number of depth
for i in $(git fsck --unreachable | grep -E 'tree|commit' | cut -d\ -f3)
do
echo -n "U:$i CM:"
git-closest-match $i num $depth
git-closest-match "$i" num "$depth"
done
4 changes: 2 additions & 2 deletions git-flush
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
# as possible, by dropping all reflogs, stashes, and other cruft that may
# be bloating your pack files.

/bin/rm -fr .git/refs/original
/bin/rm -fr .git/refs/snapshots
rm -fr .git/refs/original
rm -fr .git/refs/snapshots

if [ -f .git/info/refs ]; then
perl -i -ne 'print unless /refs\/original/;' .git/info/refs
Expand Down
4 changes: 2 additions & 2 deletions git-follow
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh

CURRENT=$(basename $(pwd))
CURRENT=$(basename "$(pwd)")

git remote add -t master -f $1 git://github.com/$1/$CURRENT.git
git remote add -t master -f "$1" "git://github.com/$1/$CURRENT.git"
2 changes: 1 addition & 1 deletion git-hunt-and-seek
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash

for hash in $(grep ^commit | awk '{print $2}'); do
git diff-directory $1 $hash
git diff-directory "$1" "$hash"
done
26 changes: 13 additions & 13 deletions git-ignore-wizard
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# basename

file=$1
if [ -z "$file" -o ! -e "$file" ]
if [[ -z "$file" || ! -e "$file" ]]
then
echo 'No such file or directory' >&2
exit 2
Expand All @@ -21,24 +21,24 @@ exclude # specific to it's repo, but irrelevant to other devs

[ -z "$type" ] && echo 'Cancelled' && exit 0

dirname=$( dirname $file)
basename=$(basename $file)
dirname=$( dirname "$file")
basename=$(basename "$file")
case $type in
.gitignore-root)
root=$(git root $file) || exit 2
dirname=$(readlink -f $dirname)
relative_dir=$(echo $dirname | sed "s#^$root##") # ie: /src
echo "$relative_dir/$basename" >> $root/.gitignore
root=$(git root "$file") || exit 2
dirname=$(readlink -f "$dirname")
relative_dir=$(echo "$dirname" | sed "s#^$root##") # ie: /src
echo "$relative_dir/$basename" >> "$root/.gitignore"
;;
.gitignore-dirname)
git root $file >/dev/null || exit 2
echo "$basename" >> $dirname/.gitignore
git root "$file ">/dev/null || exit 2
echo "$basename" >> "$dirname/.gitignore"
;;
exclude)
root=$(git root $file) || exit 2
dirname=$(readlink -f $dirname)
relative_dir=$(echo $dirname | sed "s#^$root##")
echo "$relative_dir/$basename" >> $root/info/exclude
root=$(git root "$file") || exit 2
dirname=$(readlink -f "$dirname")
relative_dir=$(echo "$dirname" | sed "s#^$root##")
echo "$relative_dir/$basename" >> "$root/info/exclude"
;;
.gitconfig)
#TODO. git config --get-all ?, then another dmenu? how many such config keys are allowed?
Expand Down
2 changes: 1 addition & 1 deletion git-igunk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh

git ls-files --other --exclude-standard | while read path; do
git ls-files --other --exclude-standard | while read -r path; do
echo "/$path" >> .gitignore
done
12 changes: 6 additions & 6 deletions git-interactive-merge
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ then
fi
from=$1
to=$2
git checkout $from
git checkout -b ${from}_tmp
git checkout "$from"
git checkout -b "${from}_tmp"
# drops you in an editor, pick the changes you want
git rebase -i $to
git checkout $to
git pull . ${from}_tmp
git branch -d ${from}_tmp
git rebase -i "$to"
git checkout "$to"
git pull . "${from}_tmp"
git branch -d "${from}_tmp"

0 comments on commit 96e66fb

Please sign in to comment.