Signed-off-by: David Turner <dturner@xxxxxxxxxxxxxxxx> --- refs.c | 5 +++++ refs/files-backend.c | 4 +++- refs/refs-internal.h | 8 ++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/refs.c b/refs.c index e222d02..f5754f2 100644 --- a/refs.c +++ b/refs.c @@ -1303,3 +1303,8 @@ int delete_refs(struct string_list *refnames) { return the_refs_backend->delete_refs(refnames); } + +int rename_ref(const char *oldref, const char *newref, const char *logmsg) +{ + return the_refs_backend->rename_ref(oldref, newref, logmsg); +} diff --git a/refs/files-backend.c b/refs/files-backend.c index 5377e3f..d38acd6 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -2424,7 +2424,8 @@ static int commit_ref_update(struct ref_lock *lock, const unsigned char *sha1, const char *logmsg, int flags, struct strbuf *err); -int rename_ref(const char *oldrefname, const char *newrefname, const char *logmsg) +static int files_rename_ref(const char *oldrefname, const char *newrefname, + const char *logmsg) { unsigned char sha1[20], orig_sha1[20]; int flag = 0, logmoved = 0; @@ -3514,6 +3515,7 @@ struct ref_storage_be refs_be_files = { files_peel_ref, files_create_symref, files_delete_refs, + files_rename_ref, files_resolve_ref_unsafe, files_verify_refname_available, diff --git a/refs/refs-internal.h b/refs/refs-internal.h index 94227cf..10a4e4d 100644 --- a/refs/refs-internal.h +++ b/refs/refs-internal.h @@ -195,6 +195,11 @@ const char *find_descendant_ref(const char *dirname, const struct string_list *extras, const struct string_list *skip); +/* + * Check if the new name does not conflict with any existing refs + * (other than possibly the old ref). Return 0 if the ref can be + * renamed to the new name. + */ int rename_ref_available(const char *oldname, const char *newname); /* Include broken references in a do_for_each_ref*() iteration: */ @@ -244,6 +249,8 @@ typedef int create_symref_fn(const char *ref_target, const char *refs_heads_master, const char *logmsg); typedef int delete_refs_fn(struct string_list *refnames); +typedef int rename_ref_fn(const char *oldref, const char *newref, + const char *logmsg); /* resolution methods */ typedef const char *resolve_ref_unsafe_fn(const char *ref, @@ -275,6 +282,7 @@ struct ref_storage_be { peel_ref_fn *peel_ref; create_symref_fn *create_symref; delete_refs_fn *delete_refs; + rename_ref_fn *rename_ref; resolve_ref_unsafe_fn *resolve_ref_unsafe; verify_refname_available_fn *verify_refname_available; -- 2.4.2.767.g62658d5-twtrsrc -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html