longest_ancestor_length(): take a string_list argument for prefixes
Change longest_ancestor_length() to take the prefixes argument as a string_list rather than as a colon-separated string. This will make it easier for the caller to alter the entries before calling longest_ancestor_length(). Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Jeff King <peff@peff.net>
This commit is contained in:

committed by
Jeff King

parent
a5ccdbe416
commit
31171d9e45
@ -1,4 +1,5 @@
|
||||
#include "cache.h"
|
||||
#include "string-list.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
@ -30,7 +31,12 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (argc == 4 && !strcmp(argv[1], "longest_ancestor_length")) {
|
||||
int len = longest_ancestor_length(argv[2], argv[3]);
|
||||
int len;
|
||||
struct string_list ceiling_dirs = STRING_LIST_INIT_DUP;
|
||||
|
||||
string_list_split(&ceiling_dirs, argv[3], PATH_SEP, -1);
|
||||
len = longest_ancestor_length(argv[2], &ceiling_dirs);
|
||||
string_list_clear(&ceiling_dirs, 0);
|
||||
printf("%d\n", len);
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user