aboutsummaryrefslogtreecommitdiffstats
path: root/refs.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2022-03-16 17:53:07 -0700
committerJunio C Hamano <gitster@pobox.com>2022-03-16 17:53:07 -0700
commit6969ac64bf1c7bc43e897d6bfe7d2450d37e9aa9 (patch)
tree282ec839d4f21b10780f3942460e2103a77b98ff /refs.c
parent47e0380289b4d60c6fc6a86935686233113aa001 (diff)
parent0a7b38707d5d5c8a7baeb88a85d6259cee4f4e4d (diff)
downloadgit-6969ac64bf1c7bc43e897d6bfe7d2450d37e9aa9.tar.gz
Merge branch 'ps/fetch-mirror-optim'
Various optimization for "git fetch". * ps/fetch-mirror-optim: refs/files-backend: optimize reading of symbolic refs remote: read symbolic refs via `refs_read_symbolic_ref()` refs: add ability for backends to special-case reading of symbolic refs fetch: avoid lookup of commits when not appending to FETCH_HEAD upload-pack: look up "want" lines via commit-graph
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/refs.c b/refs.c
index 1598fb13e2..0b79bdd7c3 100644
--- a/refs.c
+++ b/refs.c
@@ -1673,6 +1673,23 @@ int refs_read_raw_ref(struct ref_store *ref_store, const char *refname,
type, failure_errno);
}
+int refs_read_symbolic_ref(struct ref_store *ref_store, const char *refname,
+ struct strbuf *referent)
+{
+ struct object_id oid;
+ int ret, failure_errno = 0;
+ unsigned int type = 0;
+
+ if (ref_store->be->read_symbolic_ref)
+ return ref_store->be->read_symbolic_ref(ref_store, refname, referent);
+
+ ret = refs_read_raw_ref(ref_store, refname, &oid, referent, &type, &failure_errno);
+ if (ret || !(type & REF_ISSYMREF))
+ return -1;
+
+ return 0;
+}
+
const char *refs_resolve_ref_unsafe(struct ref_store *refs,
const char *refname,
int resolve_flags,