Raw
1 #ifndef REFS_REFS_INTERNAL_H
2 #define REFS_REFS_INTERNAL_H
3
4 #include "refs.h"
5 #include "iterator.h"
6 #include "string-list.h"
7
8 struct fsck_options;
9 struct ref_transaction;
10
11 /*
12 * Data structures and functions for the internal use of the refs
13 * module. Code outside of the refs module should use only the public
14 * functions defined in "refs.h", and should *not* include this file.
15 */
16
17 /*
18 * The following flags can appear in `ref_update::flags`. Their
19 * numerical values must not conflict with those of REF_NO_DEREF and
20 * REF_FORCE_CREATE_REFLOG, which are also stored in
21 * `ref_update::flags`.
22 */
23
24 /*
25 * The reference should be updated to new_oid.
26 */
27 #define REF_HAVE_NEW (1 << 2)
28
29 /*
30 * The current reference's value should be checked to make sure that
31 * it agrees with old_oid.
32 */
33 #define REF_HAVE_OLD (1 << 3)
34
35 /*
36 * Used as a flag in ref_update::flags when we want to log a ref
37 * update but not actually perform it. This is used when a symbolic
38 * ref update is split up.
39 */
40 #define REF_LOG_ONLY (1 << 7)
41
42 /*
43 * The reference contains a peeled object ID. This is used when the
44 * new_oid is pointing to a tag object and the reference backend
45 * wants to also store the peeled value for optimized retrieval.
46 */
47 #define REF_HAVE_PEELED (1 << 15)
48
49 /*
50 * Return the length of time to retry acquiring a loose reference lock
51 * before giving up, in milliseconds:
52 */
53 long get_files_ref_lock_timeout_ms(struct repository *repo);
54
55 /*
56 * Return true iff refname is minimally safe. "Safe" here means that
57 * deleting a loose reference by this name will not do any damage, for
58 * example by causing a file that is not a reference to be deleted.
59 * This function does not check that the reference name is legal; for
60 * that, use check_refname_format().
61 *
62 * A refname that starts with "refs/" is considered safe iff it
63 * doesn't contain any "." or ".." components or consecutive '/'
64 * characters, end with '/', or (on Windows) contain any '\'
65 * characters. Names that do not start with "refs/" are considered
66 * safe iff they consist entirely of upper case characters and '_'
67 * (like "HEAD" and "MERGE_HEAD" but not "config" or "FOO/BAR").
68 */
69 int refname_is_safe(const char *refname);
70
71 /*
72 * Helper function: return true if refname, which has the specified
73 * oid and flags, can be resolved to an object in the database. If the
74 * referred-to object does not exist, emit a warning and return false.
75 */
76 int ref_resolves_to_object(const char *refname,
77 struct repository *repo,
78 const struct object_id *oid,
79 unsigned int flags);
80
81 /**
82 * Information needed for a single ref update. Set new_oid to the new
83 * value or to null_oid to delete the ref. To check the old value
84 * while the ref is locked, set (flags & REF_HAVE_OLD) and set old_oid
85 * to the old value, or to null_oid to ensure the ref does not exist
86 * before update.
87 */
88 struct ref_update {
89 /*
90 * If (flags & REF_HAVE_NEW), set the reference to this value
91 * (or delete it, if `new_oid` is `null_oid`).
92 */
93 struct object_id new_oid;
94
95 /*
96 * If (flags & REF_HAVE_OLD), check that the reference
97 * previously had this value (or didn't previously exist, if
98 * `old_oid` is `null_oid`).
99 */
100 struct object_id old_oid;
101
102 /*
103 * If the new_oid points to a tag object, set this to the peeled
104 * object ID for optimized retrieval without needed to hit the odb.
105 */
106 struct object_id peeled;
107
108 /*
109 * If set, point the reference to this value. This can also be
110 * used to convert regular references to become symbolic refs.
111 * Cannot be set together with `new_oid`.
112 */
113 const char *new_target;
114
115 /*
116 * If set, check that the reference previously pointed to this
117 * value. Cannot be set together with `old_oid`.
118 */
119 const char *old_target;
120
121 /*
122 * One or more of REF_NO_DEREF, REF_FORCE_CREATE_REFLOG,
123 * REF_HAVE_NEW, REF_HAVE_OLD, or backend-specific flags.
124 */
125 unsigned int flags;
126
127 void *backend_data;
128 unsigned int type;
129 char *msg;
130 char *committer_info;
131
132 /*
133 * The index overrides the default sort algorithm. This is needed
134 * when migrating reflogs and we want to ensure we carry over the
135 * same order.
136 */
137 uint64_t index;
138
139 /*
140 * Used in batched reference updates to mark if a given update
141 * was rejected.
142 */
143 enum ref_transaction_error rejection_err;
144 const char *rejection_details;
145
146 /*
147 * If this ref_update was split off of a symref update via
148 * split_symref_update(), then this member points at that
149 * update. This is used for two purposes:
150 * 1. When reporting errors, we report the refname under which
151 * the update was originally requested.
152 * 2. When we read the old value of this reference, we
153 * propagate it back to its parent update for recording in
154 * the latter's reflog.
155 */
156 struct ref_update *parent_update;
157
158 const char refname[FLEX_ARRAY];
159 };
160
161 int refs_read_raw_ref(struct ref_store *ref_store, const char *refname,
162 struct object_id *oid, struct strbuf *referent,
163 unsigned int *type, int *failure_errno);
164
165 /*
166 * Mark a given update as rejected with a given reason.
167 */
168 int ref_transaction_maybe_set_rejected(struct ref_transaction *transaction,
169 size_t update_idx,
170 enum ref_transaction_error err,
171 struct strbuf *details);
172
173 /*
174 * Add a ref_update with the specified properties to transaction, and
175 * return a pointer to the new object. This function does not verify
176 * that refname is well-formed. new_oid and old_oid are only
177 * dereferenced if the REF_HAVE_NEW and REF_HAVE_OLD bits,
178 * respectively, are set in flags.
179 */
180 struct ref_update *ref_transaction_add_update(
181 struct ref_transaction *transaction,
182 const char *refname, unsigned int flags,
183 const struct object_id *new_oid,
184 const struct object_id *old_oid,
185 const struct object_id *peeled,
186 const char *new_target, const char *old_target,
187 const char *committer_info,
188 const char *msg);
189
190 /*
191 * Transaction states.
192 *
193 * OPEN: The transaction is initialized and new updates can still be
194 * added to it. An OPEN transaction can be prepared,
195 * committed, freed, or aborted (freeing and aborting an open
196 * transaction are equivalent).
197 *
198 * PREPARED: ref_transaction_prepare(), which locks all of the
199 * references involved in the update and checks that the
200 * update has no errors, has been called successfully for the
201 * transaction. A PREPARED transaction can be committed or
202 * aborted.
203 *
204 * CLOSED: The transaction is no longer active. A transaction becomes
205 * CLOSED if there is a failure while building the transaction
206 * or if a transaction is committed or aborted. A CLOSED
207 * transaction can only be freed.
208 */
209 enum ref_transaction_state {
210 REF_TRANSACTION_OPEN = 0,
211 REF_TRANSACTION_PREPARED = 1,
212 REF_TRANSACTION_CLOSED = 2
213 };
214
215 /*
216 * Data structure to hold indices of updates which were rejected, for batched
217 * reference updates. While the updates themselves hold the rejection error,
218 * this structure allows a transaction to iterate only over the rejected
219 * updates.
220 */
221 struct ref_transaction_rejections {
222 size_t *update_indices;
223 size_t alloc;
224 size_t nr;
225 };
226
227 /*
228 * Data structure for holding a reference transaction, which can
229 * consist of checks and updates to multiple references, carried out
230 * as atomically as possible. This structure is opaque to callers.
231 */
232 struct ref_transaction {
233 struct ref_store *ref_store;
234 struct ref_update **updates;
235 struct string_list refnames;
236 size_t alloc;
237 size_t nr;
238 enum ref_transaction_state state;
239 struct ref_transaction_rejections *rejections;
240 void *backend_data;
241 unsigned int flags;
242 uint64_t max_index;
243 };
244
245 /*
246 * Check for entries in extras that are within the specified
247 * directory, where dirname is a reference directory name including
248 * the trailing slash (e.g., "refs/heads/foo/"). Ignore any
249 * conflicting references that are found in skip. If there is a
250 * conflicting reference, return its name.
251 *
252 * extras and skip must be sorted lists of reference names. Either one
253 * can be NULL, signifying the empty list.
254 */
255 const char *find_descendant_ref(const char *dirname,
256 const struct string_list *extras,
257 const struct string_list *skip);
258
259 /* We allow "recursive" symbolic refs. Only within reason, though */
260 #define SYMREF_MAXDEPTH 5
261
262 /*
263 * Data structure for holding a reference iterator. See refs.h for
264 * more details and usage instructions.
265 */
266 struct ref_iterator {
267 struct ref_iterator_vtable *vtable;
268 struct reference ref;
269 };
270
271 /*
272 * An iterator over nothing (its first ref_iterator_advance() call
273 * returns ITER_DONE).
274 */
275 struct ref_iterator *empty_ref_iterator_begin(void);
276
277 /*
278 * Return true iff ref_iterator is an empty_ref_iterator.
279 */
280 int is_empty_ref_iterator(struct ref_iterator *ref_iterator);
281
282 /*
283 * A callback function used to instruct merge_ref_iterator how to
284 * interleave the entries from iter0 and iter1. The function should
285 * return one of the constants defined in enum iterator_selection. It
286 * must not advance either of the iterators itself.
287 *
288 * The function must be prepared to handle the case that iter0 and/or
289 * iter1 is NULL, which indicates that the corresponding sub-iterator
290 * has been exhausted. Its return value must be consistent with the
291 * current states of the iterators; e.g., it must not return
292 * ITER_SKIP_1 if iter1 has already been exhausted.
293 */
294 typedef enum iterator_selection ref_iterator_select_fn(
295 struct ref_iterator *iter0, struct ref_iterator *iter1,
296 void *cb_data);
297
298 /*
299 * An implementation of ref_iterator_select_fn that merges worktree and common
300 * refs. Per-worktree refs from the common iterator are ignored, worktree refs
301 * override common refs. Refs are selected lexicographically.
302 */
303 enum iterator_selection ref_iterator_select(struct ref_iterator *iter_worktree,
304 struct ref_iterator *iter_common,
305 void *cb_data);
306
307 /*
308 * Iterate over the entries from iter0 and iter1, with the values
309 * interleaved as directed by the select function. The iterator takes
310 * ownership of iter0 and iter1 and frees them when the iteration is
311 * over.
312 */
313 struct ref_iterator *merge_ref_iterator_begin(
314 struct ref_iterator *iter0, struct ref_iterator *iter1,
315 ref_iterator_select_fn *select, void *cb_data);
316
317 /*
318 * An iterator consisting of the union of the entries from front and
319 * back. If there are entries common to the two sub-iterators, use the
320 * one from front. Each iterator must iterate over its entries in
321 * strcmp() order by refname for this to work.
322 *
323 * The new iterator takes ownership of its arguments and frees them
324 * when the iteration is over. As a convenience to callers, if front
325 * or back is an empty_ref_iterator, then abort that one immediately
326 * and return the other iterator directly, without wrapping it.
327 */
328 struct ref_iterator *overlay_ref_iterator_begin(
329 struct ref_iterator *front, struct ref_iterator *back);
330
331 /*
332 * Wrap iter0, only letting through the references whose names start
333 * with prefix. If trim is set, set iter->refname to the name of the
334 * reference with that many characters trimmed off the front;
335 * otherwise set it to the full refname. The new iterator takes over
336 * ownership of iter0 and frees it when iteration is over. It makes
337 * its own copy of prefix.
338 *
339 * As an convenience to callers, if prefix is the empty string and
340 * trim is zero, this function returns iter0 directly, without
341 * wrapping it.
342 */
343 struct ref_iterator *prefix_ref_iterator_begin(struct ref_iterator *iter0,
344 const char *prefix,
345 int trim);
346
347 /* Internal implementation of reference iteration: */
348
349 /*
350 * Base class constructor for ref_iterators. Initialize the
351 * ref_iterator part of iter, setting its vtable pointer as specified.
352 * This is meant to be called only by the initializers of derived
353 * classes.
354 */
355 void base_ref_iterator_init(struct ref_iterator *iter,
356 struct ref_iterator_vtable *vtable);
357
358 /* Virtual function declarations for ref_iterators: */
359
360 /*
361 * backend-specific implementation of ref_iterator_advance. For symrefs, the
362 * function should set REF_ISSYMREF, and it should also dereference the symref
363 * to provide the OID referent. It should respect do_for_each_ref_flags
364 * that were passed to refs_ref_iterator_begin().
365 */
366 typedef int ref_iterator_advance_fn(struct ref_iterator *ref_iterator);
367
368 /*
369 * Seek the iterator to the first matching reference. If the
370 * REF_ITERATOR_SEEK_SET_PREFIX flag is set, it would behave the same as if a
371 * new iterator was created with the provided refname as prefix.
372 */
373 typedef int ref_iterator_seek_fn(struct ref_iterator *ref_iterator,
374 const char *refname, unsigned int flags);
375
376 /*
377 * Implementations of this function should free any resources specific
378 * to the derived class.
379 */
380 typedef void ref_iterator_release_fn(struct ref_iterator *ref_iterator);
381
382 struct ref_iterator_vtable {
383 ref_iterator_advance_fn *advance;
384 ref_iterator_seek_fn *seek;
385 ref_iterator_release_fn *release;
386 };
387
388 struct ref_store;
389
390 /* refs backends */
391
392 /* ref_store_init flags */
393 #define REF_STORE_READ (1 << 0)
394 #define REF_STORE_WRITE (1 << 1) /* can perform update operations */
395 #define REF_STORE_ODB (1 << 2) /* has access to object database */
396 #define REF_STORE_MAIN (1 << 3)
397 #define REF_STORE_ALL_CAPS (REF_STORE_READ | \
398 REF_STORE_WRITE | \
399 REF_STORE_ODB | \
400 REF_STORE_MAIN)
401
402 /*
403 * Options for initializing the ref backend. All backend-agnostic information
404 * which backends required will be held here.
405 */
406 struct ref_store_init_options {
407 /* The kind of operations that the ref_store is allowed to perform. */
408 unsigned int access_flags;
409 };
410
411 /*
412 * Initialize the ref_store for the specified gitdir. These functions
413 * should call base_ref_store_init() to initialize the shared part of
414 * the ref_store and to record the ref_store for later lookup.
415 */
416 typedef struct ref_store *ref_store_init_fn(struct repository *repo,
417 const char *payload,
418 const char *gitdir,
419 const struct ref_store_init_options *opts);
420 /*
421 * Release all memory and resources associated with the ref store.
422 */
423 typedef void ref_store_release_fn(struct ref_store *refs);
424
425 typedef int ref_store_create_on_disk_fn(struct ref_store *refs,
426 int flags,
427 struct strbuf *err);
428
429 /*
430 * Remove the reference store from disk.
431 */
432 typedef int ref_store_remove_on_disk_fn(struct ref_store *refs,
433 struct strbuf *err);
434
435 typedef int ref_transaction_prepare_fn(struct ref_store *refs,
436 struct ref_transaction *transaction,
437 struct strbuf *err);
438
439 typedef int ref_transaction_finish_fn(struct ref_store *refs,
440 struct ref_transaction *transaction,
441 struct strbuf *err);
442
443 typedef int ref_transaction_abort_fn(struct ref_store *refs,
444 struct ref_transaction *transaction,
445 struct strbuf *err);
446
447 typedef int optimize_fn(struct ref_store *ref_store,
448 struct refs_optimize_opts *opts);
449
450 typedef int optimize_required_fn(struct ref_store *ref_store,
451 struct refs_optimize_opts *opts,
452 bool *required);
453
454 typedef int rename_ref_fn(struct ref_store *ref_store,
455 const char *oldref, const char *newref,
456 const char *logmsg);
457 typedef int copy_ref_fn(struct ref_store *ref_store,
458 const char *oldref, const char *newref,
459 const char *logmsg);
460
461 /*
462 * Iterate over the references in `ref_store` whose names start with
463 * `prefix`. `prefix` is matched as a literal string, without regard
464 * for path separators. If prefix is NULL or the empty string, iterate
465 * over all references in `ref_store`. The output is ordered by
466 * refname.
467 */
468 typedef struct ref_iterator *ref_iterator_begin_fn(
469 struct ref_store *ref_store,
470 const char *prefix, const char **exclude_patterns,
471 unsigned int flags);
472
473 /* reflog functions */
474
475 /*
476 * Iterate over the references in the specified ref_store that have a
477 * reflog. The refs are iterated over in arbitrary order.
478 */
479 typedef struct ref_iterator *reflog_iterator_begin_fn(
480 struct ref_store *ref_store);
481
482 typedef int for_each_reflog_ent_fn(struct ref_store *ref_store,
483 const char *refname,
484 each_reflog_ent_fn fn,
485 void *cb_data);
486 typedef int for_each_reflog_ent_reverse_fn(struct ref_store *ref_store,
487 const char *refname,
488 each_reflog_ent_fn fn,
489 void *cb_data);
490 typedef int reflog_exists_fn(struct ref_store *ref_store, const char *refname);
491 typedef int create_reflog_fn(struct ref_store *ref_store, const char *refname,
492 struct strbuf *err);
493 typedef int delete_reflog_fn(struct ref_store *ref_store, const char *refname);
494 typedef int reflog_expire_fn(struct ref_store *ref_store,
495 const char *refname,
496 unsigned int flags,
497 reflog_expiry_prepare_fn prepare_fn,
498 reflog_expiry_should_prune_fn should_prune_fn,
499 reflog_expiry_cleanup_fn cleanup_fn,
500 void *policy_cb_data);
501
502 /*
503 * Read a reference from the specified reference store, non-recursively.
504 * Set type to describe the reference, and:
505 *
506 * - If refname is the name of a normal reference, fill in oid
507 * (leaving referent unchanged).
508 *
509 * - If refname is the name of a symbolic reference, write the full
510 * name of the reference to which it refers (e.g.
511 * "refs/heads/master") to referent and set the REF_ISSYMREF bit in
512 * type (leaving oid unchanged). The caller is responsible for
513 * validating that referent is a valid reference name.
514 *
515 * WARNING: refname might be used as part of a filename, so it is
516 * important from a security standpoint that it be safe in the sense
517 * of refname_is_safe(). Moreover, for symrefs this function sets
518 * referent to whatever the repository says, which might not be a
519 * properly-formatted or even safe reference name. NEITHER INPUT NOR
520 * OUTPUT REFERENCE NAMES ARE VALIDATED WITHIN THIS FUNCTION.
521 *
522 * Return 0 on success, or -1 on failure. If the ref exists but is neither a
523 * symbolic ref nor an object ID, it is broken. In this case set REF_ISBROKEN in
524 * type, and return -1 (failure_errno should not be ENOENT)
525 *
526 * failure_errno provides errno codes that are interpreted beyond error
527 * reporting. The following error codes have special meaning:
528 * * ENOENT: the ref doesn't exist
529 * * EISDIR: ref name is a directory
530 * * ENOTDIR: ref prefix is not a directory
531 *
532 * Backend-specific flags might be set in type as well, regardless of
533 * outcome.
534 *
535 * It is OK for refname to point into referent. If so:
536 *
537 * - if the function succeeds with REF_ISSYMREF, referent will be
538 * overwritten and the memory formerly pointed to by it might be
539 * changed or even freed.
540 *
541 * - in all other cases, referent will be untouched, and therefore
542 * refname will still be valid and unchanged.
543 */
544 typedef int read_raw_ref_fn(struct ref_store *ref_store, const char *refname,
545 struct object_id *oid, struct strbuf *referent,
546 unsigned int *type, int *failure_errno);
547
548 /*
549 * Read a symbolic reference from the specified reference store. This function
550 * is optional: if not implemented by a backend, then `read_raw_ref_fn` is used
551 * to read the symbolcic reference instead. It is intended to be implemented
552 * only in case the backend can optimize the reading of symbolic references.
553 *
554 * Return 0 on success, or -1 on failure. `referent` will be set to the target
555 * of the symbolic reference on success. This function explicitly does not
556 * distinguish between error cases and the reference not being a symbolic
557 * reference to allow backends to optimize this operation in case symbolic and
558 * non-symbolic references are treated differently.
559 */
560 typedef int read_symbolic_ref_fn(struct ref_store *ref_store, const char *refname,
561 struct strbuf *referent);
562
563 typedef int fsck_fn(struct ref_store *ref_store,
564 struct fsck_options *o,
565 struct worktree *wt);
566
567 struct ref_storage_be {
568 const char *name;
569 ref_store_init_fn *init;
570 ref_store_release_fn *release;
571 ref_store_create_on_disk_fn *create_on_disk;
572 ref_store_remove_on_disk_fn *remove_on_disk;
573
574 ref_transaction_prepare_fn *transaction_prepare;
575 ref_transaction_finish_fn *transaction_finish;
576 ref_transaction_abort_fn *transaction_abort;
577
578 optimize_fn *optimize;
579 optimize_required_fn *optimize_required;
580 rename_ref_fn *rename_ref;
581 copy_ref_fn *copy_ref;
582
583 ref_iterator_begin_fn *iterator_begin;
584 read_raw_ref_fn *read_raw_ref;
585
586 /*
587 * Please refer to `refs_read_symbolic_ref()` for the expected
588 * behaviour.
589 */
590 read_symbolic_ref_fn *read_symbolic_ref;
591
592 reflog_iterator_begin_fn *reflog_iterator_begin;
593 for_each_reflog_ent_fn *for_each_reflog_ent;
594 for_each_reflog_ent_reverse_fn *for_each_reflog_ent_reverse;
595 reflog_exists_fn *reflog_exists;
596 create_reflog_fn *create_reflog;
597 delete_reflog_fn *delete_reflog;
598 reflog_expire_fn *reflog_expire;
599
600 fsck_fn *fsck;
601 };
602
603 extern struct ref_storage_be refs_be_files;
604 extern struct ref_storage_be refs_be_reftable;
605 extern struct ref_storage_be refs_be_packed;
606
607 /*
608 * A representation of the reference store for the main repository or
609 * a submodule. The ref_store instances for submodules are kept in a
610 * hash map; see repo_get_submodule_ref_store() for more info.
611 */
612 struct ref_store {
613 /* The backend describing this ref_store's storage scheme: */
614 const struct ref_storage_be *be;
615
616 struct repository *repo;
617
618 /*
619 * The gitdir that this ref_store applies to. Note that this is not
620 * necessarily repo->gitdir if the repo has multiple worktrees.
621 */
622 char *gitdir;
623 };
624
625 /*
626 * Parse contents of a loose ref file. *failure_errno maybe be set to EINVAL for
627 * invalid contents.
628 */
629 int parse_loose_ref_contents(const struct git_hash_algo *algop,
630 const char *buf, struct object_id *oid,
631 struct strbuf *referent, unsigned int *type,
632 const char **trailing, int *failure_errno);
633
634 /*
635 * Fill in the generic part of refs and add it to our collection of
636 * reference stores.
637 */
638 void base_ref_store_init(struct ref_store *refs, struct repository *repo,
639 const char *path, const struct ref_storage_be *be);
640
641 /*
642 * Support GIT_TRACE_REFS by optionally wrapping the given ref_store instance.
643 */
644 struct ref_store *maybe_debug_wrap_ref_store(const char *gitdir, struct ref_store *store);
645
646 /*
647 * Return the refname under which update was originally requested.
648 */
649 const char *ref_update_original_update_refname(struct ref_update *update);
650
651 /*
652 * Helper function to check if the new value is null, this
653 * takes into consideration that the update could be a regular
654 * ref or a symbolic ref.
655 */
656 int ref_update_has_null_new_value(struct ref_update *update);
657
658 /*
659 * Check whether the old_target values stored in update are consistent
660 * with the referent, which is the symbolic reference's current value.
661 * If everything is OK, return 0; otherwise, write an error message to
662 * err and return -1.
663 */
664 enum ref_transaction_error ref_update_check_old_target(const char *referent,
665 struct ref_update *update,
666 struct strbuf *err);
667
668 /*
669 * Check if the ref must exist, this means that the old_oid or
670 * old_target is non NULL. Log-only updates never require the old state to
671 * match.
672 */
673 int ref_update_expects_existing_old_ref(struct ref_update *update);
674
675 /*
676 * Same as `refs_verify_refname_available()`, but checking for a list of
677 * refnames instead of only a single item. This is more efficient in the case
678 * where one needs to check multiple refnames.
679 *
680 * If using batched updates, then individual updates are marked rejected,
681 * reference backends are then in charge of not committing those updates.
682 */
683 enum ref_transaction_error refs_verify_refnames_available(struct ref_store *refs,
684 const struct string_list *refnames,
685 const struct string_list *extras,
686 const struct string_list *skip,
687 struct ref_transaction *transaction,
688 unsigned int initial_transaction,
689 struct strbuf *err);
690
691 /*
692 * Given a gitdir and the reference storage payload provided, retrieve the
693 * 'refdir' and 'ref_common_dir'. The former is where references should be
694 * stored for the current worktree, the latter is the common reference
695 * directory if working with a linked worktree. If working with the main
696 * worktree, both values will be the same.
697 *
698 * This is used by backends that store references in the repository directly.
699 */
700 void refs_compute_filesystem_location(const char *gitdir, const char *payload,
701 bool *is_worktree, struct strbuf *refdir,
702 struct strbuf *ref_common_dir);
703
704 #endif /* REFS_REFS_INTERNAL_H */