mirror of
https://git.proxmox.com/git/libgit2
synced 2025-06-19 22:44:42 +00:00
refs: properly report errors from update_wt_heads
This commit is contained in:
parent
0c28c72d13
commit
0f642f3168
22
src/refs.c
22
src/refs.c
@ -622,15 +622,25 @@ typedef struct {
|
||||
static int update_wt_heads(git_repository *repo, const char *path, void *payload)
|
||||
{
|
||||
rename_cb_data *data = (rename_cb_data *) payload;
|
||||
git_reference *head;
|
||||
git_reference *head = NULL;
|
||||
char *gitdir = NULL;
|
||||
int error = 0;
|
||||
int error;
|
||||
|
||||
if (git_reference__read_head(&head, repo, path) < 0 ||
|
||||
git_reference_type(head) != GIT_REF_SYMBOLIC ||
|
||||
git__strcmp(head->target.symbolic, data->old_name) != 0 ||
|
||||
(gitdir = git_path_dirname(path)) == NULL)
|
||||
if ((error = git_reference__read_head(&head, repo, path)) < 0) {
|
||||
giterr_set(GITERR_REFERENCE, "could not read HEAD when renaming references");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if ((gitdir = git_path_dirname(path)) == NULL) {
|
||||
error = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (git_reference_type(head) != GIT_REF_SYMBOLIC ||
|
||||
git__strcmp(head->target.symbolic, data->old_name) != 0) {
|
||||
error = 0;
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Update HEAD it was pointing to the reference being renamed */
|
||||
if ((error = git_repository_create_head(gitdir, data->new_name)) < 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user