From 80a9d3ee14688feada4bd799d02892ba66aa80fa Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Fri, 23 Mar 2012 17:20:51 +0000 Subject: Make "morph edit" work when chunk already has the branch --- morph | 7 ++-- .../edit-checkouts-existing-chunk.script | 37 ++++++++++++++++++++++ .../edit-checkouts-existing-chunk.stdout | 4 +++ 3 files changed, 46 insertions(+), 2 deletions(-) create mode 100755 tests.branching/edit-checkouts-existing-chunk.script create mode 100644 tests.branching/edit-checkouts-existing-chunk.stdout diff --git a/morph b/morph index 16f98720..377fc787 100755 --- a/morph +++ b/morph @@ -487,8 +487,11 @@ class Morph(cliapp.Application): new_repo = os.path.join(mine_directory, system_branch, os.path.basename(repo)) self._clone_to_directory(new_repo, repo, ref) - self.runcmd(['git', 'checkout', '-b', system_branch, ref], - cwd=new_repo) + + system_branch = self._deduce_system_branch() + if system_branch != ref: + self.runcmd(['git', 'checkout', '-b', system_branch, ref], + cwd=new_repo) def cmd_merge(self, args): '''Merge specified repositories from another system branch.''' diff --git a/tests.branching/edit-checkouts-existing-chunk.script b/tests.branching/edit-checkouts-existing-chunk.script new file mode 100755 index 00000000..cc5977ca --- /dev/null +++ b/tests.branching/edit-checkouts-existing-chunk.script @@ -0,0 +1,37 @@ +#!/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 edit" clones a chunk repository into a system branch. + + +set -eu + +# Checkout the master system branch. +cd "$DATADIR/mine" +"$SRCDIR/scripts/test-morph" init +"$SRCDIR/scripts/test-morph" checkout master + +# Edit the hello chunk in master. +cd master/morphs +"$SRCDIR/scripts/test-morph" edit hello master + +echo "Current branches, morphs:" +"$SRCDIR/scripts/run-git-in" "$DATADIR/mine/master/morphs" branch + +echo "Current branches, hello:" +"$SRCDIR/scripts/run-git-in" "$DATADIR/mine/master/hello" branch + diff --git a/tests.branching/edit-checkouts-existing-chunk.stdout b/tests.branching/edit-checkouts-existing-chunk.stdout new file mode 100644 index 00000000..c5be6aed --- /dev/null +++ b/tests.branching/edit-checkouts-existing-chunk.stdout @@ -0,0 +1,4 @@ +Current branches, morphs: +* master +Current branches, hello: +* master -- cgit v1.2.1