diff --git a/heptapod/hooks/git_sync.py b/heptapod/hooks/git_sync.py
index 96e00fae505b9c6b94da2561e74e95a66c3cba85_aGVwdGFwb2QvaG9va3MvZ2l0X3N5bmMucHk=..56e71c24fd6360585a4552aea524d39b30bafad6_aGVwdGFwb2QvaG9va3MvZ2l0X3N5bmMucHk= 100644
--- a/heptapod/hooks/git_sync.py
+++ b/heptapod/hooks/git_sync.py
@@ -6,6 +6,10 @@
 
 
 def mirror_path(ui, repo):
+    dest = ui.config('heptapod', 'mirror-path')
+    if dest:
+        return dest
+
     repos_root = ui.config('heptapod', 'repositories-root')
     if not repos_root:
         raise error.Abort(_("heptapod.repositories-root not set"))
@@ -9,24 +13,22 @@
     repos_root = ui.config('heptapod', 'repositories-root')
     if not repos_root:
         raise error.Abort(_("heptapod.repositories-root not set"))
-    dest = ui.config('heptapod', 'mirror-path')
-    if not dest:
-        # Mercurial gives us `realpath` of repos. Therefore, if the whole
-        # repositories root turns out to be a symlink, we need to
-        # use its `realpath`, too.
-        repos_root = os.path.realpath(repos_root)
-        repo_path = repo.root
-        if repo_path is None:
-            raise error.Abort(_(
-                'heptapod.mirror-path repository not configured, and '
-                'cannot find current repository filesystem path'))
-        rpath = os.path.relpath(repo_path, repos_root)
-        if rpath.startswith(UP_DIR) or not rpath.endswith('.hg'):
-            raise error.Abort(_(
-                'heptapod.mirror-path repository not configured, and '
-                'inferred relative path %r is invalid' % rpath))
-        dest = 'git+ssh://git@localhost:' + rpath.rsplit('.', 1)[0] + '.git'
-    return dest
+
+    # Mercurial gives us `realpath` of repos. Therefore, if the whole
+    # repositories root turns out to be a symlink, we need to
+    # use its `realpath`, too.
+    repos_root = os.path.realpath(repos_root)
+    repo_path = repo.root
+    if repo_path is None:
+        raise error.Abort(_(
+            'heptapod.mirror-path repository not configured, and '
+            'cannot find current repository filesystem path'))
+    rpath = os.path.relpath(repo_path, repos_root)
+    if rpath.startswith(UP_DIR) or not rpath.endswith('.hg'):
+        raise error.Abort(_(
+            'heptapod.mirror-path repository not configured, and '
+            'inferred relative path %r is invalid' % rpath))
+    return 'git+ssh://git@localhost:' + rpath.rsplit('.', 1)[0] + '.git'
 
 
 def mirror(ui, repo, *args, **kwargs):
diff --git a/heptapod/hooks/tests/test_git_sync.py b/heptapod/hooks/tests/test_git_sync.py
new file mode 100644
index 0000000000000000000000000000000000000000..56e71c24fd6360585a4552aea524d39b30bafad6_aGVwdGFwb2QvaG9va3MvdGVzdHMvdGVzdF9naXRfc3luYy5weQ==
--- /dev/null
+++ b/heptapod/hooks/tests/test_git_sync.py
@@ -0,0 +1,54 @@
+from __future__ import absolute_import
+import pytest
+
+from mercurial import (
+    error,
+)
+from heptapod.testhelpers import (
+    LocalRepoWrapper,
+    make_ui,
+    )
+from ..git_sync import (
+    mirror_path,
+    )
+
+
+def init_repo(basedir, name):
+    repos_root = basedir.join('repositories')
+    return LocalRepoWrapper.init(
+        repos_root.join(name),
+        config=dict(
+            heptapod={'repositories-root': str(repos_root)}
+        ))
+
+
+def test_mirror_path(tmpdir):
+    wrapper = init_repo(tmpdir, 'proj.hg')
+    repo = wrapper.repo
+    assert mirror_path(repo.ui, repo) == 'git+ssh://git@localhost:proj.git'
+
+    # now for some sabotage
+    repo.ui.setconfig('heptapod', 'mirror-path', None)
+    repo.root = None
+    with pytest.raises(error.Abort):
+        mirror_path(repo.ui, repo)
+
+
+def test_mirror_path_locally_set(tmpdir):
+    ui = make_ui(None, dict(heptapod={'mirror-path': '/hard/coded'}))
+    assert mirror_path(ui, None) == '/hard/coded'
+
+
+def test_mirror_path_no_root(tmpdir):
+    ui = make_ui(None)
+    with pytest.raises(error.Abort) as exc_info:
+        mirror_path(ui, None)
+    assert "heptapod.repositories-root not set" in exc_info.value.args[0]
+
+
+def test_mirror_path_unknown(tmpdir):
+    wrapper = init_repo(tmpdir, 'proj.svn')
+    repo = wrapper.repo
+    with pytest.raises(error.Abort) as exc_info:
+        mirror_path(repo.ui, repo)
+    assert "'proj.svn' is invalid" in exc_info.value.args[0]