modified to get more signal info

Dependencies:   WNC14A2AInterface

Fork of easy-connect by Jim Flynn

Committer:
tdMBED
Date:
Sat Nov 25 21:52:06 2017 +0000
Revision:
7:b7ed55f374be
Parent:
0:2563b0415d1f
modified to get more signal info

Who changed what in which revision?

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