The doc says:
* Updates files in the index and the working tree to match the content of
* the commit pointed at by HEAD.
But since git_checkout_head() simply calls git_checkout_tree() with a NULL tree, the checkout code will use HEAD as a baseline and attempts to check out HEAD against it. In practice this means, no attempt will be made to touch modified files (whatever the mode) or create missing ones (unless you happen to be GIT_CHECKOUT_SAFE_CREATE mode).
As an example, if you move the HEAD to a different commit then call git_checkout_head() expecting the index and workdir to be updated to reflect the new commit (as per the docs), nothing happens (and there are no errors either of course).
Is there a bug in the implementation, is the doc wrong, or is it really the intended behavior of git_checkout_head()?
PS: If the latter, what's the actual and most efficient way using libgit2 to update the index and workdir to match the HEAD?
The doc says:
But since
git_checkout_head()simply callsgit_checkout_tree()with aNULLtree, the checkout code will useHEADas a baseline and attempts to check outHEADagainst it. In practice this means, no attempt will be made to touch modified files (whatever the mode) or create missing ones (unless you happen to beGIT_CHECKOUT_SAFE_CREATEmode).As an example, if you move the
HEADto a different commit then callgit_checkout_head()expecting the index and workdir to be updated to reflect the new commit (as per the docs), nothing happens (and there are no errors either of course).Is there a bug in the implementation, is the doc wrong, or is it really the intended behavior of
git_checkout_head()?PS: If the latter, what's the actual and most efficient way using libgit2 to update the index and workdir to match the
HEAD?