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

I get nil for blob.name when fetched directly from the Repo #12

Closed
krisleech opened this issue Feb 10, 2010 · 4 comments
Closed

I get nil for blob.name when fetched directly from the Repo #12

krisleech opened this issue Feb 10, 2010 · 4 comments

Comments

@krisleech
Copy link

r=Repo.new('~/git/test')
c=r.commits('114456d6606ca35c8ceec669aebb3a5b56ebdd0d').first
b=c.tree.contents.first
b.name #=> "README"
bb = r.blob(b.id)
bb.name #=> nil

Grit version 2.0

@blackspace
Copy link

who give me a answer?I run into the same issue.

@krisleech
Copy link
Author

When looking up a blob, eg. r.blob(b.id), you get an 'unbaked' blob. This is the terminology used in the source code and it seems to suggest the blob instance has not been populated with any values yet. I do not know how to 'bake' the blob however.

@schleyfox
Copy link

"A "blob" object is nothing but a chunk of binary data. It doesn't refer to anything else or have attributes of any kind, not even a file name.

Since the blob is entirely defined by its data, if two files in a directory tree (or in multiple different versions of the repository) have the same contents, they will share the same blob object. The object is totally independent of its location in the directory tree, and renaming a file does not change the object that file is associated with." -- from http://book.git-scm.com/1_the_git_object_model.html

A blob only gets a name if it is initialized via an action where it would have a name (e.g. tree traversal). Looking up a blob by its id will only return the content, size, and type.

@bkeepers
Copy link
Collaborator

bkeepers commented Feb 3, 2014

Grit is no longer maintained. See #183 and check out libgit2/rugged.

@bkeepers bkeepers closed this as completed Feb 3, 2014
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

4 participants