mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-09 18:22:16 +00:00
Checkout: fix problem with detached HEAD.
This commit is contained in:
parent
5280f4e698
commit
5f4d2f9f65
@ -216,15 +216,12 @@ int git_checkout_reference(git_reference *ref,
|
|||||||
git_reference *head = NULL;
|
git_reference *head = NULL;
|
||||||
int retcode = GIT_ERROR;
|
int retcode = GIT_ERROR;
|
||||||
|
|
||||||
if ((retcode = git_reference_lookup(&head, repo, GIT_HEAD_FILE)) < 0)
|
if ((retcode = git_reference_create_symbolic(&head, repo, GIT_HEAD_FILE,
|
||||||
|
git_reference_name(ref), true)) < 0)
|
||||||
return retcode;
|
return retcode;
|
||||||
|
|
||||||
if ((retcode = git_reference_set_target(head, git_reference_name(ref))) < 0)
|
|
||||||
goto gcr_cleanup;
|
|
||||||
|
|
||||||
retcode = git_checkout_head(git_reference_owner(ref), opts, stats);
|
retcode = git_checkout_head(git_reference_owner(ref), opts, stats);
|
||||||
|
|
||||||
gcr_cleanup:
|
|
||||||
git_reference_free(head);
|
git_reference_free(head);
|
||||||
return retcode;
|
return retcode;
|
||||||
}
|
}
|
||||||
|
@ -177,3 +177,8 @@ void test_checkout_checkout__open_flags(void)
|
|||||||
cl_git_pass(git_checkout_head(g_repo, &opts, NULL));
|
cl_git_pass(git_checkout_head(g_repo, &opts, NULL));
|
||||||
test_file_contents("./testrepo/new.txt", "hi\nmy new file\n");
|
test_file_contents("./testrepo/new.txt", "hi\nmy new file\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test_checkout_checkout__detached_head(void)
|
||||||
|
{
|
||||||
|
/* TODO: write this when git_checkout_commit is implemented. */
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user