blob: 9dd8a344c34dd7ae078f8226abf044219d5f3a3c [file] [log] [blame]
Michael Haggerty67be7c52017-06-23 09:01:37 +02001#ifndef REFS_PACKED_BACKEND_H
2#define REFS_PACKED_BACKEND_H
3
Jonathan Tan34224e12021-10-08 14:08:14 -07004struct repository;
Ramsay Jones611023f2018-09-19 01:11:44 +01005struct ref_transaction;
6
Michael Haggerty2775d872017-09-08 15:51:45 +02007/*
8 * Support for storing references in a `packed-refs` file.
9 *
10 * Note that this backend doesn't check for D/F conflicts, because it
11 * doesn't care about them. But usually it should be wrapped in a
12 * `files_ref_store` that prevents D/F conflicts from being created,
13 * even among packed refs.
14 */
15
Jonathan Tan34224e12021-10-08 14:08:14 -070016struct ref_store *packed_ref_store_create(struct repository *repo,
Han-Wen Nienhuys99f0d972021-12-22 18:11:52 +000017 const char *gitdir,
Michael Haggertye0cc8ac2017-06-23 09:01:38 +020018 unsigned int store_flags);
Michael Haggerty67be7c52017-06-23 09:01:37 +020019
20/*
21 * Lock the packed-refs file for writing. Flags is passed to
Michael Haggertyc8bed832017-06-23 09:01:42 +020022 * hold_lock_file_for_update(). Return 0 on success. On errors, write
23 * an error message to `err` and return a nonzero value.
Michael Haggerty67be7c52017-06-23 09:01:37 +020024 */
Michael Haggertyc8bed832017-06-23 09:01:42 +020025int packed_refs_lock(struct ref_store *ref_store, int flags, struct strbuf *err);
Michael Haggerty67be7c52017-06-23 09:01:37 +020026
Michael Haggerty49aebcf2017-06-23 09:01:43 +020027void packed_refs_unlock(struct ref_store *ref_store);
28int packed_refs_is_locked(struct ref_store *ref_store);
29
Michael Haggerty7c6bd252017-10-28 11:16:02 +020030/*
31 * Return true if `transaction` really needs to be carried out against
32 * the specified packed_ref_store, or false if it can be skipped
33 * (i.e., because it is an obvious NOOP). `ref_store` must be locked
34 * before calling this function.
35 */
36int is_packed_transaction_needed(struct ref_store *ref_store,
37 struct ref_transaction *transaction);
38
Michael Haggerty67be7c52017-06-23 09:01:37 +020039#endif /* REFS_PACKED_BACKEND_H */