summaryrefslogtreecommitdiff
path: root/tests.branching
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2012-08-30 13:49:33 +0100
committerSam Thursfield <sam.thursfield@codethink.co.uk>2012-08-30 13:49:33 +0100
commit15eef533406cee3811650f96897724b4fba5c18c (patch)
tree65ade50ceb174765f77b8f87bdac131b947ff52b /tests.branching
parentc510c12be2d32a8ab18f7350d8f2a708e74cfa4a (diff)
parent17e4c4c0bad5589dabf67156afdfe9dc4e8f218b (diff)
downloadmorph-15eef533406cee3811650f96897724b4fba5c18c.tar.gz
Merge branch 'jannis/initial-branch-and-merge-work'
Conflicts: morphlib/plugins/branch_and_merge_plugin.py
Diffstat (limited to 'tests.branching')
-rwxr-xr-xtests.branching/branch-creates-new-system-branch-not-from-master.script18
-rw-r--r--tests.branching/branch-creates-new-system-branch-not-from-master.stdout12
-rwxr-xr-xtests.branching/branch-creates-new-system-branch.script18
-rw-r--r--tests.branching/branch-creates-new-system-branch.stdout10
-rwxr-xr-xtests.branching/branch-when-branchdir-exists-locally.script10
-rwxr-xr-xtests.branching/checkout-existing-branch.script16
-rw-r--r--tests.branching/checkout-existing-branch.stdout10
-rwxr-xr-xtests.branching/checkout-non-aliased-repos.script61
-rw-r--r--tests.branching/checkout-non-aliased-repos.stdout38
-rwxr-xr-xtests.branching/edit-checkouts-existing-chunk.script18
-rwxr-xr-xtests.branching/edit-clones-chunk.script29
-rwxr-xr-xtests.branching/edit-updates-stratum.script13
-rwxr-xr-xtests.branching/edit-uses-ref-from-stratum.script13
-rwxr-xr-xtests.branching/init-cwd.script10
-rwxr-xr-xtests.branching/init-default.script10
-rwxr-xr-xtests.branching/init-existing.script10
-rwxr-xr-xtests.branching/init-newdir.script12
-rw-r--r--tests.branching/init-newdir.stderr1
-rw-r--r--tests.branching/init-newdir.stdout2
-rwxr-xr-xtests.branching/init-nonempty.script10
-rw-r--r--tests.branching/init-nonempty.stderr2
-rwxr-xr-xtests.branching/merge-explicitly-named-repos.script21
-rwxr-xr-xtests.branching/minedir-not-found.script10
-rw-r--r--tests.branching/minedir-not-found.stderr2
-rwxr-xr-xtests.branching/minedir.script14
-rw-r--r--tests.branching/minedir.stdout2
-rwxr-xr-xtests.branching/petrify.script12
-rwxr-xr-xtests.branching/setup11
-rw-r--r--tests.branching/show-system-branch-fails-outside-workspace.exit (renamed from tests.branching/init-newdir.exit)0
-rwxr-xr-xtests.branching/show-system-branch-fails-outside-workspace.script (renamed from tests.branching/show-system-branch-shows-name-correctly.script)22
-rw-r--r--tests.branching/show-system-branch-fails-outside-workspace.stderr1
-rw-r--r--tests.branching/show-system-branch-fails-when-branch-is-ambiguous.exit1
-rwxr-xr-xtests.branching/show-system-branch-fails-when-branch-is-ambiguous.script32
-rw-r--r--tests.branching/show-system-branch-fails-when-branch-is-ambiguous.stderr1
-rw-r--r--tests.branching/show-system-branch-shows-name-correctly.stdout1
-rwxr-xr-xtests.branching/show-system-branch-works-anywhere-with-a-single-branch.script31
-rw-r--r--tests.branching/show-system-branch-works-anywhere-with-a-single-branch.stdout1
-rwxr-xr-xtests.branching/show-system-branch-works-in-different-directories-in-a-branch.script57
-rw-r--r--tests.branching/show-system-branch-works-in-different-directories-in-a-branch.stdout6
-rwxr-xr-xtests.branching/workflow.script21
40 files changed, 406 insertions, 163 deletions
diff --git a/tests.branching/branch-creates-new-system-branch-not-from-master.script b/tests.branching/branch-creates-new-system-branch-not-from-master.script
index 9ab44809..e2883c83 100755
--- a/tests.branching/branch-creates-new-system-branch-not-from-master.script
+++ b/tests.branching/branch-creates-new-system-branch-not-from-master.script
@@ -1,15 +1,15 @@
#!/bin/sh
# Copyright (C) 2012 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.
@@ -18,18 +18,18 @@
set -eu
-cd "$DATADIR/mine"
+cd "$DATADIR/workspace"
"$SRCDIR/scripts/test-morph" init
-"$SRCDIR/scripts/test-morph" branch newbranch origin/alfred
+"$SRCDIR/scripts/test-morph" branch baserock:morphs newbranch origin/alfred
echo "File tree:"
-"$SRCDIR/scripts/list-tree" . | grep -v '/\.git/' |
+"$SRCDIR/scripts/list-tree" . | grep -v '/\.git/' |
sed 's,/cache/gits/file_[^/]*_,/cache/gits/file_,'
echo "Current branches:"
-"$SRCDIR/scripts/run-git-in" newbranch/morphs branch
+"$SRCDIR/scripts/run-git-in" newbranch/baserock:morphs branch
echo "Current origin:"
-"$SRCDIR/scripts/run-git-in" newbranch/morphs remote show origin |
- sed 's,\(TMP/mine/\.morph/cache/gits/file_\).*_,\1,g'
+"$SRCDIR/scripts/run-git-in" newbranch/baserock:morphs remote show origin |
+ sed 's,\(TMP/workspace/\.morph/cache/gits/file_\).*_,\1,g'
diff --git a/tests.branching/branch-creates-new-system-branch-not-from-master.stdout b/tests.branching/branch-creates-new-system-branch-not-from-master.stdout
index 7dfffab1..d68a6342 100644
--- a/tests.branching/branch-creates-new-system-branch-not-from-master.stdout
+++ b/tests.branching/branch-creates-new-system-branch-not-from-master.stdout
@@ -6,11 +6,13 @@ d ./.morph/cache/gits
d ./.morph/cache/gits/file_morphs
d ./.morph/cache/gits/file_morphs/.git
d ./newbranch
-d ./newbranch/morphs
-d ./newbranch/morphs/.git
-f ./newbranch/morphs/hello-stratum.morph
-f ./newbranch/morphs/hello-system.morph
-f ./newbranch/morphs/this.is.alfred
+d ./newbranch/.morph-system-branch
+d ./newbranch/baserock:morphs
+d ./newbranch/baserock:morphs/.git
+f ./newbranch/.morph-system-branch/branch-root
+f ./newbranch/baserock:morphs/hello-stratum.morph
+f ./newbranch/baserock:morphs/hello-system.morph
+f ./newbranch/baserock:morphs/this.is.alfred
Current branches:
master
* newbranch
diff --git a/tests.branching/branch-creates-new-system-branch.script b/tests.branching/branch-creates-new-system-branch.script
index 61e9daf4..de1a81ee 100755
--- a/tests.branching/branch-creates-new-system-branch.script
+++ b/tests.branching/branch-creates-new-system-branch.script
@@ -1,15 +1,15 @@
#!/bin/sh
# Copyright (C) 2012 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.
@@ -18,18 +18,18 @@
set -eu
-cd "$DATADIR/mine"
+cd "$DATADIR/workspace"
"$SRCDIR/scripts/test-morph" init
-"$SRCDIR/scripts/test-morph" branch newbranch
+"$SRCDIR/scripts/test-morph" branch baserock:morphs newbranch
echo "File tree:"
-"$SRCDIR/scripts/list-tree" . | grep -v '/\.git/' |
+"$SRCDIR/scripts/list-tree" . | grep -v '/\.git/' |
sed 's,/cache/gits/file_[^/]*_,/cache/gits/file_,'
echo "Current branches:"
-"$SRCDIR/scripts/run-git-in" newbranch/morphs branch
+"$SRCDIR/scripts/run-git-in" newbranch/baserock:morphs branch
echo "Current origin:"
-"$SRCDIR/scripts/run-git-in" newbranch/morphs remote show origin |
- sed 's,\(TMP/mine/\.morph/cache/gits/file_\).*_,\1,g'
+"$SRCDIR/scripts/run-git-in" newbranch/baserock:morphs remote show origin |
+ sed 's,\(TMP/workspace/\.morph/cache/gits/file_\).*_,\1,g'
diff --git a/tests.branching/branch-creates-new-system-branch.stdout b/tests.branching/branch-creates-new-system-branch.stdout
index d2884b8c..3f2dba1d 100644
--- a/tests.branching/branch-creates-new-system-branch.stdout
+++ b/tests.branching/branch-creates-new-system-branch.stdout
@@ -6,10 +6,12 @@ d ./.morph/cache/gits
d ./.morph/cache/gits/file_morphs
d ./.morph/cache/gits/file_morphs/.git
d ./newbranch
-d ./newbranch/morphs
-d ./newbranch/morphs/.git
-f ./newbranch/morphs/hello-stratum.morph
-f ./newbranch/morphs/hello-system.morph
+d ./newbranch/.morph-system-branch
+d ./newbranch/baserock:morphs
+d ./newbranch/baserock:morphs/.git
+f ./newbranch/.morph-system-branch/branch-root
+f ./newbranch/baserock:morphs/hello-stratum.morph
+f ./newbranch/baserock:morphs/hello-system.morph
Current branches:
master
* newbranch
diff --git a/tests.branching/branch-when-branchdir-exists-locally.script b/tests.branching/branch-when-branchdir-exists-locally.script
index 4692b5f6..a98f6401 100755
--- a/tests.branching/branch-when-branchdir-exists-locally.script
+++ b/tests.branching/branch-when-branchdir-exists-locally.script
@@ -1,15 +1,15 @@
#!/bin/sh
# Copyright (C) 2012 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.
@@ -19,9 +19,9 @@
set -eu
-cd "$DATADIR/mine"
+cd "$DATADIR/workspace"
"$SRCDIR/scripts/test-morph" init
mkdir newbranch
-"$SRCDIR/scripts/test-morph" branch newbranch
+"$SRCDIR/scripts/test-morph" branch baserock:morphs newbranch
diff --git a/tests.branching/checkout-existing-branch.script b/tests.branching/checkout-existing-branch.script
index 74941e18..e7e3a379 100755
--- a/tests.branching/checkout-existing-branch.script
+++ b/tests.branching/checkout-existing-branch.script
@@ -1,33 +1,33 @@
#!/bin/sh
# Copyright (C) 2012 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.
-# Verify that "morph checkout master" works.
+# Verify that "morph checkout baserock:morphs master" works.
set -eu
-cd "$DATADIR/mine"
+cd "$DATADIR/workspace"
"$SRCDIR/scripts/test-morph" init
-"$SRCDIR/scripts/test-morph" checkout master
+"$SRCDIR/scripts/test-morph" checkout baserock:morphs master
echo "File tree:"
-"$SRCDIR/scripts/list-tree" . | grep -v '/\.git/' |
+"$SRCDIR/scripts/list-tree" . | grep -v '/\.git/' |
sed 's,/cache/gits/file_[^/]*_,/cache/gits/file_,'
echo "Current branches:"
-"$SRCDIR/scripts/run-git-in" master/morphs branch
+"$SRCDIR/scripts/run-git-in" master/baserock:morphs branch
diff --git a/tests.branching/checkout-existing-branch.stdout b/tests.branching/checkout-existing-branch.stdout
index 7f405fdb..1af2900c 100644
--- a/tests.branching/checkout-existing-branch.stdout
+++ b/tests.branching/checkout-existing-branch.stdout
@@ -6,9 +6,11 @@ d ./.morph/cache/gits
d ./.morph/cache/gits/file_morphs
d ./.morph/cache/gits/file_morphs/.git
d ./master
-d ./master/morphs
-d ./master/morphs/.git
-f ./master/morphs/hello-stratum.morph
-f ./master/morphs/hello-system.morph
+d ./master/.morph-system-branch
+d ./master/baserock:morphs
+d ./master/baserock:morphs/.git
+f ./master/.morph-system-branch/branch-root
+f ./master/baserock:morphs/hello-stratum.morph
+f ./master/baserock:morphs/hello-system.morph
Current branches:
* master
diff --git a/tests.branching/checkout-non-aliased-repos.script b/tests.branching/checkout-non-aliased-repos.script
new file mode 100755
index 00000000..6c9ac638
--- /dev/null
+++ b/tests.branching/checkout-non-aliased-repos.script
@@ -0,0 +1,61 @@
+#!/bin/bash
+# Copyright (C) 2012 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.
+
+
+# Verify that "morph checkout" works with repos that are not aliased.
+# This test in particular verifies that URI schemes are stripped off
+# and that the .git suffix is only removed at the end if it is actually
+# present.
+
+
+set -eu
+
+
+REPO_WITH_SUFFIX="file://$DATADIR/morphs.git"
+REPO_WITHOUT_SUFFIX="file://$DATADIR/morphs"
+
+TEMP_DIR=$(dirname "$DATADIR")
+
+cd "$DATADIR/workspace"
+
+"$SRCDIR/scripts/test-morph" init
+"$SRCDIR/scripts/test-morph" checkout "$REPO_WITH_SUFFIX" master
+
+echo "File tree of repo with suffix:"
+"$SRCDIR/scripts/list-tree" . | grep -v '/\.git/' |
+ sed 's,/cache/gits/file_[^/]*_,/cache/gits/file_,' |
+ sed "s,${DATADIR:1},DATADIR,g" |
+ sed "s,${TEMP_DIR:1},TEMP_DIR,g"
+
+echo "Current branches of repo with suffix:"
+"$SRCDIR/scripts/run-git-in" master/"${DATADIR:1}"/morphs branch
+
+cd "$DATADIR"
+rm -rf "$DATADIR/workspace"
+mkdir "$DATADIR/workspace"
+cd "$DATADIR/workspace"
+
+"$SRCDIR/scripts/test-morph" init
+"$SRCDIR/scripts/test-morph" checkout "$REPO_WITHOUT_SUFFIX" master
+
+echo "File tree of repo without suffix:"
+"$SRCDIR/scripts/list-tree" . | grep -v '/\.git/' |
+ sed 's,/cache/gits/file_[^/]*_,/cache/gits/file_,' |
+ sed "s,${DATADIR:1},DATADIR,g" |
+ sed "s,${TEMP_DIR:1},TEMP_DIR,g"
+
+echo "Current branches of repo without suffix:"
+"$SRCDIR/scripts/run-git-in" master/"${DATADIR:1}"/morphs branch
diff --git a/tests.branching/checkout-non-aliased-repos.stdout b/tests.branching/checkout-non-aliased-repos.stdout
new file mode 100644
index 00000000..872d74aa
--- /dev/null
+++ b/tests.branching/checkout-non-aliased-repos.stdout
@@ -0,0 +1,38 @@
+File tree of repo with suffix:
+d .
+d ./.morph
+d ./.morph/cache
+d ./.morph/cache/gits
+d ./.morph/cache/gits/file_git
+d ./.morph/cache/gits/file_git/.git
+d ./master
+d ./master/.morph-system-branch
+d ./master/tmp
+d ./master/TEMP_DIR
+d ./master/DATADIR
+d ./master/DATADIR/morphs
+d ./master/DATADIR/morphs/.git
+f ./master/.morph-system-branch/branch-root
+f ./master/DATADIR/morphs/hello-stratum.morph
+f ./master/DATADIR/morphs/hello-system.morph
+Current branches of repo with suffix:
+* master
+File tree of repo without suffix:
+d .
+d ./.morph
+d ./.morph/cache
+d ./.morph/cache/gits
+d ./.morph/cache/gits/file_morphs
+d ./.morph/cache/gits/file_morphs/.git
+d ./master
+d ./master/.morph-system-branch
+d ./master/tmp
+d ./master/TEMP_DIR
+d ./master/DATADIR
+d ./master/DATADIR/morphs
+d ./master/DATADIR/morphs/.git
+f ./master/.morph-system-branch/branch-root
+f ./master/DATADIR/morphs/hello-stratum.morph
+f ./master/DATADIR/morphs/hello-system.morph
+Current branches of repo without suffix:
+* master
diff --git a/tests.branching/edit-checkouts-existing-chunk.script b/tests.branching/edit-checkouts-existing-chunk.script
index 4e88ec7c..1c8e66cd 100755
--- a/tests.branching/edit-checkouts-existing-chunk.script
+++ b/tests.branching/edit-checkouts-existing-chunk.script
@@ -1,15 +1,15 @@
#!/bin/sh
# Copyright (C) 2012 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.
@@ -21,19 +21,19 @@
set -eu
# Checkout the master system branch.
-cd "$DATADIR/mine"
+cd "$DATADIR/workspace"
"$SRCDIR/scripts/test-morph" init
-"$SRCDIR/scripts/test-morph" checkout alfred
+"$SRCDIR/scripts/test-morph" checkout baserock:morphs alfred
# Edit the hello chunk in alfred.
-cd alfred/morphs
+cd alfred/baserock:morphs
"$SRCDIR/scripts/test-morph" edit baserock:hello alfred
echo "Current branches, morphs:"
-"$SRCDIR/scripts/run-git-in" "$DATADIR/mine/alfred/morphs" branch
+"$SRCDIR/scripts/run-git-in" "$DATADIR/workspace/alfred/baserock:morphs" branch
echo "Current branches, hello:"
-"$SRCDIR/scripts/run-git-in" "$DATADIR/mine/alfred/hello" branch
+"$SRCDIR/scripts/run-git-in" "$DATADIR/workspace/alfred/baserock:hello" branch
echo "Files in hello:"
-ls "$DATADIR/mine/alfred/hello"
+ls "$DATADIR/workspace/alfred/baserock:hello"
diff --git a/tests.branching/edit-clones-chunk.script b/tests.branching/edit-clones-chunk.script
index 8b87b4d2..7a3038a3 100755
--- a/tests.branching/edit-clones-chunk.script
+++ b/tests.branching/edit-clones-chunk.script
@@ -1,15 +1,15 @@
#!/bin/sh
# Copyright (C) 2012 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.
@@ -21,24 +21,29 @@
set -eu
# Create system branch.
-cd "$DATADIR/mine"
+cd "$DATADIR/workspace"
"$SRCDIR/scripts/test-morph" init
-"$SRCDIR/scripts/test-morph" branch newbranch
+"$SRCDIR/scripts/test-morph" branch baserock:morphs newbranch
# Edit chunk.
-cd newbranch/morphs
+cd newbranch/baserock:morphs
"$SRCDIR/scripts/test-morph" edit baserock:hello master
echo "Current branches, morphs:"
-"$SRCDIR/scripts/run-git-in" "$DATADIR/mine/newbranch/morphs" branch
+"$SRCDIR/scripts/run-git-in" \
+ "$DATADIR/workspace/newbranch/baserock:morphs" branch
echo "Current origin, morphs:"
-"$SRCDIR/scripts/run-git-in" "$DATADIR/mine/newbranch/morphs" \
- remote show origin | sed 's,\(TMP/mine/\.morph/cache/gits/file_\).*_,\1,g'
+"$SRCDIR/scripts/run-git-in" \
+ "$DATADIR/workspace/newbranch/baserock:morphs" \
+ remote show origin | \
+ sed 's,\(TMP/workspace/\.morph/cache/gits/file_\).*_,\1,g'
echo "Current branches, hello:"
-"$SRCDIR/scripts/run-git-in" "$DATADIR/mine/newbranch/hello" branch
+"$SRCDIR/scripts/run-git-in" \
+ "$DATADIR/workspace/newbranch/baserock:hello" branch
echo "Current origin, hello:"
-"$SRCDIR/scripts/run-git-in" "$DATADIR/mine/newbranch/hello" \
- remote show origin | sed 's,\(TMP/mine/\.morph/cache/gits/file_\).*_,\1,g'
+"$SRCDIR/scripts/run-git-in" "$DATADIR/workspace/newbranch/baserock:hello" \
+ remote show origin | \
+ sed 's,\(TMP/workspace/\.morph/cache/gits/file_\).*_,\1,g'
diff --git a/tests.branching/edit-updates-stratum.script b/tests.branching/edit-updates-stratum.script
index a3e213e5..db819088 100755
--- a/tests.branching/edit-updates-stratum.script
+++ b/tests.branching/edit-updates-stratum.script
@@ -1,15 +1,15 @@
#!/bin/sh
# Copyright (C) 2012 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.
@@ -21,12 +21,13 @@
set -eu
# Create system branch.
-cd "$DATADIR/mine"
+cd "$DATADIR/workspace"
"$SRCDIR/scripts/test-morph" init
-"$SRCDIR/scripts/test-morph" branch newbranch
+"$SRCDIR/scripts/test-morph" branch baserock:morphs newbranch
# Edit chunk.
-cd newbranch/morphs
"$SRCDIR/scripts/test-morph" edit baserock:hello master
+# See what effect the editing had.
+cd newbranch/baserock:morphs
git diff
diff --git a/tests.branching/edit-uses-ref-from-stratum.script b/tests.branching/edit-uses-ref-from-stratum.script
index 74c26d5a..0e4eb915 100755
--- a/tests.branching/edit-uses-ref-from-stratum.script
+++ b/tests.branching/edit-uses-ref-from-stratum.script
@@ -1,15 +1,15 @@
#!/bin/sh
# Copyright (C) 2012 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.
@@ -21,13 +21,12 @@
set -eu
# Create system branch.
-cd "$DATADIR/mine"
+cd "$DATADIR/workspace"
"$SRCDIR/scripts/test-morph" init
-"$SRCDIR/scripts/test-morph" branch newbranch
+"$SRCDIR/scripts/test-morph" branch baserock:morphs newbranch
# Edit chunk.
-cd newbranch/morphs
"$SRCDIR/scripts/test-morph" edit baserock:hello
-cd ../hello
+cd newbranch/baserock:hello
git branch
diff --git a/tests.branching/init-cwd.script b/tests.branching/init-cwd.script
index 91c23506..2d14586c 100755
--- a/tests.branching/init-cwd.script
+++ b/tests.branching/init-cwd.script
@@ -1,15 +1,15 @@
#!/bin/sh
# Copyright (C) 2012 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.
@@ -19,7 +19,7 @@ set -eu
# Test that "morph init" works for the current working directory.
-cd "$DATADIR/mine"
+cd "$DATADIR/workspace"
"$SRCDIR/scripts/test-morph" init .
-"$SRCDIR/scripts/list-tree" "$DATADIR/mine"
+"$SRCDIR/scripts/list-tree" "$DATADIR/workspace"
diff --git a/tests.branching/init-default.script b/tests.branching/init-default.script
index 5ec5148d..de4627e7 100755
--- a/tests.branching/init-default.script
+++ b/tests.branching/init-default.script
@@ -1,15 +1,15 @@
#!/bin/sh
# Copyright (C) 2012 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.
@@ -19,6 +19,6 @@ set -eu
# Test that "morph init" works without an explicit argument.
-cd "$DATADIR/mine"
+cd "$DATADIR/workspace"
"$SRCDIR/scripts/test-morph" init
-"$SRCDIR/scripts/list-tree" "$DATADIR/mine"
+"$SRCDIR/scripts/list-tree" "$DATADIR/workspace"
diff --git a/tests.branching/init-existing.script b/tests.branching/init-existing.script
index 59b658aa..e713b9df 100755
--- a/tests.branching/init-existing.script
+++ b/tests.branching/init-existing.script
@@ -1,15 +1,15 @@
#!/bin/sh
# Copyright (C) 2012 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.
@@ -20,5 +20,5 @@ set -eu
# Test that "morph init" works when given the name of an existing,
# empty directory.
-"$SRCDIR/scripts/test-morph" init "$DATADIR/mine"
-"$SRCDIR/scripts/list-tree" "$DATADIR/mine"
+"$SRCDIR/scripts/test-morph" init "$DATADIR/workspace"
+"$SRCDIR/scripts/list-tree" "$DATADIR/workspace"
diff --git a/tests.branching/init-newdir.script b/tests.branching/init-newdir.script
index 3bb4a1ba..5e79ce87 100755
--- a/tests.branching/init-newdir.script
+++ b/tests.branching/init-newdir.script
@@ -1,15 +1,15 @@
#!/bin/sh
# Copyright (C) 2012 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.
@@ -17,8 +17,8 @@
set -eu
-# Test that "morph init" gives an error when given the name of a
-# directory that does not exist yet.
+# Test that "morph init" works if given a directory that
+# does not exist yet.
"$SRCDIR/scripts/test-morph" init "$DATADIR/foo"
-
+"$SRCDIR/scripts/list-tree" "$DATADIR/foo"
diff --git a/tests.branching/init-newdir.stderr b/tests.branching/init-newdir.stderr
deleted file mode 100644
index 066d69c0..00000000
--- a/tests.branching/init-newdir.stderr
+++ /dev/null
@@ -1 +0,0 @@
-ERROR: can only initialize an existing empty directory: TMP/foo
diff --git a/tests.branching/init-newdir.stdout b/tests.branching/init-newdir.stdout
new file mode 100644
index 00000000..e7922ee1
--- /dev/null
+++ b/tests.branching/init-newdir.stdout
@@ -0,0 +1,2 @@
+d .
+d ./.morph
diff --git a/tests.branching/init-nonempty.script b/tests.branching/init-nonempty.script
index 28762d08..959da028 100755
--- a/tests.branching/init-nonempty.script
+++ b/tests.branching/init-nonempty.script
@@ -1,15 +1,15 @@
#!/bin/sh
# Copyright (C) 2012 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.
@@ -20,5 +20,5 @@ set -eu
# Test that "morph init" fails when given the name of an existing,
# non-empty directory.
-touch "$DATADIR/mine/foo"
-"$SRCDIR/scripts/test-morph" init "$DATADIR/mine"
+touch "$DATADIR/workspace/foo"
+"$SRCDIR/scripts/test-morph" init "$DATADIR/workspace"
diff --git a/tests.branching/init-nonempty.stderr b/tests.branching/init-nonempty.stderr
index 4ed4bba8..bc0ef0e1 100644
--- a/tests.branching/init-nonempty.stderr
+++ b/tests.branching/init-nonempty.stderr
@@ -1 +1 @@
-ERROR: can only initialize empty directory: TMP/mine
+ERROR: can only initialize empty directory as a workspace: TMP/workspace
diff --git a/tests.branching/merge-explicitly-named-repos.script b/tests.branching/merge-explicitly-named-repos.script
index 48705f8a..ad3ef0e6 100755
--- a/tests.branching/merge-explicitly-named-repos.script
+++ b/tests.branching/merge-explicitly-named-repos.script
@@ -1,15 +1,15 @@
#!/bin/sh
# Copyright (C) 2012 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.
@@ -22,27 +22,26 @@ set -eu
# Create system branch.
-cd "$DATADIR/mine"
+cd "$DATADIR/workspace"
"$SRCDIR/scripts/test-morph" init
-"$SRCDIR/scripts/test-morph" branch newbranch
+"$SRCDIR/scripts/test-morph" branch baserock:morphs newbranch
# Make a change to a chunk.
-cd newbranch/morphs
"$SRCDIR/scripts/test-morph" edit baserock:hello master
-cd ../hello
+cd newbranch/baserock:hello
touch newfile.txt
git add newfile.txt
git commit -m foo --quiet
# Merge changes to a new system branch.
-cd "$DATADIR/mine"
-"$SRCDIR/scripts/test-morph" branch otherbranch
-cd otherbranch/morphs
+cd "$DATADIR/workspace"
+"$SRCDIR/scripts/test-morph" branch baserock:morphs otherbranch
+cd otherbranch
"$SRCDIR/scripts/test-morph" edit baserock:hello master
"$SRCDIR/scripts/test-morph" merge newbranch baserock:hello
# Check results.
-cd ../hello
+cd baserock:hello
git status --short # make sure all changes are committed
ls newfile.txt # make sure the new file is there
diff --git a/tests.branching/minedir-not-found.script b/tests.branching/minedir-not-found.script
index eb8c9d51..690f45d3 100755
--- a/tests.branching/minedir-not-found.script
+++ b/tests.branching/minedir-not-found.script
@@ -1,19 +1,19 @@
#!/bin/sh
# Copyright (C) 2012 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.
-scripts/test-morph init "$DATADIR/mine"
+scripts/test-morph init "$DATADIR/workspace"
cd "$DATADIR"
-"$SRCDIR/scripts/test-morph" minedir
+"$SRCDIR/scripts/test-morph" workspace
diff --git a/tests.branching/minedir-not-found.stderr b/tests.branching/minedir-not-found.stderr
index 46dbd84b..ea9fb165 100644
--- a/tests.branching/minedir-not-found.stderr
+++ b/tests.branching/minedir-not-found.stderr
@@ -1 +1 @@
-ERROR: Can't find the mine directory
+ERROR: Can't find the workspace directory
diff --git a/tests.branching/minedir.script b/tests.branching/minedir.script
index 5f3574b7..f872a37d 100755
--- a/tests.branching/minedir.script
+++ b/tests.branching/minedir.script
@@ -1,20 +1,20 @@
#!/bin/sh
# Copyright (C) 2012 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.
-scripts/test-morph init "$DATADIR/mine"
-mkdir -p "$DATADIR/mine/a/b/c"
-cd "$DATADIR/mine/a/b/c"
-"$SRCDIR/scripts/test-morph" minedir
+scripts/test-morph init "$DATADIR/workspace"
+mkdir -p "$DATADIR/workspace/a/b/c"
+cd "$DATADIR/workspace/a/b/c"
+"$SRCDIR/scripts/test-morph" workspace
diff --git a/tests.branching/minedir.stdout b/tests.branching/minedir.stdout
index 0fc25ee9..14c44f7d 100644
--- a/tests.branching/minedir.stdout
+++ b/tests.branching/minedir.stdout
@@ -1 +1 @@
-TMP/mine
+TMP/workspace
diff --git a/tests.branching/petrify.script b/tests.branching/petrify.script
index 303d7f72..502c8220 100755
--- a/tests.branching/petrify.script
+++ b/tests.branching/petrify.script
@@ -1,15 +1,15 @@
#!/bin/sh
# Copyright (C) 2012 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.
@@ -21,12 +21,12 @@
set -eu
-cd "$DATADIR/mine"
+cd "$DATADIR/workspace"
"$SRCDIR/scripts/test-morph" init
"$SRCDIR/scripts/test-morph" update-gits baserock:morphs master \
hello-stratum.morph
-"$SRCDIR/scripts/test-morph" checkout master
+"$SRCDIR/scripts/test-morph" checkout baserock:morphs master
-cd master/morphs
+cd master/baserock:morphs
"$SRCDIR/scripts/test-morph" petrify hello-stratum.morph
cat hello-stratum.morph
diff --git a/tests.branching/setup b/tests.branching/setup
index 126714a0..477dd00a 100755
--- a/tests.branching/setup
+++ b/tests.branching/setup
@@ -18,7 +18,7 @@
# Set up $DATADIR.
#
# - a morph.conf configuration file
-# - an empty morph mine directory
+# - an empty morph workspace directory
# - a git repository called "morphs" for fake system, stratum morphologies
# - a git repository calle "hello" for a dummy chunk
@@ -41,7 +41,7 @@ GIT_COMMITTER_DATE="1343753514 +0000"
cat <<EOF > "$DATADIR/morph.conf"
[config]
repo-alias = baserock=file://$DATADIR/%s#file://$DATADIR/%s
-cachedir = $DATADIR/mine/.morph/cache
+cachedir = $DATADIR/workspace/.morph/cache
log = $DATADIR/morph.log
keep-path = true
no-distcc = true
@@ -49,13 +49,16 @@ quiet = true
EOF
-# Create an empty directory to be used as a morph mine
-mkdir "$DATADIR/mine"
+# Create an empty directory to be used as a morph workspace
+mkdir "$DATADIR/workspace"
# Create a fake morphs repository
mkdir "$DATADIR/morphs"
+## Create a link to this repo that has a .git suffix
+ln -s "$DATADIR/morphs" "$DATADIR/morphs.git"
+
cat <<EOF > "$DATADIR/morphs/hello-system.morph"
{
"name": "hello-system",
diff --git a/tests.branching/init-newdir.exit b/tests.branching/show-system-branch-fails-outside-workspace.exit
index d00491fd..d00491fd 100644
--- a/tests.branching/init-newdir.exit
+++ b/tests.branching/show-system-branch-fails-outside-workspace.exit
diff --git a/tests.branching/show-system-branch-shows-name-correctly.script b/tests.branching/show-system-branch-fails-outside-workspace.script
index 38b2aa14..5cd3bb98 100755
--- a/tests.branching/show-system-branch-shows-name-correctly.script
+++ b/tests.branching/show-system-branch-fails-outside-workspace.script
@@ -1,31 +1,33 @@
#!/bin/sh
# Copyright (C) 2012 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.
-# Check that 'morph show-system-branch' shows the name of the current system
-# branch correctly.
+# Check that 'morph show-system-branch' fails when being run
+# outside a workspace.
set -eu
-# Create system branch.
-cd "$DATADIR/mine"
+# Create a workspace and branch.
+cd "$DATADIR/workspace"
"$SRCDIR/scripts/test-morph" init
-"$SRCDIR/scripts/test-morph" branch newbranch
+"$SRCDIR/scripts/test-morph" branch baserock:morphs testbranch
-cd newbranch/morphs
-"$SRCDIR/scripts/test-morph" show-system-branch
+# Leave the workspace.
+cd ..
+# Try to show the current branch.
+"$SRCDIR/scripts/test-morph" show-system-branch
diff --git a/tests.branching/show-system-branch-fails-outside-workspace.stderr b/tests.branching/show-system-branch-fails-outside-workspace.stderr
new file mode 100644
index 00000000..ea9fb165
--- /dev/null
+++ b/tests.branching/show-system-branch-fails-outside-workspace.stderr
@@ -0,0 +1 @@
+ERROR: Can't find the workspace directory
diff --git a/tests.branching/show-system-branch-fails-when-branch-is-ambiguous.exit b/tests.branching/show-system-branch-fails-when-branch-is-ambiguous.exit
new file mode 100644
index 00000000..d00491fd
--- /dev/null
+++ b/tests.branching/show-system-branch-fails-when-branch-is-ambiguous.exit
@@ -0,0 +1 @@
+1
diff --git a/tests.branching/show-system-branch-fails-when-branch-is-ambiguous.script b/tests.branching/show-system-branch-fails-when-branch-is-ambiguous.script
new file mode 100755
index 00000000..2383deb9
--- /dev/null
+++ b/tests.branching/show-system-branch-fails-when-branch-is-ambiguous.script
@@ -0,0 +1,32 @@
+#!/bin/sh
+# Copyright (C) 2012 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.
+
+
+# Check that 'morph show-system-branch' fails when the system branch
+# is not obvious.
+
+
+set -eu
+
+# Create a workspace and two system branches
+cd "$DATADIR/workspace"
+"$SRCDIR/scripts/test-morph" init
+"$SRCDIR/scripts/test-morph" branch baserock:morphs first/branch
+"$SRCDIR/scripts/test-morph" branch baserock:morphs second/branch
+
+# Try to find out the branch from the workspace directory.
+cd "$DATADIR/workspace"
+"$SRCDIR/scripts/test-morph" show-system-branch
diff --git a/tests.branching/show-system-branch-fails-when-branch-is-ambiguous.stderr b/tests.branching/show-system-branch-fails-when-branch-is-ambiguous.stderr
new file mode 100644
index 00000000..7c784733
--- /dev/null
+++ b/tests.branching/show-system-branch-fails-when-branch-is-ambiguous.stderr
@@ -0,0 +1 @@
+ERROR: Can't find the system branch directory
diff --git a/tests.branching/show-system-branch-shows-name-correctly.stdout b/tests.branching/show-system-branch-shows-name-correctly.stdout
deleted file mode 100644
index 467e4889..00000000
--- a/tests.branching/show-system-branch-shows-name-correctly.stdout
+++ /dev/null
@@ -1 +0,0 @@
-newbranch
diff --git a/tests.branching/show-system-branch-works-anywhere-with-a-single-branch.script b/tests.branching/show-system-branch-works-anywhere-with-a-single-branch.script
new file mode 100755
index 00000000..eb565b91
--- /dev/null
+++ b/tests.branching/show-system-branch-works-anywhere-with-a-single-branch.script
@@ -0,0 +1,31 @@
+#!/bin/sh
+# Copyright (C) 2012 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.
+
+
+# Check that 'morph show-system-branch' works even outside a branch
+# if there only is one in the workspcae.
+
+
+set -eu
+
+# Create a workspace and a system branch.
+cd "$DATADIR/workspace"
+"$SRCDIR/scripts/test-morph" init
+"$SRCDIR/scripts/test-morph" branch baserock:morphs first/branch
+
+# Show the branch even when outside the branch.
+cd "$DATADIR/workspace"
+"$SRCDIR/scripts/test-morph" show-system-branch
diff --git a/tests.branching/show-system-branch-works-anywhere-with-a-single-branch.stdout b/tests.branching/show-system-branch-works-anywhere-with-a-single-branch.stdout
new file mode 100644
index 00000000..b934ad8e
--- /dev/null
+++ b/tests.branching/show-system-branch-works-anywhere-with-a-single-branch.stdout
@@ -0,0 +1 @@
+first/branch
diff --git a/tests.branching/show-system-branch-works-in-different-directories-in-a-branch.script b/tests.branching/show-system-branch-works-in-different-directories-in-a-branch.script
new file mode 100755
index 00000000..f4abc8ea
--- /dev/null
+++ b/tests.branching/show-system-branch-works-in-different-directories-in-a-branch.script
@@ -0,0 +1,57 @@
+#!/bin/sh
+# Copyright (C) 2012 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.
+
+
+# Check that 'morph show-system-branch' shows the name of the
+# current system branch correctly from various working directories.
+
+
+set -eu
+
+# Create a workspace and two system branches.
+cd "$DATADIR/workspace"
+"$SRCDIR/scripts/test-morph" init
+"$SRCDIR/scripts/test-morph" branch baserock:morphs first/branch
+"$SRCDIR/scripts/test-morph" branch baserock:morphs second/branch
+
+# Create a few subdirectories in the first branch.
+mkdir -p "$DATADIR/workspace/first/branch/foo"
+mkdir -p "$DATADIR/workspace/first/branch/bar"
+mkdir -p "$DATADIR/workspace/first/branch/foo/bar/baz"
+
+# Show the first branch when partially inside the branch.
+cd "$DATADIR/workspace/first"
+"$SRCDIR/scripts/test-morph" show-system-branch
+
+# Show the first branch when inside the main branch directory.
+cd "$DATADIR/workspace/first/branch"
+"$SRCDIR/scripts/test-morph" show-system-branch
+
+# Show the first branch when somewhere inside the branch.
+cd "$DATADIR/workspace/first/branch/foo"
+"$SRCDIR/scripts/test-morph" show-system-branch
+
+# Show the first branch when somewhere else inside the branch.
+cd "$DATADIR/workspace/first/branch/foo/bar/baz"
+"$SRCDIR/scripts/test-morph" show-system-branch
+
+# Show the second branch when partially inside the branch.
+cd "$DATADIR/workspace/second"
+"$SRCDIR/scripts/test-morph" show-system-branch
+
+# Show the second branch when inside the main branch directory.
+cd "$DATADIR/workspace/second/branch"
+"$SRCDIR/scripts/test-morph" show-system-branch
diff --git a/tests.branching/show-system-branch-works-in-different-directories-in-a-branch.stdout b/tests.branching/show-system-branch-works-in-different-directories-in-a-branch.stdout
new file mode 100644
index 00000000..f9cc3aec
--- /dev/null
+++ b/tests.branching/show-system-branch-works-in-different-directories-in-a-branch.stdout
@@ -0,0 +1,6 @@
+first/branch
+first/branch
+first/branch
+first/branch
+second/branch
+second/branch
diff --git a/tests.branching/workflow.script b/tests.branching/workflow.script
index 6a365d8e..c8ee2187 100755
--- a/tests.branching/workflow.script
+++ b/tests.branching/workflow.script
@@ -1,15 +1,15 @@
#!/bin/sh
# Copyright (C) 2012 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.
@@ -21,19 +21,18 @@
set -eu
-cd "$DATADIR/mine"
+cd "$DATADIR/workspace"
"$SRCDIR/scripts/test-morph" init
-"$SRCDIR/scripts/test-morph" branch me/readme-fix
-cd me/readme-fix/morphs
+"$SRCDIR/scripts/test-morph" branch baserock:morphs me/readme-fix
"$SRCDIR/scripts/test-morph" edit baserock:hello master
-cd ../hello
+cd me/readme-fix/baserock:hello
echo > README yoyoyo
git add README
git commit -m "Fix README, yo!" --quiet
-cd "$DATADIR/mine"
-"$SRCDIR/scripts/test-morph" checkout master
-cd master/morphs
+cd "$DATADIR/workspace"
+"$SRCDIR/scripts/test-morph" checkout baserock:morphs master
+cd master
"$SRCDIR/scripts/test-morph" edit baserock:hello master
-"$SRCDIR/scripts/test-morph" merge me/readme-fix hello
+"$SRCDIR/scripts/test-morph" merge me/readme-fix baserock:hello