Skip to content

Cannot refer to branch name with hyphens #552

@johnnybubonic

Description

@johnnybubonic

Here's the PoC:

#!/bin/env python3

import os
import shutil
import git


srcdir = '/tmp/src'
ipxe_src = srcdir + '/ipxe'
ipxe_git_uri = 'git://git.ipxe.org/ipxe.git'
patches_git_uri = 'https://github.com/eworm-de/ipxe.git'
if os.path.isdir(ipxe_src):
    shutil.rmtree(ipxe_src)
os.makedirs(srcdir, exist_ok=True)

ipxe_repo = git.Repo.clone_from(ipxe_git_uri, ipxe_src)  # all good

patches = ipxe_repo.create_remote('eworm', patches_git_uri)  # still good

patches.fetch()  # yep, still okay

ipxe_repo.create_head('patches_m', patches.refs.master)  # works great!

ipxe_repo.create_head('patches_e', patches.refs.efi-iso-emul)  # HORRIBLE BURNING DEATH

print("Congrats, the bug isn't reproduced for you")

To save you some time, "AttributeError: 'IterableList' object has no attribute 'eworm/efi'"

here's the interesting part.

patches.refs
[<git.RemoteReference "refs/remotes/eworm/branding">, <git.RemoteReference "refs/remotes/eworm/efi-iso-emul">, <git.RemoteReference "refs/remotes/eworm/master">, <git.RemoteReference "refs/remotes/eworm/no-pie">]

So it's clearly there.

>>> patches.refs.efi-iso-emul
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.5/site-packages/git/util.py", line 879, in __getattr__
    return list.__getattribute__(self, attr)
AttributeError: 'IterableList' object has no attribute 'eworm/efi'

AND it can even be done properly when referred to by the list index number:

>>> ipxe_repo.create_head('patches_e', patches.refs[1])
<git.Head "refs/heads/patches_e">

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions