summaryrefslogtreecommitdiff
path: root/refs
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2017-03-26 02:42:34 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-04-14 10:53:25 (GMT)
commit7d2df051d05bc65a0a540ba080f07b421b4d99d7 (patch)
treea6624b0c18dabb0c59446e5a54f5cab553081be9 /refs
parent18d0002d6ddc191454b6b4a99cdac65fc7ff9ece (diff)
downloadgit-7d2df051d05bc65a0a540ba080f07b421b4d99d7.zip
git-7d2df051d05bc65a0a540ba080f07b421b4d99d7.tar.gz
git-7d2df051d05bc65a0a540ba080f07b421b4d99d7.tar.bz2
refs: add new ref-store api
This is not meant to cover all existing API. It adds enough to test ref stores with the new test program test-ref-store, coming soon and to be used by files-backend.c. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs')
-rw-r--r--refs/files-backend.c13
-rw-r--r--refs/refs-internal.h31
2 files changed, 10 insertions, 34 deletions
diff --git a/refs/files-backend.c b/refs/files-backend.c
index c90b472..f3ebdb2 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -1313,7 +1313,7 @@ static void read_loose_refs(const char *dirname, struct ref_dir *dir)
create_dir_entry(refs, refname.buf,
refname.len, 1));
} else {
- if (!resolve_ref_recursively(&refs->base,
+ if (!refs_resolve_ref_unsafe(&refs->base,
refname.buf,
RESOLVE_REF_READING,
sha1, &flag)) {
@@ -1622,7 +1622,8 @@ retry:
* another reference such as "refs/foo". There is no
* reason to expect this error to be transitory.
*/
- if (verify_refname_available(refname, extras, skip, err)) {
+ if (refs_verify_refname_available(&refs->base, refname,
+ extras, skip, err)) {
if (mustexist) {
/*
* To the user the relevant error is
@@ -2670,7 +2671,7 @@ static int files_rename_ref(struct ref_store *ref_store,
oldrefname);
goto out;
}
- if (!rename_ref_available(oldrefname, newrefname)) {
+ if (!refs_rename_ref_available(&refs->base, oldrefname, newrefname)) {
ret = 1;
goto out;
}
@@ -4054,9 +4055,9 @@ static int files_initial_transaction_commit(struct ref_store *ref_store,
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,
- err)) {
+ if (refs_verify_refname_available(&refs->base, update->refname,
+ &affected_refnames, NULL,
+ err)) {
ret = TRANSACTION_NAME_CONFLICT;
goto cleanup;
}
diff --git a/refs/refs-internal.h b/refs/refs-internal.h
index f20dde3..5f26208 100644
--- a/refs/refs-internal.h
+++ b/refs/refs-internal.h
@@ -112,28 +112,6 @@ enum peel_status {
enum peel_status peel_object(const unsigned char *name, unsigned char *sha1);
/*
- * Return 0 if a reference named refname could be created without
- * conflicting with the name of an existing reference. Otherwise,
- * return a negative value and write an explanation to err. If extras
- * is non-NULL, it is a list of additional refnames with which refname
- * is not allowed to conflict. If skip is non-NULL, ignore potential
- * conflicts with refs in skip (e.g., because they are scheduled for
- * deletion in the same operation). Behavior is undefined if the same
- * name is listed in both extras and skip.
- *
- * Two reference names conflict if one of them exactly matches the
- * leading components of the other; e.g., "foo/bar" conflicts with
- * both "foo" and with "foo/bar/baz" but not with "foo/bar" or
- * "foo/barbados".
- *
- * extras and skip must be sorted.
- */
-int verify_refname_available(const char *newname,
- const struct string_list *extras,
- const struct string_list *skip,
- struct strbuf *err);
-
-/*
* Copy the reflog message msg to buf, which has been allocated sufficiently
* large, while cleaning up the whitespaces. Especially, convert LF to space,
* because reflog file is one line per entry.
@@ -252,7 +230,9 @@ const char *find_descendant_ref(const char *dirname,
* processes (though rename_ref() catches some races that might get by
* this check).
*/
-int rename_ref_available(const char *old_refname, const char *new_refname);
+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
@@ -646,9 +626,4 @@ struct ref_store {
void base_ref_store_init(struct ref_store *refs,
const struct ref_storage_be *be);
-const char *resolve_ref_recursively(struct ref_store *refs,
- const char *refname,
- int resolve_flags,
- unsigned char *sha1, int *flags);
-
#endif /* REFS_REFS_INTERNAL_H */