4676dc395954ff7873890af2709de982dcd9a3fa
1#include "../cache.h"
2#include "../refs.h"
3#include "refs-internal.h"
4#include "ref-cache.h"
5#include "packed-backend.h"
6#include "../iterator.h"
7#include "../lockfile.h"
8
9struct packed_ref_cache {
10 struct ref_cache *cache;
11
12 /*
13 * Count of references to the data structure in this instance,
14 * including the pointer from files_ref_store::packed if any.
15 * The data will not be freed as long as the reference count
16 * is nonzero.
17 */
18 unsigned int referrers;
19
20 /* The metadata from when this packed-refs cache was read */
21 struct stat_validity validity;
22};
23
24/*
25 * Increment the reference count of *packed_refs.
26 */
27static void acquire_packed_ref_cache(struct packed_ref_cache *packed_refs)
28{
29 packed_refs->referrers++;
30}
31
32/*
33 * Decrease the reference count of *packed_refs. If it goes to zero,
34 * free *packed_refs and return true; otherwise return false.
35 */
36static int release_packed_ref_cache(struct packed_ref_cache *packed_refs)
37{
38 if (!--packed_refs->referrers) {
39 free_ref_cache(packed_refs->cache);
40 stat_validity_clear(&packed_refs->validity);
41 free(packed_refs);
42 return 1;
43 } else {
44 return 0;
45 }
46}
47
48/*
49 * A container for `packed-refs`-related data. It is not (yet) a
50 * `ref_store`.
51 */
52struct packed_ref_store {
53 struct ref_store base;
54
55 unsigned int store_flags;
56
57 /* The path of the "packed-refs" file: */
58 char *path;
59
60 /*
61 * A cache of the values read from the `packed-refs` file, if
62 * it might still be current; otherwise, NULL.
63 */
64 struct packed_ref_cache *cache;
65
66 /*
67 * Lock used for the "packed-refs" file. Note that this (and
68 * thus the enclosing `packed_ref_store`) must not be freed.
69 */
70 struct lock_file lock;
71};
72
73struct ref_store *packed_ref_store_create(const char *path,
74 unsigned int store_flags)
75{
76 struct packed_ref_store *refs = xcalloc(1, sizeof(*refs));
77 struct ref_store *ref_store = (struct ref_store *)refs;
78
79 base_ref_store_init(ref_store, &refs_be_packed);
80 refs->store_flags = store_flags;
81
82 refs->path = xstrdup(path);
83 return ref_store;
84}
85
86/*
87 * Die if refs is not the main ref store. caller is used in any
88 * necessary error messages.
89 */
90static void packed_assert_main_repository(struct packed_ref_store *refs,
91 const char *caller)
92{
93 if (refs->store_flags & REF_STORE_MAIN)
94 return;
95
96 die("BUG: operation %s only allowed for main ref store", caller);
97}
98
99/*
100 * Downcast `ref_store` to `packed_ref_store`. Die if `ref_store` is
101 * not a `packed_ref_store`. Also die if `packed_ref_store` doesn't
102 * support at least the flags specified in `required_flags`. `caller`
103 * is used in any necessary error messages.
104 */
105static struct packed_ref_store *packed_downcast(struct ref_store *ref_store,
106 unsigned int required_flags,
107 const char *caller)
108{
109 struct packed_ref_store *refs;
110
111 if (ref_store->be != &refs_be_packed)
112 die("BUG: ref_store is type \"%s\" not \"packed\" in %s",
113 ref_store->be->name, caller);
114
115 refs = (struct packed_ref_store *)ref_store;
116
117 if ((refs->store_flags & required_flags) != required_flags)
118 die("BUG: unallowed operation (%s), requires %x, has %x\n",
119 caller, required_flags, refs->store_flags);
120
121 return refs;
122}
123
124static void clear_packed_ref_cache(struct packed_ref_store *refs)
125{
126 if (refs->cache) {
127 struct packed_ref_cache *cache = refs->cache;
128
129 if (is_lock_file_locked(&refs->lock))
130 die("BUG: packed-ref cache cleared while locked");
131 refs->cache = NULL;
132 release_packed_ref_cache(cache);
133 }
134}
135
136/* The length of a peeled reference line in packed-refs, including EOL: */
137#define PEELED_LINE_LENGTH 42
138
139/*
140 * Parse one line from a packed-refs file. Write the SHA1 to sha1.
141 * Return a pointer to the refname within the line (null-terminated),
142 * or NULL if there was a problem.
143 */
144static const char *parse_ref_line(struct strbuf *line, struct object_id *oid)
145{
146 const char *ref;
147
148 if (parse_oid_hex(line->buf, oid, &ref) < 0)
149 return NULL;
150 if (!isspace(*ref++))
151 return NULL;
152
153 if (isspace(*ref))
154 return NULL;
155
156 if (line->buf[line->len - 1] != '\n')
157 return NULL;
158 line->buf[--line->len] = 0;
159
160 return ref;
161}
162
163/*
164 * Read from `packed_refs_file` into a newly-allocated
165 * `packed_ref_cache` and return it. The return value will already
166 * have its reference count incremented.
167 *
168 * A comment line of the form "# pack-refs with: " may contain zero or
169 * more traits. We interpret the traits as follows:
170 *
171 * No traits:
172 *
173 * Probably no references are peeled. But if the file contains a
174 * peeled value for a reference, we will use it.
175 *
176 * peeled:
177 *
178 * References under "refs/tags/", if they *can* be peeled, *are*
179 * peeled in this file. References outside of "refs/tags/" are
180 * probably not peeled even if they could have been, but if we find
181 * a peeled value for such a reference we will use it.
182 *
183 * fully-peeled:
184 *
185 * All references in the file that can be peeled are peeled.
186 * Inversely (and this is more important), any references in the
187 * file for which no peeled value is recorded is not peelable. This
188 * trait should typically be written alongside "peeled" for
189 * compatibility with older clients, but we do not require it
190 * (i.e., "peeled" is a no-op if "fully-peeled" is set).
191 */
192static struct packed_ref_cache *read_packed_refs(const char *packed_refs_file)
193{
194 FILE *f;
195 struct packed_ref_cache *packed_refs = xcalloc(1, sizeof(*packed_refs));
196 struct ref_entry *last = NULL;
197 struct strbuf line = STRBUF_INIT;
198 enum { PEELED_NONE, PEELED_TAGS, PEELED_FULLY } peeled = PEELED_NONE;
199 struct ref_dir *dir;
200
201 acquire_packed_ref_cache(packed_refs);
202 packed_refs->cache = create_ref_cache(NULL, NULL);
203 packed_refs->cache->root->flag &= ~REF_INCOMPLETE;
204
205 f = fopen(packed_refs_file, "r");
206 if (!f) {
207 if (errno == ENOENT) {
208 /*
209 * This is OK; it just means that no
210 * "packed-refs" file has been written yet,
211 * which is equivalent to it being empty.
212 */
213 return packed_refs;
214 } else {
215 die_errno("couldn't read %s", packed_refs_file);
216 }
217 }
218
219 stat_validity_update(&packed_refs->validity, fileno(f));
220
221 dir = get_ref_dir(packed_refs->cache->root);
222 while (strbuf_getwholeline(&line, f, '\n') != EOF) {
223 struct object_id oid;
224 const char *refname;
225 const char *traits;
226
227 if (skip_prefix(line.buf, "# pack-refs with:", &traits)) {
228 if (strstr(traits, " fully-peeled "))
229 peeled = PEELED_FULLY;
230 else if (strstr(traits, " peeled "))
231 peeled = PEELED_TAGS;
232 /* perhaps other traits later as well */
233 continue;
234 }
235
236 refname = parse_ref_line(&line, &oid);
237 if (refname) {
238 int flag = REF_ISPACKED;
239
240 if (check_refname_format(refname, REFNAME_ALLOW_ONELEVEL)) {
241 if (!refname_is_safe(refname))
242 die("packed refname is dangerous: %s", refname);
243 oidclr(&oid);
244 flag |= REF_BAD_NAME | REF_ISBROKEN;
245 }
246 last = create_ref_entry(refname, &oid, flag);
247 if (peeled == PEELED_FULLY ||
248 (peeled == PEELED_TAGS && starts_with(refname, "refs/tags/")))
249 last->flag |= REF_KNOWS_PEELED;
250 add_ref_entry(dir, last);
251 continue;
252 }
253 if (last &&
254 line.buf[0] == '^' &&
255 line.len == PEELED_LINE_LENGTH &&
256 line.buf[PEELED_LINE_LENGTH - 1] == '\n' &&
257 !get_oid_hex(line.buf + 1, &oid)) {
258 oidcpy(&last->u.value.peeled, &oid);
259 /*
260 * Regardless of what the file header said,
261 * we definitely know the value of *this*
262 * reference:
263 */
264 last->flag |= REF_KNOWS_PEELED;
265 }
266 }
267
268 fclose(f);
269 strbuf_release(&line);
270
271 return packed_refs;
272}
273
274/*
275 * Check that the packed refs cache (if any) still reflects the
276 * contents of the file. If not, clear the cache.
277 */
278static void validate_packed_ref_cache(struct packed_ref_store *refs)
279{
280 if (refs->cache &&
281 !stat_validity_check(&refs->cache->validity, refs->path))
282 clear_packed_ref_cache(refs);
283}
284
285/*
286 * Get the packed_ref_cache for the specified packed_ref_store,
287 * creating and populating it if it hasn't been read before or if the
288 * file has been changed (according to its `validity` field) since it
289 * was last read. On the other hand, if we hold the lock, then assume
290 * that the file hasn't been changed out from under us, so skip the
291 * extra `stat()` call in `stat_validity_check()`.
292 */
293static struct packed_ref_cache *get_packed_ref_cache(struct packed_ref_store *refs)
294{
295 if (!is_lock_file_locked(&refs->lock))
296 validate_packed_ref_cache(refs);
297
298 if (!refs->cache)
299 refs->cache = read_packed_refs(refs->path);
300
301 return refs->cache;
302}
303
304static struct ref_dir *get_packed_ref_dir(struct packed_ref_cache *packed_ref_cache)
305{
306 return get_ref_dir(packed_ref_cache->cache->root);
307}
308
309static struct ref_dir *get_packed_refs(struct packed_ref_store *refs)
310{
311 return get_packed_ref_dir(get_packed_ref_cache(refs));
312}
313
314/*
315 * Add or overwrite a reference in the in-memory packed reference
316 * cache. This may only be called while the packed-refs file is locked
317 * (see lock_packed_refs()). To actually write the packed-refs file,
318 * call commit_packed_refs().
319 */
320void add_packed_ref(struct ref_store *ref_store,
321 const char *refname, const struct object_id *oid)
322{
323 struct packed_ref_store *refs =
324 packed_downcast(ref_store, REF_STORE_WRITE,
325 "add_packed_ref");
326 struct ref_dir *packed_refs;
327 struct ref_entry *packed_entry;
328
329 if (!is_lock_file_locked(&refs->lock))
330 die("BUG: packed refs not locked");
331
332 if (check_refname_format(refname, REFNAME_ALLOW_ONELEVEL))
333 die("Reference has invalid format: '%s'", refname);
334
335 packed_refs = get_packed_refs(refs);
336 packed_entry = find_ref_entry(packed_refs, refname);
337 if (packed_entry) {
338 /* Overwrite the existing entry: */
339 oidcpy(&packed_entry->u.value.oid, oid);
340 packed_entry->flag = REF_ISPACKED;
341 oidclr(&packed_entry->u.value.peeled);
342 } else {
343 packed_entry = create_ref_entry(refname, oid, REF_ISPACKED);
344 add_ref_entry(packed_refs, packed_entry);
345 }
346}
347
348/*
349 * Return the ref_entry for the given refname from the packed
350 * references. If it does not exist, return NULL.
351 */
352static struct ref_entry *get_packed_ref(struct packed_ref_store *refs,
353 const char *refname)
354{
355 return find_ref_entry(get_packed_refs(refs), refname);
356}
357
358static int packed_read_raw_ref(struct ref_store *ref_store,
359 const char *refname, unsigned char *sha1,
360 struct strbuf *referent, unsigned int *type)
361{
362 struct packed_ref_store *refs =
363 packed_downcast(ref_store, REF_STORE_READ, "read_raw_ref");
364
365 struct ref_entry *entry;
366
367 *type = 0;
368
369 entry = get_packed_ref(refs, refname);
370 if (!entry) {
371 errno = ENOENT;
372 return -1;
373 }
374
375 hashcpy(sha1, entry->u.value.oid.hash);
376 *type = REF_ISPACKED;
377 return 0;
378}
379
380static int packed_peel_ref(struct ref_store *ref_store,
381 const char *refname, unsigned char *sha1)
382{
383 struct packed_ref_store *refs =
384 packed_downcast(ref_store, REF_STORE_READ | REF_STORE_ODB,
385 "peel_ref");
386 struct ref_entry *r = get_packed_ref(refs, refname);
387
388 if (!r || peel_entry(r, 0))
389 return -1;
390
391 hashcpy(sha1, r->u.value.peeled.hash);
392 return 0;
393}
394
395struct packed_ref_iterator {
396 struct ref_iterator base;
397
398 struct packed_ref_cache *cache;
399 struct ref_iterator *iter0;
400 unsigned int flags;
401};
402
403static int packed_ref_iterator_advance(struct ref_iterator *ref_iterator)
404{
405 struct packed_ref_iterator *iter =
406 (struct packed_ref_iterator *)ref_iterator;
407 int ok;
408
409 while ((ok = ref_iterator_advance(iter->iter0)) == ITER_OK) {
410 if (iter->flags & DO_FOR_EACH_PER_WORKTREE_ONLY &&
411 ref_type(iter->iter0->refname) != REF_TYPE_PER_WORKTREE)
412 continue;
413
414 if (!(iter->flags & DO_FOR_EACH_INCLUDE_BROKEN) &&
415 !ref_resolves_to_object(iter->iter0->refname,
416 iter->iter0->oid,
417 iter->iter0->flags))
418 continue;
419
420 iter->base.refname = iter->iter0->refname;
421 iter->base.oid = iter->iter0->oid;
422 iter->base.flags = iter->iter0->flags;
423 return ITER_OK;
424 }
425
426 iter->iter0 = NULL;
427 if (ref_iterator_abort(ref_iterator) != ITER_DONE)
428 ok = ITER_ERROR;
429
430 return ok;
431}
432
433static int packed_ref_iterator_peel(struct ref_iterator *ref_iterator,
434 struct object_id *peeled)
435{
436 struct packed_ref_iterator *iter =
437 (struct packed_ref_iterator *)ref_iterator;
438
439 return ref_iterator_peel(iter->iter0, peeled);
440}
441
442static int packed_ref_iterator_abort(struct ref_iterator *ref_iterator)
443{
444 struct packed_ref_iterator *iter =
445 (struct packed_ref_iterator *)ref_iterator;
446 int ok = ITER_DONE;
447
448 if (iter->iter0)
449 ok = ref_iterator_abort(iter->iter0);
450
451 release_packed_ref_cache(iter->cache);
452 base_ref_iterator_free(ref_iterator);
453 return ok;
454}
455
456static struct ref_iterator_vtable packed_ref_iterator_vtable = {
457 packed_ref_iterator_advance,
458 packed_ref_iterator_peel,
459 packed_ref_iterator_abort
460};
461
462static struct ref_iterator *packed_ref_iterator_begin(
463 struct ref_store *ref_store,
464 const char *prefix, unsigned int flags)
465{
466 struct packed_ref_store *refs;
467 struct packed_ref_iterator *iter;
468 struct ref_iterator *ref_iterator;
469 unsigned int required_flags = REF_STORE_READ;
470
471 if (!(flags & DO_FOR_EACH_INCLUDE_BROKEN))
472 required_flags |= REF_STORE_ODB;
473 refs = packed_downcast(ref_store, required_flags, "ref_iterator_begin");
474
475 iter = xcalloc(1, sizeof(*iter));
476 ref_iterator = &iter->base;
477 base_ref_iterator_init(ref_iterator, &packed_ref_iterator_vtable);
478
479 /*
480 * Note that get_packed_ref_cache() internally checks whether
481 * the packed-ref cache is up to date with what is on disk,
482 * and re-reads it if not.
483 */
484
485 iter->cache = get_packed_ref_cache(refs);
486 acquire_packed_ref_cache(iter->cache);
487 iter->iter0 = cache_ref_iterator_begin(iter->cache->cache, prefix, 0);
488
489 iter->flags = flags;
490
491 return ref_iterator;
492}
493
494/*
495 * Write an entry to the packed-refs file for the specified refname.
496 * If peeled is non-NULL, write it as the entry's peeled value.
497 */
498static void write_packed_entry(FILE *fh, const char *refname,
499 const unsigned char *sha1,
500 const unsigned char *peeled)
501{
502 fprintf_or_die(fh, "%s %s\n", sha1_to_hex(sha1), refname);
503 if (peeled)
504 fprintf_or_die(fh, "^%s\n", sha1_to_hex(peeled));
505}
506
507int lock_packed_refs(struct ref_store *ref_store, int flags)
508{
509 struct packed_ref_store *refs =
510 packed_downcast(ref_store, REF_STORE_WRITE | REF_STORE_MAIN,
511 "lock_packed_refs");
512 static int timeout_configured = 0;
513 static int timeout_value = 1000;
514 struct packed_ref_cache *packed_ref_cache;
515
516 if (!timeout_configured) {
517 git_config_get_int("core.packedrefstimeout", &timeout_value);
518 timeout_configured = 1;
519 }
520
521 if (hold_lock_file_for_update_timeout(
522 &refs->lock,
523 refs->path,
524 flags, timeout_value) < 0)
525 return -1;
526
527 /*
528 * Now that we hold the `packed-refs` lock, make sure that our
529 * cache matches the current version of the file. Normally
530 * `get_packed_ref_cache()` does that for us, but that
531 * function assumes that when the file is locked, any existing
532 * cache is still valid. We've just locked the file, but it
533 * might have changed the moment *before* we locked it.
534 */
535 validate_packed_ref_cache(refs);
536
537 packed_ref_cache = get_packed_ref_cache(refs);
538 /* Increment the reference count to prevent it from being freed: */
539 acquire_packed_ref_cache(packed_ref_cache);
540 return 0;
541}
542
543/*
544 * The packed-refs header line that we write out. Perhaps other
545 * traits will be added later. The trailing space is required.
546 */
547static const char PACKED_REFS_HEADER[] =
548 "# pack-refs with: peeled fully-peeled \n";
549
550/*
551 * Write the current version of the packed refs cache from memory to
552 * disk. The packed-refs file must already be locked for writing (see
553 * lock_packed_refs()). Return zero on success. On errors, set errno
554 * and return a nonzero value.
555 */
556int commit_packed_refs(struct ref_store *ref_store)
557{
558 struct packed_ref_store *refs =
559 packed_downcast(ref_store, REF_STORE_WRITE | REF_STORE_MAIN,
560 "commit_packed_refs");
561 struct packed_ref_cache *packed_ref_cache =
562 get_packed_ref_cache(refs);
563 int ok, error = 0;
564 int save_errno = 0;
565 FILE *out;
566 struct ref_iterator *iter;
567
568 if (!is_lock_file_locked(&refs->lock))
569 die("BUG: packed-refs not locked");
570
571 out = fdopen_lock_file(&refs->lock, "w");
572 if (!out)
573 die_errno("unable to fdopen packed-refs descriptor");
574
575 fprintf_or_die(out, "%s", PACKED_REFS_HEADER);
576
577 iter = cache_ref_iterator_begin(packed_ref_cache->cache, NULL, 0);
578 while ((ok = ref_iterator_advance(iter)) == ITER_OK) {
579 struct object_id peeled;
580 int peel_error = ref_iterator_peel(iter, &peeled);
581
582 write_packed_entry(out, iter->refname, iter->oid->hash,
583 peel_error ? NULL : peeled.hash);
584 }
585
586 if (ok != ITER_DONE)
587 die("error while iterating over references");
588
589 if (commit_lock_file(&refs->lock)) {
590 save_errno = errno;
591 error = -1;
592 }
593 release_packed_ref_cache(packed_ref_cache);
594 errno = save_errno;
595 return error;
596}
597
598/*
599 * Rollback the lockfile for the packed-refs file, and discard the
600 * in-memory packed reference cache. (The packed-refs file will be
601 * read anew if it is needed again after this function is called.)
602 */
603static void rollback_packed_refs(struct packed_ref_store *refs)
604{
605 struct packed_ref_cache *packed_ref_cache = get_packed_ref_cache(refs);
606
607 packed_assert_main_repository(refs, "rollback_packed_refs");
608
609 if (!is_lock_file_locked(&refs->lock))
610 die("BUG: packed-refs not locked");
611 rollback_lock_file(&refs->lock);
612 release_packed_ref_cache(packed_ref_cache);
613 clear_packed_ref_cache(refs);
614}
615
616/*
617 * Rewrite the packed-refs file, omitting any refs listed in
618 * 'refnames'. On error, leave packed-refs unchanged, write an error
619 * message to 'err', and return a nonzero value.
620 *
621 * The refs in 'refnames' needn't be sorted. `err` must not be NULL.
622 */
623int repack_without_refs(struct ref_store *ref_store,
624 struct string_list *refnames, struct strbuf *err)
625{
626 struct packed_ref_store *refs =
627 packed_downcast(ref_store, REF_STORE_WRITE | REF_STORE_MAIN,
628 "repack_without_refs");
629 struct ref_dir *packed;
630 struct string_list_item *refname;
631 int ret, needs_repacking = 0, removed = 0;
632
633 packed_assert_main_repository(refs, "repack_without_refs");
634 assert(err);
635
636 /* Look for a packed ref */
637 for_each_string_list_item(refname, refnames) {
638 if (get_packed_ref(refs, refname->string)) {
639 needs_repacking = 1;
640 break;
641 }
642 }
643
644 /* Avoid locking if we have nothing to do */
645 if (!needs_repacking)
646 return 0; /* no refname exists in packed refs */
647
648 if (lock_packed_refs(&refs->base, 0)) {
649 unable_to_lock_message(refs->path, errno, err);
650 return -1;
651 }
652 packed = get_packed_refs(refs);
653
654 /* Remove refnames from the cache */
655 for_each_string_list_item(refname, refnames)
656 if (remove_entry_from_dir(packed, refname->string) != -1)
657 removed = 1;
658 if (!removed) {
659 /*
660 * All packed entries disappeared while we were
661 * acquiring the lock.
662 */
663 rollback_packed_refs(refs);
664 return 0;
665 }
666
667 /* Write what remains */
668 ret = commit_packed_refs(&refs->base);
669 if (ret)
670 strbuf_addf(err, "unable to overwrite old ref-pack file: %s",
671 strerror(errno));
672 return ret;
673}
674
675static int packed_init_db(struct ref_store *ref_store, struct strbuf *err)
676{
677 /* Nothing to do. */
678 return 0;
679}
680
681static int packed_transaction_prepare(struct ref_store *ref_store,
682 struct ref_transaction *transaction,
683 struct strbuf *err)
684{
685 die("BUG: not implemented yet");
686}
687
688static int packed_transaction_abort(struct ref_store *ref_store,
689 struct ref_transaction *transaction,
690 struct strbuf *err)
691{
692 die("BUG: not implemented yet");
693}
694
695static int packed_transaction_finish(struct ref_store *ref_store,
696 struct ref_transaction *transaction,
697 struct strbuf *err)
698{
699 die("BUG: not implemented yet");
700}
701
702static int packed_initial_transaction_commit(struct ref_store *ref_store,
703 struct ref_transaction *transaction,
704 struct strbuf *err)
705{
706 return ref_transaction_commit(transaction, err);
707}
708
709static int packed_delete_refs(struct ref_store *ref_store, const char *msg,
710 struct string_list *refnames, unsigned int flags)
711{
712 die("BUG: not implemented yet");
713}
714
715static int packed_pack_refs(struct ref_store *ref_store, unsigned int flags)
716{
717 /*
718 * Packed refs are already packed. It might be that loose refs
719 * are packed *into* a packed refs store, but that is done by
720 * updating the packed references via a transaction.
721 */
722 return 0;
723}
724
725static int packed_create_symref(struct ref_store *ref_store,
726 const char *refname, const char *target,
727 const char *logmsg)
728{
729 die("BUG: packed reference store does not support symrefs");
730}
731
732static int packed_rename_ref(struct ref_store *ref_store,
733 const char *oldrefname, const char *newrefname,
734 const char *logmsg)
735{
736 die("BUG: packed reference store does not support renaming references");
737}
738
739static struct ref_iterator *packed_reflog_iterator_begin(struct ref_store *ref_store)
740{
741 return empty_ref_iterator_begin();
742}
743
744static int packed_for_each_reflog_ent(struct ref_store *ref_store,
745 const char *refname,
746 each_reflog_ent_fn fn, void *cb_data)
747{
748 return 0;
749}
750
751static int packed_for_each_reflog_ent_reverse(struct ref_store *ref_store,
752 const char *refname,
753 each_reflog_ent_fn fn,
754 void *cb_data)
755{
756 return 0;
757}
758
759static int packed_reflog_exists(struct ref_store *ref_store,
760 const char *refname)
761{
762 return 0;
763}
764
765static int packed_create_reflog(struct ref_store *ref_store,
766 const char *refname, int force_create,
767 struct strbuf *err)
768{
769 die("BUG: packed reference store does not support reflogs");
770}
771
772static int packed_delete_reflog(struct ref_store *ref_store,
773 const char *refname)
774{
775 return 0;
776}
777
778static int packed_reflog_expire(struct ref_store *ref_store,
779 const char *refname, const unsigned char *sha1,
780 unsigned int flags,
781 reflog_expiry_prepare_fn prepare_fn,
782 reflog_expiry_should_prune_fn should_prune_fn,
783 reflog_expiry_cleanup_fn cleanup_fn,
784 void *policy_cb_data)
785{
786 return 0;
787}
788
789struct ref_storage_be refs_be_packed = {
790 NULL,
791 "packed",
792 packed_ref_store_create,
793 packed_init_db,
794 packed_transaction_prepare,
795 packed_transaction_finish,
796 packed_transaction_abort,
797 packed_initial_transaction_commit,
798
799 packed_pack_refs,
800 packed_peel_ref,
801 packed_create_symref,
802 packed_delete_refs,
803 packed_rename_ref,
804
805 packed_ref_iterator_begin,
806 packed_read_raw_ref,
807
808 packed_reflog_iterator_begin,
809 packed_for_each_reflog_ent,
810 packed_for_each_reflog_ent_reverse,
811 packed_reflog_exists,
812 packed_create_reflog,
813 packed_delete_reflog,
814 packed_reflog_expire
815};