- echo "$ref"
- if git notes --ref "refs/notes/admin-merge" show "$ref" 2>/dev/null; then
- echo "Not merging, already had this one"
- elif yesno "Branch \"$ref\" may want to get merged. Do it?" '{ git log HEAD.."$ref"; git diff HEAD..."$ref"; } | less'; then
- git checkout master
- org=`git rev-parse HEAD`
- if ! git merge "$ref" 2>&1 | tee "$t"; then
- git reset --hard "$org"
- git notes --ref "refs/notes/admin-merge" add -m "Merge failed:
-`cat "$t"`" "$ref"
- elif ! "$SELF" compile 2>&1 | tee "$t"; then
- git reset --hard "$org"
- git notes --ref "refs/notes/admin-merge" add -m "Compile failed:
-`cat "$t"`" "$ref"
- elif ! yesno "Still merge \"$ref\" into `git symbolic-ref HEAD` of $d? Maybe you want to test first."; then
- git reset --hard "$org"
- git notes --ref "refs/notes/admin-merge" add "$ref"
+ if [ -n "$branch" ]; then
+ if [ x"$branch" != x"${ref#refs/remotes/origin/}" ]; then
+ continue
+ fi
+ fi
+ case "$base" in
+ master)
+ realbase=$base
+ ;;
+ *)
+ l0=`git rev-list "$base".."$ref" | wc -l`
+ l1=`git rev-list master.."$ref" | wc -l`
+ if [ $l0 -gt $l1 ]; then
+ realbase=master
+ else
+ realbase=$base
+ fi
+ ;;
+ esac
+ reportecho " Branch $ref:"
+ note=`GIT_NOTES_REF=refs/notes/admin-merge git notes show "$ref" 2>/dev/null || true`
+ logdata=`git log --color "$realbase".."$ref"`
+ if [ -z "$logdata" ]; then
+ reportecho4 "--> not merging, no changes vs master"
+ if yesno "Branch \"$ref\" probably should get deleted. Do it?" ''; then
+ git push origin :"${ref#refs/remotes/origin/}"
+ reportecho4 "--> branch deleted"
+ fi
+ else
+ diffdata=`git diff --color --find-copies-harder --ignore-space-change "$realbase"..."$ref"`
+ if [ -z "$diffdata" ]; then
+ reportecho4 "--> not merging, no changes vs master, branch contains redundant history"
+ if yesno "Branch \"$ref\" probably should get deleted. Do it?" '{ echo "$logdata"; } | less -r'; then
+ git push origin :"${ref#refs/remotes/origin/}"
+ reportecho4 "--> branch deleted"
+ fi
+ elif [ -z "$branch" ] && [ -n "$note" ]; then
+ reportdo4 echo "$note"
+ reportecho4 "--> not merging, already had this one rejected before"
+ elif yesno "Branch \"$ref\" may want to get merged. Do it?" '{ echo "$logdata"; echo "$diffdata"; } | less -r'; then
+ git checkout "$realbase"
+ org=`git rev-parse HEAD`
+ if ! git merge --no-ff "$ref" 2>&1 | tee "$t" && ! { git ls-files -u | grep ' 1 ' >/dev/null; }; then
+ git reset --hard "$org"
+ GIT_NOTES_REF=refs/notes/admin-merge git notes edit -m "Merge failed:$LF`cat "$t"`" "$ref"
+ reportdo4 cat "$t"
+ reportecho4 "--> merge failed"
+ elif ! "$SELF" compile -n 2>&1 | tee "$t"; then
+ git reset --hard "$org"
+ GIT_NOTES_REF=refs/notes/admin-merge git notes edit -m "Compile failed:$LF`cat "$t"`" "$ref"
+ reportdo4 cat "$t"
+ reportecho4 "--> compile failed"
+ elif ! yesno "Still merge \"$ref\" into `git symbolic-ref HEAD` of $d? Maybe you want to test first."; then
+ git reset --hard "$org"
+ GIT_NOTES_REF=refs/notes/admin-merge git notes edit "$ref"
+ note=`GIT_NOTES_REF=refs/notes/admin-merge git notes show "$ref" 2>/dev/null || true`
+ if [ x"$note" = x"del" ]; then
+ git push origin :"${ref#refs/remotes/origin/}"
+ reportecho4 "--> test failed, branch deleted"
+ elif [ -n "$note" ]; then
+ reportdo4 echo "$note"
+ reportecho4 "--> test failed"
+ else
+ reportecho4 "--> test failed, postponed"
+ fi
+ else
+ echo "MERGING"
+ case ",`repoflags "$d"`," in
+ *,svn,*)
+ # we do quite a mess here... luckily we know $org
+ git fetch # svn needs to be current
+ git rebase -i --onto origin/master "$org"
+ git svn dcommit --add-author-from
+ git reset --hard "$org"
+ ;;
+ *)
+ git push origin HEAD
+ ;;
+ esac
+ reportecho4 "--> MERGED"
+ if yesno "Delete original branch \"$ref\"?"; then
+ git push origin :"${ref#refs/remotes/origin/}"
+ reportecho4 "--> branch deleted"
+ fi
+ fi