Merge branch 'mh/ref-api'

Allows walking only a sub-hierarchy in refs/*.

By Michael Haggerty
* mh/ref-api:
  do_for_each_ref(): only iterate over the subtree that was requested
  refs: store references hierarchically
  sort_ref_dir(): simplify logic
  refs.c: rename ref_array -> ref_dir
  struct ref_entry: nest the value part in a union
  check_refname_component(): return 0 for zero-length components
  free_ref_entry(): new function
  names_conflict(): simplify implementation
  repack_without_ref(): reimplement using do_for_each_ref_in_array()
  do_for_each_ref_in_arrays(): new function
  do_for_each_ref_in_array(): new function
  refs: manage current_ref within do_one_ref()
  refs.c: reorder definitions more logically
This commit is contained in:
Junio C Hamano 2012-04-24 14:40:28 -07:00
commit 5e69491bf2
2 changed files with 670 additions and 374 deletions

1037
refs.c

File diff suppressed because it is too large Load Diff

7
refs.h
View File

@ -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 *);