| 1 | #ifndef REFLOG_H |
| 2 | #define REFLOG_H |
| 3 | #include "refs.h" |
| 4 | |
| 5 | #define REFLOG_EXPIRE_TOTAL (1 << 0) |
| 6 | #define REFLOG_EXPIRE_UNREACH (1 << 1) |
| 7 | |
| 8 | struct reflog_expire_entry_option { |
| 9 | struct reflog_expire_entry_option *next; |
| 10 | timestamp_t expire_total; |
| 11 | timestamp_t expire_unreachable; |
| 12 | char pattern[FLEX_ARRAY]; |
| 13 | }; |
| 14 | |
| 15 | struct reflog_expire_options { |
| 16 | struct reflog_expire_entry_option *entries, **entries_tail; |
| 17 | int stalefix; |
| 18 | int explicit_expiry; |
| 19 | timestamp_t default_expire_total; |
| 20 | timestamp_t expire_total; |
| 21 | timestamp_t default_expire_unreachable; |
| 22 | timestamp_t expire_unreachable; |
| 23 | int recno; |
| 24 | }; |
| 25 | #define REFLOG_EXPIRE_OPTIONS_INIT(now) { \ |
| 26 | .default_expire_total = now - 30 * 24 * 3600, \ |
| 27 | .default_expire_unreachable = now - 90 * 24 * 3600, \ |
| 28 | } |
| 29 | |
| 30 | /* |
| 31 | * Parse the reflog expire configuration. This should be used with |
| 32 | * `repo_config()`. |
| 33 | */ |
| 34 | int reflog_expire_config(const char *var, const char *value, |
| 35 | const struct config_context *ctx, void *cb); |
| 36 | |
| 37 | void reflog_clear_expire_config(struct reflog_expire_options *opts); |
| 38 | |
| 39 | /* |
| 40 | * Adapt the options so that they apply to the given refname. This applies any |
| 41 | * per-reference reflog expiry configuration that may exist to the options. |
| 42 | */ |
| 43 | void reflog_expire_options_set_refname(struct reflog_expire_options *cb, |
| 44 | const char *refname); |
| 45 | |
| 46 | struct expire_reflog_policy_cb { |
| 47 | enum { |
| 48 | UE_NORMAL, |
| 49 | UE_ALWAYS, |
| 50 | UE_HEAD |
| 51 | } unreachable_expire_kind; |
| 52 | struct commit_list *mark_list; |
| 53 | unsigned long mark_limit; |
| 54 | struct reflog_expire_options opts; |
| 55 | struct commit *tip_commit; |
| 56 | struct commit_list *tips; |
| 57 | unsigned int dry_run:1; |
| 58 | }; |
| 59 | |
| 60 | int reflog_delete(const char *rev, enum expire_reflog_flags flags, |
| 61 | int verbose); |
| 62 | void reflog_expiry_cleanup(void *cb_data); |
| 63 | void reflog_expiry_prepare(const char *refname, const struct object_id *oid, |
| 64 | void *cb_data); |
| 65 | int should_expire_reflog_ent(struct object_id *ooid, struct object_id *noid, |
| 66 | const char *email, timestamp_t timestamp, int tz, |
| 67 | const char *message, void *cb_data); |
| 68 | int count_reflog_ent(const char *refname, |
| 69 | struct object_id *ooid, struct object_id *noid, |
| 70 | const char *email, timestamp_t timestamp, int tz, |
| 71 | const char *message, void *cb_data); |
| 72 | int should_expire_reflog_ent_verbose(struct object_id *ooid, |
| 73 | struct object_id *noid, |
| 74 | const char *email, |
| 75 | timestamp_t timestamp, int tz, |
| 76 | const char *message, void *cb_data); |
| 77 | #endif /* REFLOG_H */ |