summaryrefslogtreecommitdiff
path: root/lib/git/refs.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/git/refs.py')
-rw-r--r--lib/git/refs.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/git/refs.py b/lib/git/refs.py
index 0b8b2a98..ec70c72b 100644
--- a/lib/git/refs.py
+++ b/lib/git/refs.py
@@ -334,9 +334,15 @@ class SymbolicReference(object):
return self
new_abs_path = os.path.join(self.repo.git_dir, new_path)
+ cur_abs_path = os.path.join(self.repo.git_dir, self.path)
if os.path.isfile(new_abs_path):
if not force:
- raise OSError("File at path %r already exists" % new_abs_path)
+ # if they point to the same file, its not an error
+ if open(new_abs_path,'rb').read() != open(cur_abs_path,'rb').read():
+ raise OSError("File at path %r already exists" % new_abs_path)
+ # else: we could remove ourselves and use the otherone, but
+ # but clarity we just continue as usual
+ # END not force handling
os.remove(new_abs_path)
# END handle existing target file
@@ -345,7 +351,6 @@ class SymbolicReference(object):
os.makedirs(dirname)
# END create directory
- cur_abs_path = os.path.join(self.repo.git_dir, self.path)
os.rename(cur_abs_path, new_abs_path)
self.path = new_path