test-path-utils: Add subcommand "prefix_path"

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Michael Haggerty committed Aug 4, 2011 at 06:47 UTC 9e8137238d1b7f558dd61c8737883e73c8368e4b
1 file changed +13
test-path-utils.c
+13
@@ -35,6 +35,19 @@ int main(int argc, char **argv)
35 return 0;
36 }
37
38 + if (argc >= 4 && !strcmp(argv[1], "prefix_path")) {
39 + char *prefix = argv[2];
40 + int prefix_len = strlen(prefix);
41 + int nongit_ok;
42 + setup_git_directory_gently(&nongit_ok);
43 + while (argc > 3) {
44 + puts(prefix_path(prefix, prefix_len, argv[3]));
45 + argc--;
46 + argv++;
47 + }
48 + return 0;
49 + }
50 +
51 if (argc == 4 && !strcmp(argv[1], "strip_path_suffix")) {
52 char *prefix = strip_path_suffix(argv[2], argv[3]);
53 printf("%s\n", prefix ? prefix : "(null)");