]> git.ipfire.org Git - thirdparty/git.git/commitdiff
refs API: make refs_rename_ref_available() static
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Sat, 16 Oct 2021 09:39:11 +0000 (11:39 +0200)
committerJunio C Hamano <gitster@pobox.com>
Sat, 16 Oct 2021 18:17:02 +0000 (11:17 -0700)
Move the refs_rename_ref_available() function into
"refs/files-backend.c". It is file-backend specific.

This function was added in 5fe7d825da8 (refs.c: pass a list of names
to skip to is_refname_available, 2014-05-01) as rename_ref_available()
and was only ever used in this one file-backend specific codepath. So
let's move it there.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs.c
refs/files-backend.c
refs/refs-internal.h

diff --git a/refs.c b/refs.c
index bb09993c2f96512602b033c08e4fc540650fe881..44ddbb14f1d1dfd1079524bbefaa43512d448c96 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -1372,25 +1372,6 @@ const char *find_descendant_ref(const char *dirname,
        return NULL;
 }
 
-int refs_rename_ref_available(struct ref_store *refs,
-                             const char *old_refname,
-                             const char *new_refname)
-{
-       struct string_list skip = STRING_LIST_INIT_NODUP;
-       struct strbuf err = STRBUF_INIT;
-       int ok;
-
-       string_list_insert(&skip, old_refname);
-       ok = !refs_verify_refname_available(refs, new_refname,
-                                           NULL, &skip, &err);
-       if (!ok)
-               error("%s", err.buf);
-
-       string_list_clear(&skip, 0);
-       strbuf_release(&err);
-       return ok;
-}
-
 int refs_head_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data)
 {
        struct object_id oid;
index c73ffd1ca339cd40182c7e37eefc84075f0ba59f..0af6ee44552780172b6c4c215b0f780b2b0c5581 100644 (file)
@@ -1363,6 +1363,35 @@ static int commit_ref_update(struct files_ref_store *refs,
                             const struct object_id *oid, const char *logmsg,
                             struct strbuf *err);
 
+/*
+ * Check whether an attempt to rename old_refname to new_refname would
+ * cause a D/F conflict with any existing reference (other than
+ * possibly old_refname). If there would be a conflict, emit an error
+ * message and return false; otherwise, return true.
+ *
+ * Note that this function is not safe against all races with other
+ * processes (though rename_ref() catches some races that might get by
+ * this check).
+ */
+static int refs_rename_ref_available(struct ref_store *refs,
+                             const char *old_refname,
+                             const char *new_refname)
+{
+       struct string_list skip = STRING_LIST_INIT_NODUP;
+       struct strbuf err = STRBUF_INIT;
+       int ok;
+
+       string_list_insert(&skip, old_refname);
+       ok = !refs_verify_refname_available(refs, new_refname,
+                                           NULL, &skip, &err);
+       if (!ok)
+               error("%s", err.buf);
+
+       string_list_clear(&skip, 0);
+       strbuf_release(&err);
+       return ok;
+}
+
 static int files_copy_or_rename_ref(struct ref_store *ref_store,
                            const char *oldrefname, const char *newrefname,
                            const char *logmsg, int copy)
index 121b8fdad08b7ae84e85c3ac9026533f2e3bddb6..2ecd3dea9fb63e0260b24bd7b9f19176e980165f 100644 (file)
@@ -228,20 +228,6 @@ const char *find_descendant_ref(const char *dirname,
                                const struct string_list *extras,
                                const struct string_list *skip);
 
-/*
- * Check whether an attempt to rename old_refname to new_refname would
- * cause a D/F conflict with any existing reference (other than
- * possibly old_refname). If there would be a conflict, emit an error
- * message and return false; otherwise, return true.
- *
- * Note that this function is not safe against all races with other
- * processes (though rename_ref() catches some races that might get by
- * this check).
- */
-int refs_rename_ref_available(struct ref_store *refs,
-                             const char *old_refname,
-                             const char *new_refname);
-
 /* We allow "recursive" symbolic refs. Only within reason, though */
 #define SYMREF_MAXDEPTH 5