summaryrefslogtreecommitdiff
path: root/src/refs.c
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2014-01-14 15:33:29 +0100
committerCarlos Martín Nieto <cmn@dwim.me>2014-02-05 12:07:56 +0100
commit5d96fe8828505db852671175d5895dfd275f3d06 (patch)
tree947f3d4f070248e067dcf3988b984ecfa325c15a /src/refs.c
parent9b148098e6802f9dd797471fc4f20cfc58a846b4 (diff)
downloadlibgit2-5d96fe8828505db852671175d5895dfd275f3d06.tar.gz
refs: changes from feedback
Change the name to _matching() intead of _if(), and force _set_target() to be a conditional update. If the user doesn't care about the old value, they should use git_reference_create().
Diffstat (limited to 'src/refs.c')
-rw-r--r--src/refs.c44
1 files changed, 17 insertions, 27 deletions
diff --git a/src/refs.c b/src/refs.c
index a5492cf91..007fdf353 100644
--- a/src/refs.c
+++ b/src/refs.c
@@ -407,19 +407,7 @@ static int log_signature(git_signature **out, git_repository *repo)
return 0;
}
-int git_reference_create(
- git_reference **ref_out,
- git_repository *repo,
- const char *name,
- const git_oid *id,
- int force,
- const git_signature *signature,
- const char *log_message)
-{
- return git_reference_create_if(ref_out, repo, name, id, force, signature, log_message, NULL);
-}
-
-int git_reference_create_if(
+int git_reference_create_matching(
git_reference **ref_out,
git_repository *repo,
const char *name,
@@ -428,6 +416,7 @@ int git_reference_create_if(
const git_signature *signature,
const char *log_message,
const git_oid *old_id)
+
{
int error;
git_signature *who = NULL;
@@ -448,6 +437,18 @@ int git_reference_create_if(
return error;
}
+int git_reference_create(
+ git_reference **ref_out,
+ git_repository *repo,
+ const char *name,
+ const git_oid *id,
+ int force,
+ const git_signature *signature,
+ const char *log_message)
+{
+ return git_reference_create_matching(ref_out, repo, name, id, force, signature, log_message, NULL);
+}
+
int git_reference_symbolic_create(
git_reference **ref_out,
git_repository *repo,
@@ -485,13 +486,12 @@ static int ensure_is_an_updatable_direct_reference(git_reference *ref)
return -1;
}
-int git_reference_set_target_if(
+int git_reference_set_target(
git_reference **out,
git_reference *ref,
const git_oid *id,
const git_signature *signature,
- const char *log_message,
- const git_oid *old_id)
+ const char *log_message)
{
int error;
git_repository *repo;
@@ -503,7 +503,7 @@ int git_reference_set_target_if(
if ((error = ensure_is_an_updatable_direct_reference(ref)) < 0)
return error;
- return git_reference_create_if(out, repo, ref->name, id, 1, signature, log_message, old_id);
+ return git_reference_create_matching(out, repo, ref->name, id, 1, signature, log_message, &ref->target.oid);
}
static int ensure_is_an_updatable_symbolic_reference(git_reference *ref)
@@ -515,16 +515,6 @@ static int ensure_is_an_updatable_symbolic_reference(git_reference *ref)
return -1;
}
-int git_reference_set_target(
- git_reference **out,
- git_reference *ref,
- const git_oid *id,
- const git_signature *signature,
- const char *log_message)
-{
- return git_reference_set_target_if(out, ref, id, signature, log_message, NULL);
-}
-
int git_reference_symbolic_set_target(
git_reference **out,
git_reference *ref,