Skip to content

ValueError: cannot mmap an empty file on head.log() #758

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

Open
peterbe opened this issue May 21, 2018 · 0 comments
Open

ValueError: cannot mmap an empty file on head.log() #758

peterbe opened this issue May 21, 2018 · 0 comments

Comments

@peterbe
Copy link
Contributor

peterbe commented May 21, 2018

When I do:

log = head.log()

I sometimes get this error:

Traceback (most recent call last):
  File "/usr/local/bin/gg", line 11, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args[1:], **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/gg/builtins/branches/gg_branches.py", line 25, in branches
    print_list(branches_, merged)
  File "/usr/local/lib/python3.6/site-packages/gg/builtins/branches/gg_branches.py", line 96, in print_list
    [wrap(head) for head in heads], key=lambda x: x["info"].get("date")
  File "/usr/local/lib/python3.6/site-packages/gg/builtins/branches/gg_branches.py", line 96, in <listcomp>
    [wrap(head) for head in heads], key=lambda x: x["info"].get("date")
  File "/usr/local/lib/python3.6/site-packages/gg/builtins/branches/gg_branches.py", line 64, in wrap
    log = head.log()
  File "/usr/local/lib/python3.6/site-packages/git/refs/symbolic.py", line 358, in log
    return RefLog.from_file(RefLog.path(self))
  File "/usr/local/lib/python3.6/site-packages/git/refs/log.py", line 177, in from_file
    return cls(filepath)
  File "/usr/local/lib/python3.6/site-packages/git/refs/log.py", line 151, in __init__
    self._read_from_file()
  File "/usr/local/lib/python3.6/site-packages/git/refs/log.py", line 156, in _read_from_file
    fmap = file_contents_ro_filepath(self._path, stream=True, allow_mmap=True)
  File "/usr/local/lib/python3.6/site-packages/gitdb/util.py", line 209, in file_contents_ro_filepath
    return file_contents_ro(fd, stream, allow_mmap)
  File "/usr/local/lib/python3.6/site-packages/gitdb/util.py", line 179, in file_contents_ro
    return mmap.mmap(fd, 0, access=mmap.ACCESS_READ)
ValueError: cannot mmap an empty file

That head is an object like this: <git.Head "refs/heads/bug-1361148-use-locmemcache-in-unit-tests"> when I repr it.

These are old branches usually that it happens to. I think. But I can do:

git checkout bug-1361148-use-locmemcache-in-unit-tests
git log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants