Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6ef3775

Browse filesBrowse 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
Copy full SHA for 6ef3775

1 file changed

+4-2Lines changed: 4 additions & 2 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎git/refs/symbolic.py‎

Copy file name to clipboardExpand all lines: git/refs/symbolic.py
+4-2Lines changed: 4 additions & 2 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.