Add callback data to for_each_ref() family.
[git/git.git] / refs.h
CommitLineData
95fc7512
DB
1#ifndef REFS_H
2#define REFS_H
3
4bd18c43 4struct ref_lock {
434cd0cd 5 char *ref_name;
6de08ae6 6 char *log_file;
c33d5174 7 struct lock_file *lk;
4bd18c43
SP
8 unsigned char old_sha1[20];
9 int lock_fd;
732232a1 10 int force_write;
4bd18c43
SP
11};
12
8a65ff76
LT
13/*
14 * Calls the specified function for each ref file until it returns nonzero,
15 * and returns the value
16 */
cb5d709f
JH
17typedef int each_ref_fn(const char *refname, const unsigned char *sha1, void *cb_data);
18extern int head_ref(each_ref_fn, void *);
19extern int for_each_ref(each_ref_fn, void *);
20extern int for_each_tag_ref(each_ref_fn, void *);
21extern int for_each_branch_ref(each_ref_fn, void *);
22extern int for_each_remote_ref(each_ref_fn, void *);
8a65ff76 23
95fc7512
DB
24/** Reads the refs file specified into sha1 **/
25extern int get_ref_sha1(const char *ref, unsigned char *sha1);
26
4bd18c43 27/** Locks a "refs/" ref returning the lock on success and NULL on failure. **/
e5f38ec3 28extern struct ref_lock *lock_ref_sha1(const char *ref, const unsigned char *old_sha1, int mustexist);
4bd18c43
SP
29
30/** Locks any ref (for 'HEAD' type refs). */
e5f38ec3 31extern struct ref_lock *lock_any_ref_for_update(const char *ref, const unsigned char *old_sha1, int mustexist);
95fc7512 32
4bd18c43 33/** Release any lock taken but not written. **/
e5f38ec3 34extern void unlock_ref(struct ref_lock *lock);
95fc7512 35
4bd18c43
SP
36/** Writes sha1 into the ref specified by the lock. **/
37extern int write_ref_sha1(struct ref_lock *lock, const unsigned char *sha1, const char *msg);
95fc7512 38
d556fae2
SP
39/** Reads log for the value of ref during at_time. **/
40extern int read_ref_at(const char *ref, unsigned long at_time, unsigned char *sha1);
41
95fc7512
DB
42/** Returns 0 if target has the right format for a ref. **/
43extern int check_ref_format(const char *target);
44
45#endif /* REFS_H */