summaryrefslogtreecommitdiffstats
path: root/project.py
diff options
context:
space:
mode:
authorNico Sallembien <nsallembien@google.com>2010-01-20 10:27:50 -0800
committerNico Sallembien <nsallembien@google.com>2010-01-20 10:27:50 -0800
commitd63060fc9546e2132d0ad7791beb795906372e86 (patch)
tree9b0241a1b609cc1563582e6664e3df27732de3af /project.py
parentb6ea3bfcc398417b91a4fa5a486324f4d904b022 (diff)
downloadgit-repo-d63060fc9546e2132d0ad7791beb795906372e86.tar.gz
Check that we are not overwriting a local repository when syncing.v1.6.8.11
If a local git repository exists within the same folder as a new project that is added, when the user syncs the repo, the sync will overwrite the local files under the project's .git repository with its own symlinks. Make sure that we do not overwrite 'normal' files in repo and throw an error when that happens.
Diffstat (limited to 'project.py')
-rw-r--r--project.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/project.py b/project.py
index 4930a275..902a2b44 100644
--- a/project.py
+++ b/project.py
@@ -1120,7 +1120,10 @@ class Project(object):
1120 try: 1120 try:
1121 src = os.path.join(self.gitdir, name) 1121 src = os.path.join(self.gitdir, name)
1122 dst = os.path.join(dotgit, name) 1122 dst = os.path.join(dotgit, name)
1123 os.symlink(relpath(src, dst), dst) 1123 if os.path.islink(dst) or not os.path.exists(dst):
1124 os.symlink(relpath(src, dst), dst)
1125 else:
1126 raise GitError('cannot overwrite a local work tree')
1124 except OSError, e: 1127 except OSError, e:
1125 if e.errno == errno.EPERM: 1128 if e.errno == errno.EPERM:
1126 raise GitError('filesystem must support symlinks') 1129 raise GitError('filesystem must support symlinks')