diff options
author | Simon Westphahl <simon.westphahl@bmw.de> | 2020-07-17 15:14:59 +0200 |
---|---|---|
committer | Sebastian Thiel <sebastian.thiel@icloud.com> | 2020-08-12 20:37:58 +0800 |
commit | 6ef37754527948af1338f8e4a408bda7034d004f (patch) | |
tree | 5de34a3f1562056dc418eb3fd2feb9447bbf6788 | |
parent | 30387f16920f69544fcc7db40dfae554bcd7d1cc (diff) | |
download | gitpython-6ef37754527948af1338f8e4a408bda7034d004f.tar.gz |
Ensure only fully matching symrefs are deleted
Deleting a symbolic ref with e.g. the name 'refs/remotes/origin/mas'
would also delete 'refs/remotes/origin/master' if the ref had to be
deleted from the pack file.
In order to fix this the full ref is now checked for a match.
-rw-r--r-- | git/refs/symbolic.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/git/refs/symbolic.py b/git/refs/symbolic.py index 550464e5..60cfe554 100644 --- a/git/refs/symbolic.py +++ b/git/refs/symbolic.py @@ -445,12 +445,14 @@ class SymbolicReference(object): made_change = False dropped_last_line = False for line in reader: + line = line.decode(defenc) + _, _, line_ref = line.partition(' ') + line_ref = line_ref.strip() # keep line if it is a comment or if the ref to delete is not # in the line # If we deleted the last line and this one is a tag-reference object, # we drop it as well - line = line.decode(defenc) - if (line.startswith('#') or full_ref_path not in line) and \ + if (line.startswith('#') or full_ref_path != line_ref) and \ (not dropped_last_line or dropped_last_line and not line.startswith('^')): new_lines.append(line) dropped_last_line = False |