Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

repo.ref("HEAD") -> KeyError #2

Closed
brosner opened this issue Jun 16, 2009 · 1 comment
Closed

repo.ref("HEAD") -> KeyError #2

brosner opened this issue Jun 16, 2009 · 1 comment

Comments

@brosner
Copy link

brosner commented Jun 16, 2009

I am new to the code base and have been trying to get my head around it (though pretty easy to follow along).

With the repo I am working with I am seeing this:

>>> from dulwich.repo import Repo
>>> repo = Repo("<my bare repo path>")
>>> repo.head()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/brian/Development/dulwich/dulwich/repo.py", line 308, in head
    return self.refs.follow('HEAD')
  File "/Users/brian/Development/dulwich/dulwich/repo.py", line 82, in follow
    return follow_ref(self, name)
  File "/Users/brian/Development/dulwich/dulwich/repo.py", line 65, in follow_ref
    return follow_ref(container, ref)
  File "/Users/brian/Development/dulwich/dulwich/repo.py", line 60, in follow_ref
    contents = container[name]
  File "/Users/brian/Development/dulwich/dulwich/repo.py", line 163, in __getitem__
    raise KeyError(name)
KeyError: 'refs/heads/master'

Digging in a bit deeper I see that refs/heads/master is a packed ref which is why it cannot find it in refs/heads. Is there any reason why Repo.head uses self.refs.follow over self.ref? Hence the title. ref looks in packed refs, but doesn't know what HEAD is equal to to pull out the right ref.

I am sort of lost in the implementation to find the correct place to solve this.

@jelmer
Copy link
Owner

jelmer commented Apr 2, 2010

AFAIK this has been fixed.

jelmer pushed a commit that referenced this issue Oct 25, 2016
# This is the 1st commit message:
Support linked working directories

Support for linked working directories:
- Add `commondir()` (equivalent to `GIT_COMMON_DIR`)
- Read the `commondir` file, to set it.

See `git-worktree(1)` and `gitrepository-layout(5)`.

# The commit message #2 will be skipped:

#	Fix DiskRefsContainer.refpath()

# The commit message #3 will be skipped:

#	Add a testsuite

# The commit message #4 will be skipped:

#	Add @skipIf for WorkingTreeTestCase

# The commit message #5 will be skipped:

#	worktree is optional and default to path

# The commit message #6 will be skipped:

#	add a TODO

# The commit message #7 will be skipped:

#	Save one syscall
#
#	See https://github.com/jelmer/dulwich/pull/454/files/0927deb7cd2ad24294b89e319ea060ed488acbba#r82424872

# The commit message #8 will be skipped:

#	Read commondir with get_named_file()
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants