Michael Haggerty | 67be7c5 | 2017-06-23 09:01:37 +0200 | [diff] [blame] | 1 | #ifndef REFS_PACKED_BACKEND_H |
| 2 | #define REFS_PACKED_BACKEND_H |
| 3 | |
Jonathan Tan | 34224e1 | 2021-10-08 14:08:14 -0700 | [diff] [blame] | 4 | struct repository; |
Ramsay Jones | 611023f | 2018-09-19 01:11:44 +0100 | [diff] [blame] | 5 | struct ref_transaction; |
| 6 | |
Michael Haggerty | 2775d87 | 2017-09-08 15:51:45 +0200 | [diff] [blame] | 7 | /* |
| 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 Tan | 34224e1 | 2021-10-08 14:08:14 -0700 | [diff] [blame] | 16 | struct ref_store *packed_ref_store_create(struct repository *repo, |
Han-Wen Nienhuys | 99f0d97 | 2021-12-22 18:11:52 +0000 | [diff] [blame] | 17 | const char *gitdir, |
Michael Haggerty | e0cc8ac | 2017-06-23 09:01:38 +0200 | [diff] [blame] | 18 | unsigned int store_flags); |
Michael Haggerty | 67be7c5 | 2017-06-23 09:01:37 +0200 | [diff] [blame] | 19 | |
| 20 | /* |
| 21 | * Lock the packed-refs file for writing. Flags is passed to |
Michael Haggerty | c8bed83 | 2017-06-23 09:01:42 +0200 | [diff] [blame] | 22 | * hold_lock_file_for_update(). Return 0 on success. On errors, write |
| 23 | * an error message to `err` and return a nonzero value. |
Michael Haggerty | 67be7c5 | 2017-06-23 09:01:37 +0200 | [diff] [blame] | 24 | */ |
Michael Haggerty | c8bed83 | 2017-06-23 09:01:42 +0200 | [diff] [blame] | 25 | int packed_refs_lock(struct ref_store *ref_store, int flags, struct strbuf *err); |
Michael Haggerty | 67be7c5 | 2017-06-23 09:01:37 +0200 | [diff] [blame] | 26 | |
Michael Haggerty | 49aebcf | 2017-06-23 09:01:43 +0200 | [diff] [blame] | 27 | void packed_refs_unlock(struct ref_store *ref_store); |
| 28 | int packed_refs_is_locked(struct ref_store *ref_store); |
| 29 | |
Michael Haggerty | 7c6bd25 | 2017-10-28 11:16:02 +0200 | [diff] [blame] | 30 | /* |
| 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 | */ |
| 36 | int is_packed_transaction_needed(struct ref_store *ref_store, |
| 37 | struct ref_transaction *transaction); |
| 38 | |
Michael Haggerty | 67be7c5 | 2017-06-23 09:01:37 +0200 | [diff] [blame] | 39 | #endif /* REFS_PACKED_BACKEND_H */ |