add context pointer to read_tree_recursive()

Add a pointer parameter to read_tree_recursive(), which is passed to the
callback function.  This allows callers of read_tree_recursive() to
share data with the callback without resorting to global variables.  All
current callers pass NULL.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
René Scharfe
2008-07-14 21:22:12 +02:00
committed by Junio C Hamano
parent 34533004b2
commit 671f070721
8 changed files with 28 additions and 26 deletions

View File

@ -256,7 +256,7 @@ struct tree *write_tree_from_memory(void)
static int save_files_dirs(const unsigned char *sha1,
const char *base, int baselen, const char *path,
unsigned int mode, int stage)
unsigned int mode, int stage, void *context)
{
int len = strlen(path);
char *newpath = xmalloc(baselen + len + 1);
@ -276,7 +276,7 @@ static int save_files_dirs(const unsigned char *sha1,
static int get_files_dirs(struct tree *tree)
{
int n;
if (read_tree_recursive(tree, "", 0, 0, NULL, save_files_dirs) != 0)
if (read_tree_recursive(tree, "", 0, 0, NULL, save_files_dirs, NULL))
return 0;
n = current_file_set.nr + current_directory_set.nr;
return n;