2 #include "string-list.h"
4 int main(int argc, char **argv)
6 if (argc == 3 && !strcmp(argv[1], "normalize_path_copy")) {
7 char *buf = xmalloc(PATH_MAX + 1);
8 int rv = normalize_path_copy(buf, argv[2]);
15 if (argc >= 2 && !strcmp(argv[1], "real_path")) {
17 puts(real_path(argv[2]));
24 if (argc >= 2 && !strcmp(argv[1], "absolute_path")) {
26 puts(absolute_path(argv[2]));
33 if (argc == 4 && !strcmp(argv[1], "longest_ancestor_length")) {
35 struct string_list ceiling_dirs = STRING_LIST_INIT_DUP;
37 string_list_split(&ceiling_dirs, argv[3], PATH_SEP, -1);
38 len = longest_ancestor_length(argv[2], &ceiling_dirs);
39 string_list_clear(&ceiling_dirs, 0);
44 if (argc >= 4 && !strcmp(argv[1], "prefix_path")) {
45 char *prefix = argv[2];
46 int prefix_len = strlen(prefix);
48 setup_git_directory_gently(&nongit_ok);
50 puts(prefix_path(prefix, prefix_len, argv[3]));
57 if (argc == 4 && !strcmp(argv[1], "strip_path_suffix")) {
58 char *prefix = strip_path_suffix(argv[2], argv[3]);
59 printf("%s\n", prefix ? prefix : "(null)");
63 fprintf(stderr, "%s: unknown function name: %s\n", argv[0],
64 argv[1] ? argv[1] : "(there was none)");