diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2014-02-05 10:19:17 +0100 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2014-02-05 12:07:57 +0100 |
commit | 878fb66f5765115eff34213cfc8dd04b8a56b2a5 (patch) | |
tree | 45bb77cd3d92c9cda9e6a773a77911deb2908c04 /src | |
parent | 911236619b5d774e33dd9f3de92a7c86c2befb26 (diff) | |
download | libgit2-878fb66f5765115eff34213cfc8dd04b8a56b2a5.tar.gz |
refs: bring conditional symbolic updates to the frontend
Bring the race detection goodness to symbolic references as well.
Diffstat (limited to 'src')
-rw-r--r-- | src/refs.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/refs.c b/src/refs.c index 888b5cb3c..864bfce59 100644 --- a/src/refs.c +++ b/src/refs.c @@ -450,14 +450,15 @@ int git_reference_create( return git_reference_create_matching(ref_out, repo, name, id, force, signature, log_message, NULL); } -int git_reference_symbolic_create( +int git_reference_symbolic_create_matching( git_reference **ref_out, git_repository *repo, const char *name, const char *target, int force, const git_signature *signature, - const char *log_message) + const char *log_message, + const char *old_target) { int error; git_signature *who = NULL; @@ -472,12 +473,24 @@ int git_reference_symbolic_create( } error = reference__create( - ref_out, repo, name, NULL, target, force, signature, log_message, NULL, NULL); + ref_out, repo, name, NULL, target, force, signature, log_message, NULL, old_target); git_signature_free(who); return error; } +int git_reference_symbolic_create( + git_reference **ref_out, + git_repository *repo, + const char *name, + const char *target, + int force, + const git_signature *signature, + const char *log_message) +{ + return git_reference_symbolic_create_matching(ref_out, repo, name, target, force, signature, log_message, NULL); +} + static int ensure_is_an_updatable_direct_reference(git_reference *ref) { if (ref->type == GIT_REF_OID) @@ -530,8 +543,8 @@ int git_reference_symbolic_set_target( if ((error = ensure_is_an_updatable_symbolic_reference(ref)) < 0) return error; - return git_reference_symbolic_create( - out, ref->db->repo, ref->name, target, 1, signature, log_message); + return git_reference_symbolic_create_matching( + out, ref->db->repo, ref->name, target, 1, signature, log_message, ref->target.symbolic); } static int reference__rename(git_reference **out, git_reference *ref, const char *new_name, int force, |