4 # Goes through the ensure-follows branches and makes sure
5 # the non-excused branches have it merged.
17 if [ "$source_branch" == "$remote_branch" ] ; then
20 if [[ $excused =~ " $remote_branch " ]] ; then
23 git branch -r --contains "$source_branch" | grep --quiet "origin/$remote_branch"
24 if [ $? -eq 0 ] ; then
28 echo -n "Merging $source_branch into $remote_branch..."
30 baserev=$(git merge-base "$source_branch" "origin/$remote_branch")
31 git read-tree -m --trivial $baserev "origin/$remote_branch" "$source_branch"
32 if [ $? -ne 0 ] ; then
37 new_tree=$(git write-tree)
38 new_commit=$(git commit-tree $new_tree -p "origin/$remote_branch" -p "$source_branch" <<FOO
39 Merge $source_branch into $remote_branch
41 if [ "$new_commit" == "" ] ; then
46 git push origin "$new_commit:$remote_branch" >/dev/null 2>/dev/null
47 if [ $? -ne 0 ] ; then
55 gitconfig=$(git rev-parse origin/gitconfig)
56 if [ $? -ne 0 ] ; then
57 echo "gitconfig branch not found"
62 config_hash=$(git ls-tree $gitconfig | grep config | grep -oP '\w{40}')
63 branches=$(git cat-file blob "$config_hash" | grep hooks.update-ensure-follows.branches)
64 branches=("${branches#*=}")
65 excused=$(git cat-file blob "$config_hash" | grep hooks.update-ensure-follows.excused)
66 excused=" ${excused#*=} "
68 # We're going to merge stuff into the index, so make sure it's okay
69 git diff-index --cached --quiet HEAD -- || die "refusing to refollow--your index is not clean"
71 # Get the latest remote refs
74 # So we can put the index back after we screw with it
75 original_head=$(git rev-parse HEAD)
77 for source_branch in ${branches[@]} ; do
78 git branch -r | grep -v HEAD | while read line ; do
79 if [[ "$line" =~ origin/(.*) ]] ; then
80 attempt_merge $source_branch ${BASH_REMATCH[1]}
86 git read-tree "$original_head"