Does a few sanity checks to avoid common gotchas:
- make sure the backmerge is in drm-tip already
- check that git rerere resolves all conflict, and cuation if not
- merge commit template.

Cc: Sean Paul <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
---
 bash_completion |  2 +-
 dim             | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 dim.rst         |  7 +++++++
 3 files changed, 62 insertions(+), 1 deletion(-)

diff --git a/bash_completion b/bash_completion
index 7dfc4b86cb13..451db26aae8c 100644
--- a/bash_completion
+++ b/bash_completion
@@ -75,7 +75,7 @@ _dim ()
                checkpatch)
                        # FIXME needs a git sha1
                        ;;
-               pull-request)
+               pull-request|backmerge)
                        if [[ $args == 2 ]]; then
                                COMPREPLY=( $( compgen -W "$nightly_branches" 
-- $cur ) )
                        elif [[ $args == 3 ]]; then
diff --git a/dim b/dim
index 8357d4f635e7..6474d078af67 100755
--- a/dim
+++ b/dim
@@ -749,6 +749,60 @@ function dim_apply_pull
        return $rv
 }
 
+function dim_backmerge
+{
+       local branch upstream patch_file
+
+       branch=${1:?$usage}
+       upstream=${2:?$usage}
+
+       cd $DIM_PREFIX/drm-tip
+       tip_remote=$(url_to_remote $drm_tip_ssh)
+       git fetch -q $tip_remote || true
+
+       if ! git merge-base --is-ancestor $upstream $tip_remote/drm-tip ; then
+               echoerr "Upstream $upstream not merged into drm-tip, aborting."
+               echoerr "Please make sure any backmerge is tested in drm-tip,"
+               echoerr "to give all the CI bots some time to find bugs."
+               exit 1
+       fi
+
+       assert_branch $branch
+       assert_repo_clean
+
+       git merge --rerere-autoupdate --no-commit $upstream >& /dev/null || true
+
+       if [[ -d .git ]]; then
+               patch_file=".git"
+       else
+               patch_file=$(cut -d ' ' -f 2 .git)
+       fi
+       patch_file=$patch_file/MERGE_MSG
+
+
+       cat > $patch_file <<-HERE
+               Merge $upstream into $branch
+
+               Explain here why you've done the backmerge, e.g. which patches
+               or which driver pull request you need to be able to merge
+               \$feature_work from \$author.
+
+               HERE
+
+       if git diff | grep -q '\(<<<<<<<\|=======\|>>>>>>>\||||||||\)' ; then
+               echoerr "Conflicts find while merging $upstream into $branch."
+               echoerr "This should only happen when git rerere gets confused" 
+               echoerr "or if there's a manual fixup patch in drm-rerere." 
+               echoerr "Please proceed with extreme caution." 
+               echoerr "Once the conflict is resolved, commit it with" 
+               echoerr "   git commit -a" 
+       fi
+
+       git add -u
+       git commit -s
+
+}
+
 function dim_add_link
 {
        local branch file message_id
diff --git a/dim.rst b/dim.rst
index bc4d9a0b2a76..b99248e24a8d 100644
--- a/dim.rst
+++ b/dim.rst
@@ -360,6 +360,13 @@ apply-pull *branch*
 -------------------
 Reads a pull request mail from stdin and merges it into the given *branch*.
 
+backmerge *branch* *upstream*
+-----------------------------
+
+Backmerges *upstream* into *branch*, making a few sanity checks on the way. The
+*upstream* we backmerge should be the same as used for sending out pull 
requests
+using **pull-request**.
+
 update-next
 -----------
 Pushes out the latest dinq to drm-intel-next and tags it. Also
-- 
2.11.0

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reply via email to