diff options
author | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2014-11-04 12:56:53 +0000 |
---|---|---|
committer | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2014-11-05 13:21:04 +0000 |
commit | 509b1985807a308e31bdff595c939503b6d26a40 (patch) | |
tree | fb0e6e186ab4acf28d43bd6e3555fe1f2f3a289d /morphlib/plugins | |
parent | ac9e6787cd2b82bc37b9ba71d09d44aac71f85b1 (diff) | |
download | morph-509b1985807a308e31bdff595c939503b6d26a40.tar.gz |
Only search for repository root in GitDirectory constructor if told to
The GitDirectory() constructor, if passed a 'dirname' that doesn't
contain a '.git' subdirectory, can search upwards to find the real root
of the repository. This is used by the `add-binary`, `push`, and `pull`
commands.
This causes very confusing behaviour in the case that 'dirname' points to
a directory that should be a Git repository, but isn't, and that directory
is a path inside the working tree of another Git repository. Rather than
raising an error, in this case the GitDirectory class would perform
operations on a different repository to the one the caller expected.
This 'search_for_root' behaviour is now opt-in, to avoid confusion.
Diffstat (limited to 'morphlib/plugins')
-rw-r--r-- | morphlib/plugins/add_binary_plugin.py | 2 | ||||
-rw-r--r-- | morphlib/plugins/push_pull_plugin.py | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/morphlib/plugins/add_binary_plugin.py b/morphlib/plugins/add_binary_plugin.py index a192f792..dee1d9c4 100644 --- a/morphlib/plugins/add_binary_plugin.py +++ b/morphlib/plugins/add_binary_plugin.py @@ -56,7 +56,7 @@ class AddBinaryPlugin(cliapp.Plugin): if not binaries: raise morphlib.Error('add-binary must get at least one argument') - gd = morphlib.gitdir.GitDirectory(os.getcwd()) + gd = morphlib.gitdir.GitDirectory(os.getcwd(), search_for_root=True) gd.fat_init() if not gd.has_fat(): self._make_gitfat(gd) diff --git a/morphlib/plugins/push_pull_plugin.py b/morphlib/plugins/push_pull_plugin.py index 843de1a6..ddc9a8af 100644 --- a/morphlib/plugins/push_pull_plugin.py +++ b/morphlib/plugins/push_pull_plugin.py @@ -52,7 +52,7 @@ class PushPullPlugin(cliapp.Plugin): if len(args) != 2: raise morphlib.Error('push must get exactly two arguments') - gd = morphlib.gitdir.GitDirectory(os.getcwd()) + gd = morphlib.gitdir.GitDirectory(os.getcwd(), search_for_root=True) remote, branch = args rs = morphlib.gitdir.RefSpec(branch) gd.get_remote(remote).push(rs) @@ -81,7 +81,7 @@ class PushPullPlugin(cliapp.Plugin): if len(args) > 1: raise morphlib.Error('pull takes at most one argument') - gd = morphlib.gitdir.GitDirectory(os.getcwd()) + gd = morphlib.gitdir.GitDirectory(os.getcwd(), search_for_root=True) remote = gd.get_remote('origin') if args: branch = args[0] |