#!/bin/sh # git-pk3-merge: Attempt a trivial merge of master in a bare repo. set -x # Helpers die() { echo "$(basename "$0"): error: $*" >&2 exit 1 } usage() { cat < /dev/null) || die "couldn't determine the common ancestor" # Figure out the parent commits parent1=$(git rev-parse --verify -q $ref) && parent2=$(git rev-parse --verify -q $master) || die "couldn't determine parent commits" # Attempt a trivial merge git read-tree -i -m --aggressive --trivial $base $ref $master || die "couldn't do a trivial merge" # Check if the index contains changes against parent git diff-index --cached --quiet $parent1 && die "found no changes to commit" # Commit the index and point the ref to the new commit tree=$(git write-tree) && commit=$(message | git commit-tree $tree -p $parent1 -p $parent2) && git update-ref -m "pk3-merge" $ref $commit || die "couldn't commit merge"