-
Notifications
You must be signed in to change notification settings - Fork 515
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
Grit::GitRuby::Internal::PackFormatError #117
Comments
Got same error with same env(ruby 1.9.3-p194 on rbenv). any updates? [1] pry(main)> c = Grit::Repo.new './'
=> #<Grit::Repo "/Users/dfujimura/sandbox/some-repo/.git">
[2] pry(main)> c.commits
Grit::GitRuby::Internal::PackFormatError: pack /Users/dfujimura/sandbox/some-repo/.git/objects/pack/pack-0c53037493ffa0fdb824180e05de021e66e53d63.pack has discontinuous index 1
from /Users/dfujimura/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/grit-2.5.0/lib/grit/git-ruby/internal/pack.rb:135:in `block (2 levels) in init_pack'
|
Heh, I think I found the issue. It's encodings related. So basically it opens the index file in binary mode. There are two formats of index/pack files: version 1 and version 2. Version 2 is marked by a 4 byte signature ( The index reader takes this into account and applies an 8 byte offset for all version 2 files and a 0 byte offset for all version 1 files: https://github.com/github/grit/blob/master/lib/grit/git-ruby/internal/file_window.rb#L19-L23 The determination of version is handled by comparing the signature with PACK_IDX_SIGNATURE: https://github.com/github/grit/blob/master/lib/grit/git-ruby/internal/pack.rb#L63 PACK_IDX_SIGNATURE is defined as a string literal: https://github.com/github/grit/blob/master/lib/grit/git-ruby/internal/pack.rb#L17 The 4 byte signature is read out of a file in binary, so it explicitly has an encoding of "ASCII-8BIT". PACK_IDX_SIGNATURE is a string literal, so its encoding is determined as whatever ruby wants it to be (on my mac that's ASCII-8BIT, on my server that's UTF-8). For a string to be equal both content and encoding must be equal. Hilarity ensues. The actual error message is produced because the file is thought to be version 1, so it reads two integers from the file starting at index 0. These are 4285812579 and 2. |
Please fix this! Got this problem when using gollum. |
Only happens for me with ruby 2.0 (installed via rvm). With ruby 1.9.3 everything seems to be fine. |
I also get this on rvm 1.18.21 (stable) when using gollum. |
I can confirm that this only happens with Ruby 2.0. With 1.9.3 everything is fine. |
An I can confirm this always happens on 2.0 and sometimes on 1.9.3 (I have such a repo but can't share it). Also I'd wish to admit that Grit seems to be dead. |
Signed-off-by: Mikhail S. Pobolovets <styx.mp@gmail.com> Conflicts: lib/grit/git-ruby/internal/pack.rb
Signed-off-by: Mikhail S. Pobolovets <styx.mp@gmail.com> Conflicts: lib/grit/git-ruby/internal/pack.rb
This commit (https://github.com/BertramScharpf/grit/commit/6fc5006cca4f07f7f82383fb4d822c509cc516ee) solved the issue in my case. with git 1.8.4, rvm 1.24.1, ruby 2.0.0-p353 |
Grit is no longer maintained. See #183 and check out libgit2/rugged. |
calling tree to try to determine if a directory exists exposed this error mojombo/grit#117 hacking a workaround for now to check for the readme using a method which uses JGit instead
The text was updated successfully, but these errors were encountered: