summaryrefslogtreecommitdiffstats
path: root/bin/git
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2012-06-04 01:27:24 -0500
committerJesse Luehrs <doy@tozt.net>2012-06-04 01:33:29 -0500
commitc88bf6a96e087a217afda366cd0b18fff806b7df (patch)
tree07eaaf2b59c0bc7dd19b91467d16c8951393c0b7 /bin/git
parent1dbdececdc964ce6ea38a0f3fb0a325979ab536c (diff)
downloadconf-c88bf6a96e087a217afda366cd0b18fff806b7df.tar.gz
conf-c88bf6a96e087a217afda366cd0b18fff806b7df.zip
add git test-sequence
Diffstat (limited to 'bin/git')
-rw-r--r--bin/git/git-test-sequence95
1 files changed, 95 insertions, 0 deletions
diff --git a/bin/git/git-test-sequence b/bin/git/git-test-sequence
new file mode 100644
index 0000000..5aa4d27
--- /dev/null
+++ b/bin/git/git-test-sequence
@@ -0,0 +1,95 @@
+#!/bin/sh
+# Run a command over a sequence of commits.
+# Example:
+# git test-sequence origin/master.. 'make clean && make test'
+
+. git-sh-setup
+require_work_tree
+
+t=
+run_once=
+ref_name=pass
+
+# The tree must be really really clean.
+if ! git update-index --ignore-submodules --refresh > /dev/null; then
+ echo >&2 "cannot rebase: you have unstaged changes"
+ git diff-files --name-status -r --ignore-submodules -- >&2
+ exit 1
+fi
+diff=$(git diff-index --cached --name-status -r --ignore-submodules HEAD --)
+case "$diff" in
+ ?*) echo >&2 "cannot rebase: your index contains uncommitted changes"
+ echo >&2 "$diff"
+ exit 1
+ ;;
+esac
+
+start_branch=`git rev-parse --symbolic-full-name HEAD | sed s,refs/heads/,,`
+git checkout `git rev-parse HEAD` > /dev/null 2>/dev/null
+
+cleanup() {
+ git checkout $start_branch > /dev/null 2>/dev/null
+}
+
+already_passed() {
+ obdata=${ref_name}-$t-$1
+ obhash=`echo $obdata | git hash-object --stdin`
+ git cat-file blob $obhash > /dev/null 2>/dev/null \
+ && echo "Already ${ref_name} $1"
+}
+
+passed_on() {
+ obdata=${ref_name}-$t-$1
+ echo $obdata | git hash-object -w --stdin > /dev/null
+ echo "Passed: $1."
+}
+
+broke_on() {
+ echo "Broke on $1"
+ cleanup
+ exit 1
+}
+
+new_test() {
+ echo "Testing $2"
+ git reset --hard $v && eval "$2" && passed_on $1 || broke_on $v
+ status=$?
+ if test -n "$run_once"; then
+ cleanup
+ exit $status
+ fi
+}
+
+
+while test $# != 0
+do
+ case "$1" in
+ --once)
+ run_once=yes
+ ;;
+ --ref-name)
+ ref_name=$2
+ shift
+ ;;
+ *)
+ break;
+ ;;
+ esac
+ shift
+done
+
+t=`echo "$2" | git hash-object --stdin`
+
+for v in `git rev-list --reverse $1`
+do
+ tree_ver=`git rev-parse "$v^{tree}"`
+ already_passed $tree_ver || new_test $tree_ver "$2"
+done
+cleanup
+
+if test -n "$run_once"; then
+ echo "All commits already passed for --once argument. Quiting."
+ exit 127
+fi
+
+echo "All's well."