summaryrefslogtreecommitdiff
path: root/src/clone.c
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2015-01-07 12:23:05 +0000
committerCarlos Martín Nieto <cmn@dwim.me>2015-03-03 14:40:50 +0100
commit659cf2029f322ea876d663d85783b48945227e8f (patch)
tree435e9185c38d96656e21db83fc736b5294499b10 /src/clone.c
parent99b68a2aecfaa24f252f265d61b230b8e2576dd2 (diff)
downloadlibgit2-659cf2029f322ea876d663d85783b48945227e8f.tar.gz
Remove the signature from ref-modifying functions
The signature for the reflog is not something which changes dynamically. Almost all uses will be NULL, since we want for the repository's default identity to be used, making it noise. In order to allow for changing the identity, we instead provide git_repository_set_ident() and git_repository_ident() which allow a user to override the choice of signature.
Diffstat (limited to 'src/clone.c')
-rw-r--r--src/clone.c43
1 files changed, 19 insertions, 24 deletions
diff --git a/src/clone.c b/src/clone.c
index f18f07611..f7ae17c57 100644
--- a/src/clone.c
+++ b/src/clone.c
@@ -24,14 +24,13 @@
#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;
@@ -43,7 +42,7 @@ static int create_branch(
return error;
/* Create the new branch */
- error = git_branch_create(&branch_ref, repo, name, head_obj, 0, signature, log_message);
+ error = git_branch_create(&branch_ref, repo, name, head_obj, 0, log_message);
git_commit_free(head_obj);
@@ -93,12 +92,11 @@ static int create_tracking_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(
@@ -112,7 +110,6 @@ 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;
@@ -122,12 +119,12 @@ static int update_head_to_new_branch(
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);
+ reflog_message);
git_reference_free(tracking_branch);
@@ -141,7 +138,6 @@ 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;
@@ -169,7 +165,7 @@ static int update_head_to_remote(
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, reflog_message);
goto cleanup;
}
@@ -192,7 +188,7 @@ static int update_head_to_remote(
repo,
remote_head_id,
git_buf_cstr(&branch),
- signature, reflog_message);
+ reflog_message);
cleanup:
git_buf_free(&remote_master_name);
@@ -205,7 +201,6 @@ 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;
@@ -222,7 +217,7 @@ static int update_head_to_branch(
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);
@@ -313,16 +308,16 @@ static bool should_checkout(
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);
@@ -330,7 +325,7 @@ static int checkout_branch(git_repository *repo, git_remote *remote, const git_c
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;
@@ -358,10 +353,10 @@ static int clone_into(git_repository *repo, git_remote *_remote, const git_check
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);
@@ -442,11 +437,11 @@ int git_clone(
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;
@@ -508,7 +503,7 @@ static bool can_link(const char *src, const char *dst, int link)
#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;
@@ -553,10 +548,10 @@ static int clone_local_into(git_repository *repo, git_remote *remote, const git_
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);