summaryrefslogtreecommitdiff
path: root/src/clone.c
diff options
context:
space:
mode:
authorBen Straub <bs@github.com>2014-01-27 14:40:31 -0800
committerBen Straub <bs@github.com>2014-01-30 15:52:13 -0800
commit1cc974ab625c2fa0794130eb97ca88c449fc1a06 (patch)
tree325c27052bbae86612d278ddacab9fc5982e131e /src/clone.c
parentb31ebfbc666202fb576f7eb406d7a699134da09d (diff)
downloadlibgit2-1cc974ab625c2fa0794130eb97ca88c449fc1a06.tar.gz
Augment clone API with reflog parameters
Diffstat (limited to 'src/clone.c')
-rw-r--r--src/clone.c36
1 files changed, 23 insertions, 13 deletions
diff --git a/src/clone.c b/src/clone.c
index 288e9d2c8..97d25bdcd 100644
--- a/src/clone.c
+++ b/src/clone.c
@@ -27,7 +27,9 @@ static int create_branch(
git_reference **branch,
git_repository *repo,
const git_oid *target,
- const char *name)
+ const char *name,
+ const git_signature *signature,
+ const char *log_message)
{
git_commit *head_obj = NULL;
git_reference *branch_ref = NULL;
@@ -38,7 +40,7 @@ static int create_branch(
return error;
/* Create the new branch */
- error = git_branch_create(&branch_ref, repo, name, head_obj, 0, NULL, NULL);
+ error = git_branch_create(&branch_ref, repo, name, head_obj, 0, signature, log_message);
git_commit_free(head_obj);
@@ -87,11 +89,13 @@ static int create_tracking_branch(
git_reference **branch,
git_repository *repo,
const git_oid *target,
- const char *branch_name)
+ const char *branch_name,
+ const git_signature *signature,
+ const char *log_message)
{
int error;
- if ((error = create_branch(branch, repo, target, branch_name)) < 0)
+ if ((error = create_branch(branch, repo, target, branch_name, signature, log_message)) < 0)
return error;
return setup_tracking_config(
@@ -153,15 +157,17 @@ 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 = create_tracking_branch(&tracking_branch, repo, target, name);
+ int 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),
- NULL, reflog_message);
+ signature, reflog_message);
git_reference_free(tracking_branch);
@@ -171,6 +177,7 @@ static int update_head_to_new_branch(
static int update_head_to_remote(
git_repository *repo,
git_remote *remote,
+ const git_signature *signature,
const char *reflog_message)
{
int error = 0;
@@ -221,7 +228,7 @@ static int update_head_to_remote(
repo,
&head_info.remote_head_oid,
git_buf_cstr(&head_info.branchname),
- reflog_message);
+ signature, reflog_message);
goto cleanup;
}
@@ -236,7 +243,7 @@ static int update_head_to_remote(
repo,
&head_info.remote_head_oid,
git_buf_cstr(&head_info.branchname),
- reflog_message);
+ signature, reflog_message);
} else {
error = git_repository_set_head_detached(
repo, &head_info.remote_head_oid, NULL, reflog_message);
@@ -252,6 +259,7 @@ 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;
@@ -267,7 +275,8 @@ static int update_head_to_branch(
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, reflog_message);
+ retcode = update_head_to_new_branch(repo, git_reference_target(remote_ref), branch,
+ signature, reflog_message);
cleanup:
git_reference_free(remote_ref);
@@ -327,7 +336,7 @@ static bool should_checkout(
return !git_repository_head_unborn(repo);
}
-int git_clone_into(git_repository *repo, git_remote *remote, const git_checkout_opts *co_opts, const char *branch)
+int git_clone_into(git_repository *repo, git_remote *remote, const git_checkout_opts *co_opts, const char *branch, const git_signature *signature)
{
int error = 0, old_fetchhead;
git_strarray refspecs;
@@ -355,10 +364,11 @@ int git_clone_into(git_repository *repo, git_remote *remote, const git_checkout_
goto cleanup;
if (branch)
- error = update_head_to_branch(repo, git_remote_name(remote), branch, git_buf_cstr(&reflog_message));
+ error = update_head_to_branch(repo, git_remote_name(remote), branch,
+ signature, git_buf_cstr(&reflog_message));
/* Point HEAD to the same ref as the remote's head */
else
- error = update_head_to_remote(repo, remote, git_buf_cstr(&reflog_message));
+ error = update_head_to_remote(repo, remote, signature, git_buf_cstr(&reflog_message));
if (!error && should_checkout(repo, git_repository_is_bare(repo), co_opts))
error = git_checkout_head(repo, co_opts);
@@ -414,7 +424,7 @@ int git_clone(
if (!(error = create_and_configure_origin(&origin, repo, url, &options))) {
error = git_clone_into(
- repo, origin, &options.checkout_opts, options.checkout_branch);
+ repo, origin, &options.checkout_opts, options.checkout_branch, options.signature);
git_remote_free(origin);
}