]> git.xonotic.org Git - xonotic/xonotic.git/blobdiff - all
new feature: "./all merge" - merges changes from master into your branches (to be...
[xonotic/xonotic.git] / all
diff --git a/all b/all
index d217389619a38a01c9d1d77b483ba53707a49df9..44c037646eb3e99b6b1d27b6445e3b5c94423cf0 100755 (executable)
--- a/all
+++ b/all
@@ -33,10 +33,23 @@ msg()
        echo "\e[1m$*\e[m"
 }
 
-self=`cksum "$SELF"`
+checksum()
+{
+       if [ -x /usr/bin/md5sum ]; then
+               /usr/bin/md5sum "$@"
+       elif [ -x /bin/md5sum ]; then
+               /bin/md5sum "$@"
+       elif [ -x /usr/bin/cksum ]; then
+               /usr/bin/cksum "$@"
+       else
+               echo "NOCHECKSUM"
+       fi
+}
+
+self=`checksum "$SELF"`
 checkself()
 {
-       self_new=`cksum "$SELF"`
+       self_new=`checksum "$SELF"`
        if [ x"$self" != x"$self_new" ]; then
                msg "./all has changed."
                if [ -z "$XONOTIC_FORBID_RERUN_ALL" ]; then
@@ -105,7 +118,7 @@ case "$cmd" in
                                                fi
                                                ;;
                                esac
-                               verbose git pull
+                               verbose git pull || true # errors if the branch is not tracking anything
                                cd "$d00"
                                checkself "$SELF" "$@"
                                cd "$d0/$d"
@@ -184,6 +197,34 @@ case "$cmd" in
                        cd "$d0"
                done
                ;;
+       merge)
+               for d in $repos; do
+                       cd "$d0/$d"
+                       r=`git symbolic-ref HEAD`
+                       r=${r#refs/heads/}
+                       if git log HEAD..origin/master | grep .; then
+                               # we have uncommitted changes
+                               a=
+                               while [ x"$a" != x"y" -a x"$a" != x"n" ]; do
+                                       echo "Could merge from \"master\" into \"$r\" in \"$d\". Do it?"
+                                       read -r a
+                               done
+                               if [ x"$a" = x"y" ]; then
+                                       if ! verbose git merge origin/master; then
+                                               echo
+                                               echo "MERGE CONFLICT."
+                                               echo "change into the \"$d\" project directory, and then:"
+                                               echo "- edit the files mentioned above with your favorite editor,"
+                                               echo "  and fix the conflicts (marked with <<<<<<< blocks)"
+                                               echo "- when done with a file, 'git add' the file"
+                                               echo "- when done, 'git commit'"
+                                               exit 1
+                                       fi
+                               fi
+                       fi
+                       cd "$d0"
+               done
+               ;;
        push)
                for d in $repos; do
                        cd "$d0/$d"
@@ -264,10 +305,11 @@ case "$cmd" in
        *)
                echo "Usage:"
                echo "  $SELF pull"
+               echo "  $SELF merge"
                echo "  $SELF push"
                echo "  $SELF branches"
-               echo "  $SELF branch <remote> <branchname>"
-               echo "  $SELF checkout"
+               echo "  $SELF branch [<remote>] <branchname>"
+               echo "  $SELF checkout [<remote>] <branchname>"
                echo "  $SELF compile"
                echo "  $SELF run <client> <options>"
                echo "  $SELF each <command>"