Skip to content

Commit c339ff6

Browse files
avargitster
authored andcommitted
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 5fe7d82 (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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent df3458e commit c339ff6

File tree

3 files changed

+29
-33
lines changed

3 files changed

+29
-33
lines changed

refs.c

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,25 +1372,6 @@ const char *find_descendant_ref(const char *dirname,
13721372
return NULL;
13731373
}
13741374

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-
13941375
int refs_head_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data)
13951376
{
13961377
struct object_id oid;

refs/files-backend.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,6 +1363,35 @@ static int commit_ref_update(struct files_ref_store *refs,
13631363
const struct object_id *oid, const char *logmsg,
13641364
struct strbuf *err);
13651365

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+
13661395
static int files_copy_or_rename_ref(struct ref_store *ref_store,
13671396
const char *oldrefname, const char *newrefname,
13681397
const char *logmsg, int copy)

refs/refs-internal.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -228,20 +228,6 @@ const char *find_descendant_ref(const char *dirname,
228228
const struct string_list *extras,
229229
const struct string_list *skip);
230230

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-
245231
/* We allow "recursive" symbolic refs. Only within reason, though */
246232
#define SYMREF_MAXDEPTH 5
247233

0 commit comments

Comments
 (0)