static int update_head_to_new_branch( git_repository *repo, const git_oid *target, const char *name, const git_signature *signature, const char *reflog_message) { git_reference *tracking_branch = NULL; int error; if (!git__prefixcmp(name, GIT_REFS_HEADS_DIR)) name += strlen(GIT_REFS_HEADS_DIR); error = create_tracking_branch(&tracking_branch, repo, target, name, signature, reflog_message); if (!error) error = git_repository_set_head( repo, git_reference_name(tracking_branch), signature, reflog_message); git_reference_free(tracking_branch); /* if it already existed, then the user's refspec created it for us, ignore it' */ if (error == GIT_EEXISTS) error = 0; return error; }
static int update_head_to_new_branch( git_repository *repo, const git_oid *target, const char *name) { git_reference *tracking_branch = NULL; int error; if ((error = create_tracking_branch( &tracking_branch, repo, target, name)) < 0) return error; error = git_repository_set_head(repo, git_reference_name(tracking_branch)); git_reference_free(tracking_branch); return error; }