static int handle_grep_syntax(git_object **out, git_repository *repo, const git_oid *spec_oid, const char *pattern) { regex_t preg; git_revwalk *walk = NULL; int error; if ((error = build_regex(&preg, pattern)) < 0) return error; if ((error = git_revwalk_new(&walk, repo)) < 0) goto cleanup; git_revwalk_sorting(walk, GIT_SORT_TIME); if (spec_oid == NULL) { if ((error = git_revwalk_push_glob(walk, "refs/*")) < 0) goto cleanup; } else if ((error = git_revwalk_push(walk, spec_oid)) < 0) goto cleanup; error = walk_and_search(out, walk, &preg); cleanup: regfree(&preg); git_revwalk_free(walk); return error; }
static int handle_grep_syntax(git_object **out, git_repository *repo, const git_oid *spec_oid, const char *pattern) { regex_t preg; git_revwalk *walk = NULL; int error = -1; if (build_regex(&preg, pattern) < 0) return -1; if (git_revwalk_new(&walk, repo) < 0) goto cleanup; git_revwalk_sorting(walk, GIT_SORT_TIME); if (spec_oid == NULL) { // TODO: @carlosmn: The glob should be refs/* but this makes git_revwalk_next() fails if (git_revwalk_push_glob(walk, "refs/heads/*") < 0) goto cleanup; } else if (git_revwalk_push(walk, spec_oid) < 0) goto cleanup; error = walk_and_search(out, walk, &preg); cleanup: regfree(&preg); git_revwalk_free(walk); return error; }