blob: d261398d6c50aeefa7450b99caae23ee5cdff0d0 [file] [log] [blame]
David Reissae299be2008-05-19 23:48:54 -07001#include "cache.h"
2
3int main(int argc, char **argv)
4{
Johannes Sixtf42302b2009-02-07 16:08:30 +01005 if (argc == 3 && !strcmp(argv[1], "normalize_path_copy")) {
Johannes Schindelinb8469ad2009-01-28 00:07:36 +01006 char *buf = xmalloc(PATH_MAX + 1);
Johannes Sixtf42302b2009-02-07 16:08:30 +01007 int rv = normalize_path_copy(buf, argv[2]);
8 if (rv)
9 buf = "++failed++";
David Reissae299be2008-05-19 23:48:54 -070010 puts(buf);
Johannes Sixt2cd85c42009-02-07 16:08:27 +010011 return 0;
David Reissae299be2008-05-19 23:48:54 -070012 }
13
David Reissd553e732008-05-19 23:49:00 -070014 if (argc >= 2 && !strcmp(argv[1], "make_absolute_path")) {
15 while (argc > 2) {
16 puts(make_absolute_path(argv[2]));
17 argc--;
18 argv++;
19 }
Johannes Sixt2cd85c42009-02-07 16:08:27 +010020 return 0;
David Reissd553e732008-05-19 23:49:00 -070021 }
22
David Reiss0454dd92008-05-19 23:49:26 -070023 if (argc == 4 && !strcmp(argv[1], "longest_ancestor_length")) {
24 int len = longest_ancestor_length(argv[2], argv[3]);
25 printf("%d\n", len);
Johannes Sixt2cd85c42009-02-07 16:08:27 +010026 return 0;
David Reiss0454dd92008-05-19 23:49:26 -070027 }
28
Johannes Schindelin4fcc86b2009-02-19 20:10:49 +010029 if (argc == 4 && !strcmp(argv[1], "strip_path_suffix")) {
30 char *prefix = strip_path_suffix(argv[2], argv[3]);
31 printf("%s\n", prefix ? prefix : "(null)");
32 return 0;
33 }
34
Johannes Sixt2cd85c42009-02-07 16:08:27 +010035 fprintf(stderr, "%s: unknown function name: %s\n", argv[0],
36 argv[1] ? argv[1] : "(there was none)");
37 return 1;
David Reissae299be2008-05-19 23:48:54 -070038}