From 411985f7cf8b432426f6c732071565fbcdab1994 Mon Sep 17 00:00:00 2001 From: Matthias Wolf Date: Fri, 27 May 2016 05:36:07 -0400 Subject: [PATCH] Add a small script to test multiple branches at once. --- git-test-branches | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100755 git-test-branches diff --git a/git-test-branches b/git-test-branches new file mode 100755 index 00000000..470bf6e5 --- /dev/null +++ b/git-test-branches @@ -0,0 +1,43 @@ +#!/bin/sh + +# A small script to test multiple branches at once. +# +# Use this script on your own risk! +# Prerequisite for git actually finding this: export PATH=$PATH:. +# Usage: git test-branches fix-bare-size cache-dbs-info ... + +if [ $# -le 0 ]; then + echo usage: $0 branch... + exit 1 +fi + +success=0 + +git stash && stash=1 + +git checkout master +git fetch +git pull --ff-only + +if [ !$? ]; then + git branch -D test + git checkout -b test + for i in $*; do + git merge -m "Merging $i" $i + if [ $? -ne 0 ]; then + echo "Merge failed for branch $i" + git merge --abort + else + success=1 + fi + done +fi + +if [ $success -eq 0 ]; then + echo "No merges succeeded - reverting to master" + git checkout master +fi + +if [ "x$stash" != "x" ]; then + git stash pop +fi