Version of easy-connect with the u-blox cellular platforms C027 and C030 added.

Dependents:   HelloMQTT

Committer:
group-ublox
Date:
Thu Aug 10 14:33:05 2017 +0000
Revision:
0:19aa55d66228
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
group-ublox 0:19aa55d66228 1 #!/bin/sh
group-ublox 0:19aa55d66228 2 #
group-ublox 0:19aa55d66228 3 # Copyright (c) 2006, 2008 Junio C Hamano
group-ublox 0:19aa55d66228 4 #
group-ublox 0:19aa55d66228 5 # The "pre-rebase" hook is run just before "git rebase" starts doing
group-ublox 0:19aa55d66228 6 # its job, and can prevent the command from running by exiting with
group-ublox 0:19aa55d66228 7 # non-zero status.
group-ublox 0:19aa55d66228 8 #
group-ublox 0:19aa55d66228 9 # The hook is called with the following parameters:
group-ublox 0:19aa55d66228 10 #
group-ublox 0:19aa55d66228 11 # $1 -- the upstream the series was forked from.
group-ublox 0:19aa55d66228 12 # $2 -- the branch being rebased (or empty when rebasing the current branch).
group-ublox 0:19aa55d66228 13 #
group-ublox 0:19aa55d66228 14 # This sample shows how to prevent topic branches that are already
group-ublox 0:19aa55d66228 15 # merged to 'next' branch from getting rebased, because allowing it
group-ublox 0:19aa55d66228 16 # would result in rebasing already published history.
group-ublox 0:19aa55d66228 17
group-ublox 0:19aa55d66228 18 publish=next
group-ublox 0:19aa55d66228 19 basebranch="$1"
group-ublox 0:19aa55d66228 20 if test "$#" = 2
group-ublox 0:19aa55d66228 21 then
group-ublox 0:19aa55d66228 22 topic="refs/heads/$2"
group-ublox 0:19aa55d66228 23 else
group-ublox 0:19aa55d66228 24 topic=`git symbolic-ref HEAD` ||
group-ublox 0:19aa55d66228 25 exit 0 ;# we do not interrupt rebasing detached HEAD
group-ublox 0:19aa55d66228 26 fi
group-ublox 0:19aa55d66228 27
group-ublox 0:19aa55d66228 28 case "$topic" in
group-ublox 0:19aa55d66228 29 refs/heads/??/*)
group-ublox 0:19aa55d66228 30 ;;
group-ublox 0:19aa55d66228 31 *)
group-ublox 0:19aa55d66228 32 exit 0 ;# we do not interrupt others.
group-ublox 0:19aa55d66228 33 ;;
group-ublox 0:19aa55d66228 34 esac
group-ublox 0:19aa55d66228 35
group-ublox 0:19aa55d66228 36 # Now we are dealing with a topic branch being rebased
group-ublox 0:19aa55d66228 37 # on top of master. Is it OK to rebase it?
group-ublox 0:19aa55d66228 38
group-ublox 0:19aa55d66228 39 # Does the topic really exist?
group-ublox 0:19aa55d66228 40 git show-ref -q "$topic" || {
group-ublox 0:19aa55d66228 41 echo >&2 "No such branch $topic"
group-ublox 0:19aa55d66228 42 exit 1
group-ublox 0:19aa55d66228 43 }
group-ublox 0:19aa55d66228 44
group-ublox 0:19aa55d66228 45 # Is topic fully merged to master?
group-ublox 0:19aa55d66228 46 not_in_master=`git rev-list --pretty=oneline ^master "$topic"`
group-ublox 0:19aa55d66228 47 if test -z "$not_in_master"
group-ublox 0:19aa55d66228 48 then
group-ublox 0:19aa55d66228 49 echo >&2 "$topic is fully merged to master; better remove it."
group-ublox 0:19aa55d66228 50 exit 1 ;# we could allow it, but there is no point.
group-ublox 0:19aa55d66228 51 fi
group-ublox 0:19aa55d66228 52
group-ublox 0:19aa55d66228 53 # Is topic ever merged to next? If so you should not be rebasing it.
group-ublox 0:19aa55d66228 54 only_next_1=`git rev-list ^master "^$topic" ${publish} | sort`
group-ublox 0:19aa55d66228 55 only_next_2=`git rev-list ^master ${publish} | sort`
group-ublox 0:19aa55d66228 56 if test "$only_next_1" = "$only_next_2"
group-ublox 0:19aa55d66228 57 then
group-ublox 0:19aa55d66228 58 not_in_topic=`git rev-list "^$topic" master`
group-ublox 0:19aa55d66228 59 if test -z "$not_in_topic"
group-ublox 0:19aa55d66228 60 then
group-ublox 0:19aa55d66228 61 echo >&2 "$topic is already up-to-date with master"
group-ublox 0:19aa55d66228 62 exit 1 ;# we could allow it, but there is no point.
group-ublox 0:19aa55d66228 63 else
group-ublox 0:19aa55d66228 64 exit 0
group-ublox 0:19aa55d66228 65 fi
group-ublox 0:19aa55d66228 66 else
group-ublox 0:19aa55d66228 67 not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"`
group-ublox 0:19aa55d66228 68 /usr/bin/perl -e '
group-ublox 0:19aa55d66228 69 my $topic = $ARGV[0];
group-ublox 0:19aa55d66228 70 my $msg = "* $topic has commits already merged to public branch:\n";
group-ublox 0:19aa55d66228 71 my (%not_in_next) = map {
group-ublox 0:19aa55d66228 72 /^([0-9a-f]+) /;
group-ublox 0:19aa55d66228 73 ($1 => 1);
group-ublox 0:19aa55d66228 74 } split(/\n/, $ARGV[1]);
group-ublox 0:19aa55d66228 75 for my $elem (map {
group-ublox 0:19aa55d66228 76 /^([0-9a-f]+) (.*)$/;
group-ublox 0:19aa55d66228 77 [$1 => $2];
group-ublox 0:19aa55d66228 78 } split(/\n/, $ARGV[2])) {
group-ublox 0:19aa55d66228 79 if (!exists $not_in_next{$elem->[0]}) {
group-ublox 0:19aa55d66228 80 if ($msg) {
group-ublox 0:19aa55d66228 81 print STDERR $msg;
group-ublox 0:19aa55d66228 82 undef $msg;
group-ublox 0:19aa55d66228 83 }
group-ublox 0:19aa55d66228 84 print STDERR " $elem->[1]\n";
group-ublox 0:19aa55d66228 85 }
group-ublox 0:19aa55d66228 86 }
group-ublox 0:19aa55d66228 87 ' "$topic" "$not_in_next" "$not_in_master"
group-ublox 0:19aa55d66228 88 exit 1
group-ublox 0:19aa55d66228 89 fi
group-ublox 0:19aa55d66228 90
group-ublox 0:19aa55d66228 91 <<\DOC_END
group-ublox 0:19aa55d66228 92
group-ublox 0:19aa55d66228 93 This sample hook safeguards topic branches that have been
group-ublox 0:19aa55d66228 94 published from being rewound.
group-ublox 0:19aa55d66228 95
group-ublox 0:19aa55d66228 96 The workflow assumed here is:
group-ublox 0:19aa55d66228 97
group-ublox 0:19aa55d66228 98 * Once a topic branch forks from "master", "master" is never
group-ublox 0:19aa55d66228 99 merged into it again (either directly or indirectly).
group-ublox 0:19aa55d66228 100
group-ublox 0:19aa55d66228 101 * Once a topic branch is fully cooked and merged into "master",
group-ublox 0:19aa55d66228 102 it is deleted. If you need to build on top of it to correct
group-ublox 0:19aa55d66228 103 earlier mistakes, a new topic branch is created by forking at
group-ublox 0:19aa55d66228 104 the tip of the "master". This is not strictly necessary, but
group-ublox 0:19aa55d66228 105 it makes it easier to keep your history simple.
group-ublox 0:19aa55d66228 106
group-ublox 0:19aa55d66228 107 * Whenever you need to test or publish your changes to topic
group-ublox 0:19aa55d66228 108 branches, merge them into "next" branch.
group-ublox 0:19aa55d66228 109
group-ublox 0:19aa55d66228 110 The script, being an example, hardcodes the publish branch name
group-ublox 0:19aa55d66228 111 to be "next", but it is trivial to make it configurable via
group-ublox 0:19aa55d66228 112 $GIT_DIR/config mechanism.
group-ublox 0:19aa55d66228 113
group-ublox 0:19aa55d66228 114 With this workflow, you would want to know:
group-ublox 0:19aa55d66228 115
group-ublox 0:19aa55d66228 116 (1) ... if a topic branch has ever been merged to "next". Young
group-ublox 0:19aa55d66228 117 topic branches can have stupid mistakes you would rather
group-ublox 0:19aa55d66228 118 clean up before publishing, and things that have not been
group-ublox 0:19aa55d66228 119 merged into other branches can be easily rebased without
group-ublox 0:19aa55d66228 120 affecting other people. But once it is published, you would
group-ublox 0:19aa55d66228 121 not want to rewind it.
group-ublox 0:19aa55d66228 122
group-ublox 0:19aa55d66228 123 (2) ... if a topic branch has been fully merged to "master".
group-ublox 0:19aa55d66228 124 Then you can delete it. More importantly, you should not
group-ublox 0:19aa55d66228 125 build on top of it -- other people may already want to
group-ublox 0:19aa55d66228 126 change things related to the topic as patches against your
group-ublox 0:19aa55d66228 127 "master", so if you need further changes, it is better to
group-ublox 0:19aa55d66228 128 fork the topic (perhaps with the same name) afresh from the
group-ublox 0:19aa55d66228 129 tip of "master".
group-ublox 0:19aa55d66228 130
group-ublox 0:19aa55d66228 131 Let's look at this example:
group-ublox 0:19aa55d66228 132
group-ublox 0:19aa55d66228 133 o---o---o---o---o---o---o---o---o---o "next"
group-ublox 0:19aa55d66228 134 / / / /
group-ublox 0:19aa55d66228 135 / a---a---b A / /
group-ublox 0:19aa55d66228 136 / / / /
group-ublox 0:19aa55d66228 137 / / c---c---c---c B /
group-ublox 0:19aa55d66228 138 / / / \ /
group-ublox 0:19aa55d66228 139 / / / b---b C \ /
group-ublox 0:19aa55d66228 140 / / / / \ /
group-ublox 0:19aa55d66228 141 ---o---o---o---o---o---o---o---o---o---o---o "master"
group-ublox 0:19aa55d66228 142
group-ublox 0:19aa55d66228 143
group-ublox 0:19aa55d66228 144 A, B and C are topic branches.
group-ublox 0:19aa55d66228 145
group-ublox 0:19aa55d66228 146 * A has one fix since it was merged up to "next".
group-ublox 0:19aa55d66228 147
group-ublox 0:19aa55d66228 148 * B has finished. It has been fully merged up to "master" and "next",
group-ublox 0:19aa55d66228 149 and is ready to be deleted.
group-ublox 0:19aa55d66228 150
group-ublox 0:19aa55d66228 151 * C has not merged to "next" at all.
group-ublox 0:19aa55d66228 152
group-ublox 0:19aa55d66228 153 We would want to allow C to be rebased, refuse A, and encourage
group-ublox 0:19aa55d66228 154 B to be deleted.
group-ublox 0:19aa55d66228 155
group-ublox 0:19aa55d66228 156 To compute (1):
group-ublox 0:19aa55d66228 157
group-ublox 0:19aa55d66228 158 git rev-list ^master ^topic next
group-ublox 0:19aa55d66228 159 git rev-list ^master next
group-ublox 0:19aa55d66228 160
group-ublox 0:19aa55d66228 161 if these match, topic has not merged in next at all.
group-ublox 0:19aa55d66228 162
group-ublox 0:19aa55d66228 163 To compute (2):
group-ublox 0:19aa55d66228 164
group-ublox 0:19aa55d66228 165 git rev-list master..topic
group-ublox 0:19aa55d66228 166
group-ublox 0:19aa55d66228 167 if this is empty, it is fully merged to "master".
group-ublox 0:19aa55d66228 168
group-ublox 0:19aa55d66228 169 DOC_END