Merge branch 'mh/reflife'
Define memory ownership and lifetime rules for what for-each-ref feeds to its callbacks (in short, "you do not own it, so make a copy if you want to keep it"). * mh/reflife: (25 commits) refs: document the lifetime of the args passed to each_ref_fn register_ref(): make a copy of the bad reference SHA-1 exclude_existing(): set existing_refs.strdup_strings string_list_add_refs_by_glob(): add a comment about memory management string_list_add_one_ref(): rename first parameter to "refname" show_head_ref(): rename first parameter to "refname" show_head_ref(): do not shadow name of argument add_existing(): do not retain a reference to sha1 do_fetch(): clean up existing_refs before exiting do_fetch(): reduce scope of peer_item object_array_entry: fix memory handling of the name field find_first_merges(): remove unnecessary code find_first_merges(): initialize merges variable using initializer fsck: don't put a void*-shaped peg in a char*-shaped hole object_array_remove_duplicates(): rewrite to reduce copying revision: use object_array_filter() in implementation of gc_boundary() object_array: add function object_array_filter() revision: split some overly-long lines cmd_diff(): make it obvious which cases are exclusive of each other cmd_diff(): rename local variable "list" -> "entry" ...
This commit is contained in:
22
refs.h
22
refs.h
@ -28,13 +28,23 @@ struct ref_lock {
|
||||
#define REF_ISBROKEN 0x04
|
||||
|
||||
/*
|
||||
* 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.
|
||||
* The signature for the callback function for the for_each_*()
|
||||
* functions below. The memory pointed to by the refname and sha1
|
||||
* arguments is only guaranteed to be valid for the duration of a
|
||||
* single callback invocation.
|
||||
*/
|
||||
typedef int each_ref_fn(const char *refname,
|
||||
const unsigned char *sha1, int flags, void *cb_data);
|
||||
|
||||
/*
|
||||
* The following functions invoke the specified callback function for
|
||||
* each reference indicated. If the function ever returns a nonzero
|
||||
* value, stop the iteration and return that 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 *);
|
||||
extern int for_each_ref(each_ref_fn, void *);
|
||||
extern int for_each_ref_in(const char *, each_ref_fn, void *);
|
||||
|
Reference in New Issue
Block a user