]> git.droids-corp.org - git-central.git/blobdiff - server/update-ensure-follows
It's unlikely, but warn the user to update first before telling them they need to...
[git-central.git] / server / update-ensure-follows
index 2cf633801d715530bd93a5b3bc69c90b3b85e909..a3c6b922f4e35a86018ee508c0d70d35f50351bd 100644 (file)
@@ -50,7 +50,14 @@ for ((i = 0 ; i < count ; i++)) do
        if [ $? -eq 0 ] ; then
                missing_commits=$(git log ^$newrev $follow --pretty=oneline | wc -l)
                if [ $missing_commits -ne 0 ] ; then
-                       display_error_message "You need to merge $follow into $short_refname"
+                       # If for some reason people are stupid and push with a --force flag,
+                       # we should warn them to update first in case one of their teammates
+                       # already merged for them
+                       if [ "$(git merge-base $oldrev $newrev)" != "$oldrev" ] ; then
+                               display_error_message "You need to update your local branch $short_refname"
+                       else
+                               display_error_message "You need to merge $follow into $short_refname"
+                       fi
                        exit 1
                fi
        fi