annotate Lib/fftw-3.2.1/.git/hooks/pre-rebase.sample @ 8:fdc592312a96

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