SD card example code for Seeed Wio 3G

Fork of Wio_3G-example-sd-driver by Toyomasa Watarai

Committer:
MACRUM
Date:
Thu Aug 09 01:42:53 2018 +0000
Revision:
0:8eedb2495d52
Initial commit

Who changed what in which revision?

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