verify_refname_available(): rename function

Rename verify_refname_available() to verify_refname_available_dir() to
make the old name available for a more general purpose.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
Signed-off-by: David Turner <dturner@twopensource.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Jeff King <peff@peff.net>
This commit is contained in:
Ronnie Sahlberg 2015-11-10 12:42:31 +01:00 коммит произвёл Jeff King
Родитель f34be46e47
Коммит 7003b3ce21
1 изменённых файлов: 22 добавлений и 22 удалений

44
refs.c
Просмотреть файл

@ -279,7 +279,7 @@ struct ref_dir {
* presence of an empty subdirectory does not block the creation of a
* similarly-named reference. (The fact that reference names with the
* same leading components can conflict *with each other* is a
* separate issue that is regulated by verify_refname_available().)
* separate issue that is regulated by verify_refname_available_dir().)
*
* Please note that the name field contains the fully-qualified
* reference (or subdirectory) name. Space could be saved by only
@ -911,11 +911,11 @@ static int nonmatching_ref_fn(struct ref_entry *entry, void *vdata)
*
* extras and skip must be sorted.
*/
static int verify_refname_available(const char *refname,
const struct string_list *extras,
const struct string_list *skip,
struct ref_dir *dir,
struct strbuf *err)
static int verify_refname_available_dir(const char *refname,
const struct string_list *extras,
const struct string_list *skip,
struct ref_dir *dir,
struct strbuf *err)
{
const char *slash;
int pos;
@ -2465,8 +2465,8 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname,
strbuf_git_path(&orig_ref_file, "%s", orig_refname);
if (remove_empty_directories(&orig_ref_file)) {
last_errno = errno;
if (!verify_refname_available(orig_refname, extras, skip,
get_loose_refs(&ref_cache), err))
if (!verify_refname_available_dir(orig_refname, extras, skip,
get_loose_refs(&ref_cache), err))
strbuf_addf(err, "there are still refs under '%s'",
orig_refname);
goto error_return;
@ -2479,8 +2479,8 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname,
if (!refname) {
last_errno = errno;
if (last_errno != ENOTDIR ||
!verify_refname_available(orig_refname, extras, skip,
get_loose_refs(&ref_cache), err))
!verify_refname_available_dir(orig_refname, extras, skip,
get_loose_refs(&ref_cache), err))
strbuf_addf(err, "unable to resolve reference %s: %s",
orig_refname, strerror(last_errno));
@ -2493,8 +2493,8 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname,
* our refname.
*/
if (is_null_oid(&lock->old_oid) &&
verify_refname_available(refname, extras, skip,
get_packed_refs(&ref_cache), err)) {
verify_refname_available_dir(refname, extras, skip,
get_packed_refs(&ref_cache), err)) {
last_errno = ENOTDIR;
goto error_return;
}
@ -3127,10 +3127,10 @@ static int rename_ref_available(const char *oldname, const char *newname)
int ret;
string_list_insert(&skip, oldname);
ret = !verify_refname_available(newname, NULL, &skip,
get_packed_refs(&ref_cache), &err)
&& !verify_refname_available(newname, NULL, &skip,
get_loose_refs(&ref_cache), &err);
ret = !verify_refname_available_dir(newname, NULL, &skip,
get_packed_refs(&ref_cache), &err)
&& !verify_refname_available_dir(newname, NULL, &skip,
get_loose_refs(&ref_cache), &err);
if (!ret)
error("%s", err.buf);
@ -4376,12 +4376,12 @@ int initial_ref_transaction_commit(struct ref_transaction *transaction,
if ((update->flags & REF_HAVE_OLD) &&
!is_null_sha1(update->old_sha1))
die("BUG: initial ref transaction with old_sha1 set");
if (verify_refname_available(update->refname,
&affected_refnames, NULL,
loose_refs, err) ||
verify_refname_available(update->refname,
&affected_refnames, NULL,
packed_refs, err)) {
if (verify_refname_available_dir(update->refname,
&affected_refnames, NULL,
loose_refs, err) ||
verify_refname_available_dir(update->refname,
&affected_refnames, NULL,
packed_refs, err)) {
ret = TRANSACTION_NAME_CONFLICT;
goto cleanup;
}