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

More correct reference updating #414

Merged
merged 5 commits into from
Sep 5, 2014
Merged

Conversation

carlosmn
Copy link
Member

I realised that I never updated the references to the new method of updating. For now I've left Reference.target= as a proxy for the method call, but eventually we might like to remove it completely. Not specifying a message for the reflog significantly reduces the usability of the tools, so we should not provide a way to update which does not expose the existence of the reflog update.

We will also need to get rid of Reference.log_append() as that is now done as part of the reference update (due to race conditions and correctness wrt locking) and you should never call it directly.

This new method is Reference.set_target() which in addition lets you
specify what to use in the reflog.
We do not want this as it is riddled with race conditions.
Updating the target of a reference is not like setting a property. It
involves appending to the reflog under the same lock, so we must do it
all the same time. Thus setting the target becomes a function which
takes the new target and what the use would like to add to the reflog.
Following from the previous commits, make 'head' read-only and provide a
method to update head while providing a message.

The checkout() codepath which switches branches has been updated to
provide a reflog entry which mimics git's.
@carlosmn carlosmn changed the title [WIP] More correct reference updating More correct reference updating Sep 4, 2014
@carlosmn
Copy link
Member Author

carlosmn commented Sep 4, 2014

This should be ready for review. The move of set_head() to python was partly motivated by the fact that the C API considers passing None differently from not passing something which makes keeping the C version a pain.

@jdavid jdavid merged commit 747e7c2 into libgit2:master Sep 5, 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

Successfully merging this pull request may close these issues.

None yet

2 participants