summaryrefslogtreecommitdiff
path: root/tests.branching/ambiguous-refs.script
blob: ed72f9e3da0d0aec85a5483fda5012c5226cb490 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/sh
#
# Copyright (C) 2012-2013  Codethink Limited
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.


## Guard against a bug that occurs if 'git show-ref' is used to resolve refs
## instead of 'git rev-parse --verify': show-ref returns a list of partial
## matches sorted alphabetically, so any code using it may resolve refs
## incorrectly.

set -eu

. "$SRCDIR/scripts/fix-committer-info"

cd "$DATADIR/morphs"
git mv hello-stratum.morph goodbye-stratum.morph
sed -e '/morph: hello-stratum/s/hello-stratum/goodbye-stratum/' \
    -i hello-system.morph

git commit --quiet -am "Rename hello-system"

cd "$DATADIR/workspace"
"$SRCDIR/scripts/test-morph" init
"$SRCDIR/scripts/test-morph" branch test:morphs release

# Create an extra ref to confuse any users of git show-ref
cd release/test:morphs
git checkout --quiet -b alpha/master HEAD~1
git checkout --quiet release

# The petrify will fail if we resolved 'master' as 'alpha/master' by mistake.
cd "$DATADIR/workspace/release/test:morphs"
"$SRCDIR/scripts/test-morph" petrify