~charles/dotfiles

0444d3e69fd895a1e3055792b9d0e7e414913caa — Charles Daniels 5 years ago 07337eb
add git-each
1 files changed, 19 insertions(+), 0 deletions(-)

A overlay/bin/git-each
A overlay/bin/git-each => overlay/bin/git-each +19 -0
@@ 0,0 1,19 @@
#!/bin/sh

# Runs the command '$@' on every git commit

repo="$(git rev-parse --show-toplevel)"
tmp="$(mktemp -d)"
cd "$tmp"

git clone "$repo" ./ > /dev/null 2>&1
git fetch --all > /dev/null 2>&1
git pull > /dev/null 2>&1

git rev-list --all | while read -r commit ; do
	git checkout "$commit" > /dev/null 2>&1
	export commit="$commit"
	sh -c "$@"
done
cd /tmp
rm -rf "$tmp"