Skip to content

Commit 6ef3775

Browse files
westphahlByron
authored andcommitted
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.
1 parent 30387f1 commit 6ef3775

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Diff for: git/refs/symbolic.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -445,12 +445,14 @@ def delete(cls, repo, path):
445445
made_change = False
446446
dropped_last_line = False
447447
for line in reader:
448+
line = line.decode(defenc)
449+
_, _, line_ref = line.partition(' ')
450+
line_ref = line_ref.strip()
448451
# keep line if it is a comment or if the ref to delete is not
449452
# in the line
450453
# If we deleted the last line and this one is a tag-reference object,
451454
# we drop it as well
452-
line = line.decode(defenc)
453-
if (line.startswith('#') or full_ref_path not in line) and \
455+
if (line.startswith('#') or full_ref_path != line_ref) and \
454456
(not dropped_last_line or dropped_last_line and not line.startswith('^')):
455457
new_lines.append(line)
456458
dropped_last_line = False

0 commit comments

Comments
 (0)