Skip to content

More correct reference updating - #414

Merged
jdavid merged 5 commits into
libgit2:masterfrom
carlosmn:reference-update
Sep 5, 2014
Merged

jdavid merged 5 commits into
libgit2:masterfrom
carlosmn:reference-update

Conversation

@carlosmn

Copy link
Copy Markdown
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 Sep 4, 2014
@carlosmn

carlosmn commented Sep 4, 2014

Copy link
Copy Markdown
Member Author

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

2 participants