summaryrefslogtreecommitdiff
path: root/refs.h
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2014-12-12 09:56:59 +0100
committerJunio C Hamano <gitster@pobox.com>2014-12-22 10:11:40 -0800
commitfa5b1830b0605b39295631f6e167ddb133f2dbde (patch)
treea65601ee9a32d33d5f99620325c36dd34f53f9f0 /refs.h
parentb729effbdbc9ae2d087a83b9e2a165fb8cc04641 (diff)
downloadgit-fa5b1830b0605b39295631f6e167ddb133f2dbde.tar.gz
reflog_expire(): new function in the reference API
Move expire_reflog() into refs.c and rename it to reflog_expire(). Turn the three policy functions into function pointers that are passed into reflog_expire(). Add function prototypes and documentation to refs.h. [jc: squashed in $gmane/261582, drop "extern" in function definition] Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Reviewed-by: Stefan Beller <sbeller@google.com> Tweaked-by: Ramsay Jones Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs.h')
-rw-r--r--refs.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/refs.h b/refs.h
index 7d675b7127..99e707b1b6 100644
--- a/refs.h
+++ b/refs.h
@@ -353,4 +353,50 @@ int update_ref(const char *action, const char *refname,
extern int parse_hide_refs_config(const char *var, const char *value, const char *);
extern int ref_is_hidden(const char *);
+enum expire_reflog_flags {
+ EXPIRE_REFLOGS_DRY_RUN = 1 << 0,
+ EXPIRE_REFLOGS_UPDATE_REF = 1 << 1,
+ EXPIRE_REFLOGS_VERBOSE = 1 << 2,
+ EXPIRE_REFLOGS_REWRITE = 1 << 3
+};
+
+/*
+ * The following interface is used for reflog expiration. The caller
+ * calls reflog_expire(), supplying it with three callback functions,
+ * of the following types. The callback functions define the
+ * expiration policy that is desired.
+ *
+ * reflog_expiry_prepare_fn -- Called once after the reference is
+ * locked.
+ *
+ * reflog_expiry_should_prune_fn -- Called once for each entry in the
+ * existing reflog. It should return true iff that entry should be
+ * pruned.
+ *
+ * reflog_expiry_cleanup_fn -- Called once before the reference is
+ * unlocked again.
+ */
+typedef void reflog_expiry_prepare_fn(const char *refname,
+ const unsigned char *sha1,
+ void *cb_data);
+typedef int reflog_expiry_should_prune_fn(unsigned char *osha1,
+ unsigned char *nsha1,
+ const char *email,
+ unsigned long timestamp, int tz,
+ const char *message, void *cb_data);
+typedef void reflog_expiry_cleanup_fn(void *cb_data);
+
+/*
+ * Expire reflog entries for the specified reference. sha1 is the old
+ * value of the reference. flags is a combination of the constants in
+ * enum expire_reflog_flags. The three function pointers are described
+ * above. On success, return zero.
+ */
+extern int reflog_expire(const char *refname, const unsigned char *sha1,
+ unsigned int flags,
+ reflog_expiry_prepare_fn prepare_fn,
+ reflog_expiry_should_prune_fn should_prune_fn,
+ reflog_expiry_cleanup_fn cleanup_fn,
+ void *policy_cb_data);
+
#endif /* REFS_H */