diff options
| author | Ben Straub <bstraub@github.com> | 2012-07-27 20:29:06 -0700 |
|---|---|---|
| committer | Ben Straub <bstraub@github.com> | 2012-07-27 20:31:05 -0700 |
| commit | b31667fb695dab0510cc5fc259e0569ff2a2ef41 (patch) | |
| tree | 859bd97b8f4ec70a9605385fadea1da108556541 /src/clone.c | |
| parent | 4d83399d35f0d3d489c50f2358bd5481a90ddce5 (diff) | |
| download | libgit2-b31667fb695dab0510cc5fc259e0569ff2a2ef41.tar.gz | |
Checkout: add head- and ref-centric checkouts.
Renamed git_checkout_index to what it really was,
and removed duplicate code from clone.c. Added
git_checkout_ref, which updates HEAD and hands off
to git_checkout_head.
Added tests for the options the caller can pass to
git_checkout_*.
Diffstat (limited to 'src/clone.c')
| -rw-r--r-- | src/clone.c | 21 |
1 files changed, 2 insertions, 19 deletions
diff --git a/src/clone.c b/src/clone.c index 7ae32a067..9b7ab8945 100644 --- a/src/clone.c +++ b/src/clone.c @@ -96,25 +96,8 @@ static int update_head_to_new_branch(git_repository *repo, const git_oid *target git_reference *head; if (!git_reference_lookup(&head, repo, GIT_HEAD_FILE)) { git_buf targetbuf = GIT_BUF_INIT; - if (!git_buf_printf(&targetbuf, "refs/heads/%s", name) && /* TODO: "refs/heads" constant? */ - !git_reference_set_target(head, git_buf_cstr(&targetbuf))) { - /* Read the tree into the index */ - git_commit *commit; - if (!git_commit_lookup(&commit, repo, target)) { - git_tree *tree; - if (!git_commit_tree(&tree, commit)) { - git_index *index; - if (!git_repository_index(&index, repo)) { - if (!git_index_read_tree(index, tree)) { - git_index_write(index); - retcode = 0; - } - git_index_free(index); - } - git_tree_free(tree); - } - git_commit_free(commit); - } + if (!git_buf_printf(&targetbuf, "refs/heads/%s", name)) { + retcode = git_reference_set_target(head, git_buf_cstr(&targetbuf)); } git_buf_free(&targetbuf); git_reference_free(head); |
