diff options
author | Russell Belfer <arrbee@arrbee.com> | 2012-01-11 20:41:55 -0800 |
---|---|---|
committer | Russell Belfer <arrbee@arrbee.com> | 2012-01-11 20:41:55 -0800 |
commit | 0cfcff5daac50d5a4ba41d5125b108cdfceed832 (patch) | |
tree | f878699e76c530f5e7556020d11bcee97460d7a9 /src/ignore.c | |
parent | 15debaf5da2821e6f97038218b46d9fb3c755631 (diff) | |
download | libgit2-0cfcff5daac50d5a4ba41d5125b108cdfceed832.tar.gz |
Convert git_path_walk_up to regular function
This gets rid of the crazy macro version of git_path_walk_up
and makes it into a normal function that takes a callback
parameter. This turned out not to be too messy.
Diffstat (limited to 'src/ignore.c')
-rw-r--r-- | src/ignore.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/ignore.c b/src/ignore.c index 7639b7ba9..fa71d4941 100644 --- a/src/ignore.c +++ b/src/ignore.c @@ -64,12 +64,24 @@ static int load_ignore_file( #define push_ignore(R,S,B,F) \ git_attr_cache__push_file((R),(S),(B),(F),load_ignore_file) +typedef struct { + git_repository *repo; + git_vector *stack; +} ignore_walk_up_info; + +static int push_one_ignore(void *ref, git_buf *path) +{ + ignore_walk_up_info *info = (ignore_walk_up_info *)ref; + return push_ignore(info->repo, info->stack, path->ptr, GIT_IGNORE_FILE); +} + int git_ignore__for_path(git_repository *repo, const char *path, git_vector *stack) { int error = GIT_SUCCESS; - git_buf dir = GIT_BUF_INIT, scan; + git_buf dir = GIT_BUF_INIT; git_config *cfg; const char *workdir = git_repository_workdir(repo); + ignore_walk_up_info info; if ((error = git_attr_cache__init(repo)) < GIT_SUCCESS) goto cleanup; @@ -82,11 +94,9 @@ int git_ignore__for_path(git_repository *repo, const char *path, git_vector *sta goto cleanup; /* load .gitignore up the path */ - git_path_walk_up(&dir, &scan, workdir, { - error = push_ignore(repo, stack, scan.ptr, GIT_IGNORE_FILE); - if (error < GIT_SUCCESS) break; - }); - if (error < GIT_SUCCESS) + info.repo = repo; + info.stack = stack; + if ((error = git_path_walk_up(&dir, workdir, push_one_ignore, &info)) < GIT_SUCCESS) goto cleanup; /* load .git/info/exclude */ |