summaryrefslogtreecommitdiff
path: root/tests.branching/ambiguous-refs.script
diff options
context:
space:
mode:
Diffstat (limited to 'tests.branching/ambiguous-refs.script')
-rwxr-xr-xtests.branching/ambiguous-refs.script46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests.branching/ambiguous-refs.script b/tests.branching/ambiguous-refs.script
new file mode 100755
index 00000000..aeec61a1
--- /dev/null
+++ b/tests.branching/ambiguous-refs.script
@@ -0,0 +1,46 @@
+#!/bin/sh
+#
+# Copyright (C) 2012-2014 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