refs API: make refs_rename_ref_available() static
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>
Ævar Arnfjörð Bjarmason committed
Oct 16, 2021 at 11:39 UTC
c339ff690f5b5a9f27e27f4cb4d22023a0b7ebaf
3 files changed
+29
-33
refs.c
-19
@@ -1372,25 +1372,6 @@ const char *find_descendant_ref(const char *dirname,
1372
return NULL;
1373
}
1374
1375
-int refs_rename_ref_available(struct ref_store *refs,
1376
- const char *old_refname,
1377
- const char *new_refname)
1378
-{
1379
- struct string_list skip = STRING_LIST_INIT_NODUP;
1380
- struct strbuf err = STRBUF_INIT;
1381
- int ok;
1382
-
1383
- string_list_insert(&skip, old_refname);
1384
- ok = !refs_verify_refname_available(refs, new_refname,
1385
- NULL, &skip, &err);
1386
- if (!ok)
1387
- error("%s", err.buf);
1388
-
1389
- string_list_clear(&skip, 0);
1390
- strbuf_release(&err);
1391
- return ok;
1392
-}
1393
-
1375
int refs_head_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data)
1376
{
1377
struct object_id oid;
refs/files-backend.c
+29
@@ -1363,6 +1363,35 @@ static int commit_ref_update(struct files_ref_store *refs,
1363
const struct object_id *oid, const char *logmsg,
1364
struct strbuf *err);
1365
1366
+/*
1367
+ * Check whether an attempt to rename old_refname to new_refname would
1368
+ * cause a D/F conflict with any existing reference (other than
1369
+ * possibly old_refname). If there would be a conflict, emit an error
1370
+ * message and return false; otherwise, return true.
1371
+ *
1372
+ * Note that this function is not safe against all races with other
1373
+ * processes (though rename_ref() catches some races that might get by
1374
+ * this check).
1375
+ */
1376
+static int refs_rename_ref_available(struct ref_store *refs,
1377
+ const char *old_refname,
1378
+ const char *new_refname)
1379
+{
1380
+ struct string_list skip = STRING_LIST_INIT_NODUP;
1381
+ struct strbuf err = STRBUF_INIT;
1382
+ int ok;
1383
+
1384
+ string_list_insert(&skip, old_refname);
1385
+ ok = !refs_verify_refname_available(refs, new_refname,
1386
+ NULL, &skip, &err);
1387
+ if (!ok)
1388
+ error("%s", err.buf);
1389
+
1390
+ string_list_clear(&skip, 0);
1391
+ strbuf_release(&err);
1392
+ return ok;
1393
+}
1394
+
1395
static int files_copy_or_rename_ref(struct ref_store *ref_store,
1396
const char *oldrefname, const char *newrefname,
1397
const char *logmsg, int copy)
refs/refs-internal.h
-14
@@ -228,20 +228,6 @@ const char *find_descendant_ref(const char *dirname,
228
const struct string_list *extras,
229
const struct string_list *skip);
230
231
-/*
232
- * Check whether an attempt to rename old_refname to new_refname would
233
- * cause a D/F conflict with any existing reference (other than
234
- * possibly old_refname). If there would be a conflict, emit an error
235
- * message and return false; otherwise, return true.
236
- *
237
- * Note that this function is not safe against all races with other
238
- * processes (though rename_ref() catches some races that might get by
239
- * this check).
240
- */
241
-int refs_rename_ref_available(struct ref_store *refs,
242
- const char *old_refname,
243
- const char *new_refname);
244
-
231
/* We allow "recursive" symbolic refs. Only within reason, though */
232
#define SYMREF_MAXDEPTH 5
233