vendor/libgit2/src/clone.c in rugged-0.22.2 vs vendor/libgit2/src/clone.c in rugged-0.23.0b1
- old
+ new
@@ -22,31 +22,34 @@
#include "refs.h"
#include "path.h"
#include "repository.h"
#include "odb.h"
-static int clone_local_into(git_repository *repo, git_remote *remote, const git_checkout_options *co_opts, const char *branch, int link, const git_signature *signature);
+static int clone_local_into(git_repository *repo, git_remote *remote, const git_checkout_options *co_opts, const char *branch, int link);
static int create_branch(
git_reference **branch,
git_repository *repo,
const git_oid *target,
const char *name,
- const git_signature *signature,
const char *log_message)
{
git_commit *head_obj = NULL;
git_reference *branch_ref = NULL;
+ git_buf refname = GIT_BUF_INIT;
int error;
/* Find the target commit */
if ((error = git_commit_lookup(&head_obj, repo, target)) < 0)
return error;
/* Create the new branch */
- error = git_branch_create(&branch_ref, repo, name, head_obj, 0, signature, log_message);
+ if ((error = git_buf_printf(&refname, GIT_REFS_HEADS_DIR "%s", name)) < 0)
+ return error;
+ error = git_reference_create(&branch_ref, repo, git_buf_cstr(&refname), target, 0, log_message);
+ git_buf_free(&refname);
git_commit_free(head_obj);
if (!error)
*branch = branch_ref;
else
@@ -91,16 +94,15 @@
static int create_tracking_branch(
git_reference **branch,
git_repository *repo,
const git_oid *target,
const char *branch_name,
- const git_signature *signature,
const char *log_message)
{
int error;
- if ((error = create_branch(branch, repo, target, branch_name, signature, log_message)) < 0)
+ if ((error = create_branch(branch, repo, target, branch_name, log_message)) < 0)
return error;
return setup_tracking_config(
repo,
branch_name,
@@ -110,26 +112,24 @@
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);
+ reflog_message);
if (!error)
error = git_repository_set_head(
- repo, git_reference_name(tracking_branch),
- signature, reflog_message);
+ repo, git_reference_name(tracking_branch));
git_reference_free(tracking_branch);
/* if it already existed, then the user's refspec created it for us, ignore it' */
if (error == GIT_EEXISTS)
@@ -139,11 +139,10 @@
}
static int update_head_to_remote(
git_repository *repo,
git_remote *remote,
- const git_signature *signature,
const char *reflog_message)
{
int error = 0;
size_t refs_len;
git_refspec *refspec;
@@ -167,11 +166,11 @@
remote_head_id = &remote_head->oid;
error = git_remote_default_branch(&branch, remote);
if (error == GIT_ENOTFOUND) {
error = git_repository_set_head_detached(
- repo, remote_head_id, signature, reflog_message);
+ repo, remote_head_id);
goto cleanup;
}
refspec = git_remote__matching_refspec(remote, git_buf_cstr(&branch));
@@ -190,11 +189,11 @@
error = update_head_to_new_branch(
repo,
remote_head_id,
git_buf_cstr(&branch),
- signature, reflog_message);
+ reflog_message);
cleanup:
git_buf_free(&remote_master_name);
git_buf_free(&branch);
@@ -203,11 +202,10 @@
static int update_head_to_branch(
git_repository *repo,
const char *remote_name,
const char *branch,
- const git_signature *signature,
const char *reflog_message)
{
int retcode;
git_buf remote_branch_name = GIT_BUF_INIT;
git_reference* remote_ref = NULL;
@@ -220,11 +218,11 @@
if ((retcode = git_reference_lookup(&remote_ref, repo, git_buf_cstr(&remote_branch_name))) < 0)
goto cleanup;
retcode = update_head_to_new_branch(repo, git_reference_target(remote_ref), branch,
- signature, reflog_message);
+ reflog_message);
cleanup:
git_reference_free(remote_ref);
git_buf_free(&remote_branch_name);
return retcode;
@@ -311,28 +309,28 @@
return false;
return !git_repository_head_unborn(repo);
}
-static int checkout_branch(git_repository *repo, git_remote *remote, const git_checkout_options *co_opts, const char *branch, const git_signature *signature, const char *reflog_message)
+static int checkout_branch(git_repository *repo, git_remote *remote, const git_checkout_options *co_opts, const char *branch, const char *reflog_message)
{
int error;
if (branch)
error = update_head_to_branch(repo, git_remote_name(remote), branch,
- signature, reflog_message);
+ reflog_message);
/* Point HEAD to the same ref as the remote's head */
else
- error = update_head_to_remote(repo, remote, signature, reflog_message);
+ error = update_head_to_remote(repo, remote, reflog_message);
if (!error && should_checkout(repo, git_repository_is_bare(repo), co_opts))
error = git_checkout_head(repo, co_opts);
return error;
}
-static int clone_into(git_repository *repo, git_remote *_remote, const git_checkout_options *co_opts, const char *branch, const git_signature *signature)
+static int clone_into(git_repository *repo, git_remote *_remote, const git_checkout_options *co_opts, const char *branch)
{
int error;
git_buf reflog_message = GIT_BUF_INIT;
git_remote *remote;
const git_remote_callbacks *callbacks;
@@ -356,14 +354,14 @@
goto cleanup;
git_remote_set_update_fetchhead(remote, 0);
git_buf_printf(&reflog_message, "clone: from %s", git_remote_url(remote));
- if ((error = git_remote_fetch(remote, NULL, signature, git_buf_cstr(&reflog_message))) != 0)
+ if ((error = git_remote_fetch(remote, NULL, git_buf_cstr(&reflog_message))) != 0)
goto cleanup;
- error = checkout_branch(repo, remote, co_opts, branch, signature, git_buf_cstr(&reflog_message));
+ error = checkout_branch(repo, remote, co_opts, branch, git_buf_cstr(&reflog_message));
cleanup:
git_remote_free(remote);
git_buf_free(&reflog_message);
@@ -440,15 +438,15 @@
int link = options.local != GIT_CLONE_LOCAL_NO_LINKS;
if (clone_local == 1)
error = clone_local_into(
repo, origin, &options.checkout_opts,
- options.checkout_branch, link, options.signature);
+ options.checkout_branch, link);
else if (clone_local == 0)
error = clone_into(
repo, origin, &options.checkout_opts,
- options.checkout_branch, options.signature);
+ options.checkout_branch);
else
error = -1;
git_remote_free(origin);
}
@@ -506,11 +504,11 @@
return st_src.st_dev == st_dst.st_dev;
#endif
}
-static int clone_local_into(git_repository *repo, git_remote *remote, const git_checkout_options *co_opts, const char *branch, int link, const git_signature *signature)
+static int clone_local_into(git_repository *repo, git_remote *remote, const git_checkout_options *co_opts, const char *branch, int link)
{
int error, flags;
git_repository *src;
git_buf src_odb = GIT_BUF_INIT, dst_odb = GIT_BUF_INIT, src_path = GIT_BUF_INIT;
git_buf reflog_message = GIT_BUF_INIT;
@@ -551,13 +549,13 @@
flags, GIT_OBJECT_DIR_MODE)) < 0)
goto cleanup;
git_buf_printf(&reflog_message, "clone: from %s", git_remote_url(remote));
- if ((error = git_remote_fetch(remote, NULL, signature, git_buf_cstr(&reflog_message))) != 0)
+ if ((error = git_remote_fetch(remote, NULL, git_buf_cstr(&reflog_message))) != 0)
goto cleanup;
- error = checkout_branch(repo, remote, co_opts, branch, signature, git_buf_cstr(&reflog_message));
+ error = checkout_branch(repo, remote, co_opts, branch, git_buf_cstr(&reflog_message));
cleanup:
git_buf_free(&reflog_message);
git_buf_free(&src_path);
git_buf_free(&src_odb);