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