diff --git a/scripts/for-each-ref.rcsh b/scripts/for-each-ref.rcsh new file mode 100755 index 0000000..18506d4 --- /dev/null +++ b/scripts/for-each-ref.rcsh @@ -0,0 +1,36 @@ +#!/usr/bin/env rc + +flag e + + +current_ref=`{ + git symbolic-ref --short -q HEAD \ + || git describe --tags --exact-match >[2]/dev/null \ + || git rev-parse --short HEAD +} + +root=`{git rev-parse --show-toplevel} + +fn log { + echo $"* >[1=2] #" +} + +log Preserving current symbolic ref to return to later: $current_ref + +rev_range=$1 +shift + +revlist=`{git rev-list $rev_range --reverse} + +for (rev in $revlist) { + echo Checking out $rev + # Checkout the ref + git checkout $rev + # Execute the argument + for (command in $*) { + eval $command + } + git restore $root +} + +log Done! +git checkout $current_ref