diff options
Diffstat (limited to 'refs.h')
-rw-r--r-- | refs.h | 51 |
1 files changed, 30 insertions, 21 deletions
@@ -15,8 +15,11 @@ struct ref_lock { #define REF_ISBROKEN 0x04 /* - * Calls the specified function for each ref file until it returns nonzero, - * and returns the value + * Calls the specified function for each ref file until it returns + * nonzero, and returns the value. Please note that it is not safe to + * modify references while an iteration is in progress, unless the + * same callback function invocation that modifies the reference also + * returns a nonzero value to immediately stop the iteration. */ typedef int each_ref_fn(const char *refname, const unsigned char *sha1, int flags, void *cb_data); extern int head_ref(each_ref_fn, void *); @@ -51,23 +54,23 @@ extern int for_each_rawref(each_ref_fn, void *); extern void warn_dangling_symref(FILE *fp, const char *msg_fmt, const char *refname); /* - * Extra refs will be listed by for_each_ref() before any actual refs - * for the duration of this process or until clear_extra_refs() is - * called. Only extra refs added before for_each_ref() is called will - * be listed on a given call of for_each_ref(). + * Add a reference to the in-memory packed reference cache. To actually + * write the reference to the packed-refs file, call pack_refs(). */ -extern void add_extra_ref(const char *refname, const unsigned char *sha1, int flags); -extern void clear_extra_refs(void); +extern void add_packed_ref(const char *refname, const unsigned char *sha1); + extern int ref_exists(const char *); -extern int peel_ref(const char *, unsigned char *); +extern int peel_ref(const char *refname, unsigned char *sha1); /** Locks a "refs/" ref returning the lock on success and NULL on failure. **/ -extern struct ref_lock *lock_ref_sha1(const char *ref, const unsigned char *old_sha1); +extern struct ref_lock *lock_ref_sha1(const char *refname, const unsigned char *old_sha1); /** Locks any ref (for 'HEAD' type refs). */ #define REF_NODEREF 0x01 -extern struct ref_lock *lock_any_ref_for_update(const char *ref, const unsigned char *old_sha1, int flags); +extern struct ref_lock *lock_any_ref_for_update(const char *refname, + const unsigned char *old_sha1, + int flags); /** Close the file descriptor owned by a lock and return the status */ extern int close_ref(struct ref_lock *lock); @@ -93,12 +96,14 @@ extern void invalidate_ref_cache(const char *submodule); int log_ref_setup(const char *ref_name, char *logfile, int bufsize); /** Reads log for the value of ref during at_time. **/ -extern int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char *sha1, char **msg, unsigned long *cutoff_time, int *cutoff_tz, int *cutoff_cnt); +extern int read_ref_at(const char *refname, unsigned long at_time, int cnt, + unsigned char *sha1, char **msg, + unsigned long *cutoff_time, int *cutoff_tz, int *cutoff_cnt); /* iterate over reflog entries */ typedef int each_reflog_ent_fn(unsigned char *osha1, unsigned char *nsha1, const char *, unsigned long, int, const char *, void *); -int for_each_reflog_ent(const char *ref, each_reflog_ent_fn fn, void *cb_data); -int for_each_recent_reflog_ent(const char *ref, each_reflog_ent_fn fn, long, void *cb_data); +int for_each_reflog_ent(const char *refname, each_reflog_ent_fn fn, void *cb_data); +int for_each_recent_reflog_ent(const char *refname, each_reflog_ent_fn fn, long, void *cb_data); /* * Calls the specified function for each reflog file until it returns nonzero, @@ -111,9 +116,9 @@ extern int for_each_reflog(each_ref_fn, void *); #define REFNAME_DOT_COMPONENT 4 /* - * Return 0 iff ref has the correct format for a refname according to - * the rules described in Documentation/git-check-ref-format.txt. If - * REFNAME_ALLOW_ONELEVEL is set in flags, then accept one-level + * Return 0 iff refname has the correct format for a refname according + * to the rules described in Documentation/git-check-ref-format.txt. + * If REFNAME_ALLOW_ONELEVEL is set in flags, then accept one-level * reference names. If REFNAME_REFSPEC_PATTERN is set in flags, then * allow a "*" wildcard character in place of one of the name * components. No leading or repeated slashes are accepted. If @@ -121,16 +126,20 @@ extern int for_each_reflog(each_ref_fn, void *); * components to start with "." (but not a whole component equal to * "." or ".."). */ -extern int check_refname_format(const char *ref, int flags); +extern int check_refname_format(const char *refname, int flags); extern const char *prettify_refname(const char *refname); -extern char *shorten_unambiguous_ref(const char *ref, int strict); +extern char *shorten_unambiguous_ref(const char *refname, int strict); /** rename ref, return 0 on success **/ extern int rename_ref(const char *oldref, const char *newref, const char *logmsg); -/** resolve ref in nested "gitlink" repository */ -extern int resolve_gitlink_ref(const char *name, const char *refname, unsigned char *result); +/** + * Resolve refname in the nested "gitlink" repository that is located + * at path. If the resolution is successful, return 0 and set sha1 to + * the name of the object; otherwise, return a non-zero value. + */ +extern int resolve_gitlink_ref(const char *path, const char *refname, unsigned char *sha1); /** lock a ref and then write its file */ enum action_on_err { MSG_ON_ERR, DIE_ON_ERR, QUIET_ON_ERR }; |