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

Add flexibility when dealing with index entries #325

Merged
merged 5 commits into from
Jan 29, 2014

Conversation

carlosmn
Copy link
Member

Let IndexEntry instances live independent of their original index and bring some memory safety. Move to get an own copy of each instead of pointing to the copy inside the index, which we cannot trust to keep existing.

Allow creation of IndexEntry instances, which we need in order to make working with bare repositories more comfortable.

@jdavid
Copy link
Member

jdavid commented Jan 28, 2014

There is something Travis does not like.

Otherwise this is good to me (the inline comments are not blockers).

@carlosmn
Copy link
Member Author

That Travis error is pretty odd... looks like it might be due to different unittest versions. I'll work around that.

@jdavid
Copy link
Member

jdavid commented Jan 29, 2014

There are two different errors actually:

  • assertIsNotNone is new in Python 2.7
  • PyInt_AsLong is not anymore in Python 3 (use PyLong_AsLong instead)

The tree entries exist more or less independently of the index they were
retrieved from. The idea behind them is that they can be kept by a
binding without needing to refer to the original anymore, which may
disappear at any moment if the index is modified.

Keep a copy of the data in TreeEntry instead of pointing to the one
retrieved from the index, which is not safe to keep around.
They are not required to belong to a particular index, so it should be
possible to create them at runtime in order to insert them.
@carlosmn
Copy link
Member Author

Oh, I see; Ok, both of those things have been solved, I'll take a look at type-checking. I think I did at some point, but you'd need to check for both PyString_Check() and PyUnicode_Check() and each lets you get the string in a slightly different way.

@jdavid
Copy link
Member

jdavid commented Jan 29, 2014

Travis still failing, with another error.

The improved input handling can wait for another PR.

When updating entries in an index, it is necessary to modify the
attributes of tree entries. make it possible to do so.
A path is only useful if we have the file on the worktree. Passing an
IndexEntry allows us to add an entry with arbitrary attributes.
Take an optional repository in Index.write_tree() to serialize to a tree
into a particular repository's odb.
@carlosmn
Copy link
Member Author

I had seen that error, but chalked it up to a messed-up local setup. Third time's the charm, though

@jdavid jdavid merged commit f3f3d28 into libgit2:master Jan 29, 2014
@carlosmn carlosmn deleted the index-add-entry branch February 6, 2014 10:12
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

Successfully merging this pull request may close these issues.

2 participants