forked from msysgit/git
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test-tool: add the
path-walk
subcommand
This is currently primarily here for me to test out a couple of ideas or to investigate how this path walk API thing works. Signed-off-by: Johannes Schindelin <[email protected]>
- Loading branch information
Showing
4 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#define USE_THE_REPOSITORY_VARIABLE | ||
|
||
#include "test-tool.h" | ||
#include "git-compat-util.h" | ||
#include "parse-options.h" | ||
#include "setup.h" | ||
#include "revision.h" | ||
#include "path-walk.h" | ||
#include "oid-array.h" | ||
#include "hex.h" | ||
|
||
static const char * const path_walk_usage[] = { | ||
N_("test-tool path-walk <options>"), | ||
NULL | ||
}; | ||
|
||
static int verbose; | ||
|
||
static int callback_fn(const char *path, | ||
struct oid_array *list, | ||
enum object_type type, | ||
void *data) | ||
{ | ||
printf("visiting path '%s' (count: %"PRIuMAX") of type '%s'\n", | ||
Check failure on line 24 in t/helper/test-path-walk.c GitHub Actions / linux32 (daald/ubuntu32:xenial)
|
||
path, list->nr, type_name(type)); | ||
if (verbose) | ||
for (size_t i = 0; i < list->nr; i++) | ||
printf("\t%s\n", oid_to_hex(list->oid + i)); | ||
|
||
return 0; | ||
} | ||
|
||
int cmd__path_walk(int argc, const char **argv) | ||
{ | ||
struct rev_info revs; | ||
struct path_walk_info info = PATH_WALK_INFO_INIT; | ||
struct option options[] = { | ||
OPT_BOOL(0, "tags", &info.tags, N_("walk tags")), | ||
OPT_BOOL(0, "commits", &info.commits, N_("walk commits")), | ||
OPT_BOOL(0, "trees", &info.trees, N_("walk trees")), | ||
OPT_BOOL(0, "blobs", &info.blobs, N_("walk blobs")), | ||
OPT__VERBOSE(&verbose, N_("verbose")), | ||
OPT_END(), | ||
}; | ||
int ret = 0; | ||
|
||
if (argc == 2 && !strcmp(argv[1], "-h")) | ||
usage_with_options(path_walk_usage, options); | ||
|
||
argc = parse_options(argc, argv, NULL, options, path_walk_usage, | ||
PARSE_OPT_KEEP_ARGV0); | ||
|
||
setup_git_directory(); | ||
|
||
repo_init_revisions(the_repository, &revs, ""); | ||
setup_revisions(argc, argv, &revs, NULL); | ||
|
||
info.revs = &revs; | ||
info.path_fn = callback_fn; | ||
|
||
ret = walk_objects_by_path(&info); | ||
|
||
reset_revision_walk(); | ||
release_revisions(&revs); | ||
|
||
return ret; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters