2 * Copyright (C) 2005 Junio C Hamano
13 static int matches_pathspec(const char *name
, struct path_spec
*s
, int cnt
)
21 namelen
= strlen(name
);
22 for (i
= 0; i
< cnt
; i
++) {
24 if (! strncmp(s
[i
].spec
, name
, len
) &&
26 (name
[len
] == 0 || name
[len
] == '/'))
32 void diffcore_pathspec(const char **pathspec
)
34 struct diff_queue_struct
*q
= &diff_queued_diff
;
36 struct diff_queue_struct outq
;
37 struct path_spec
*spec
;
40 outq
.nr
= outq
.alloc
= 0;
42 for (i
= 0; pathspec
[i
]; i
++)
45 spec
= xmalloc(sizeof(*spec
) * speccnt
);
46 for (i
= 0; pathspec
[i
]; i
++) {
48 spec
[i
].spec
= pathspec
[i
];
49 l
= strlen(pathspec
[i
]);
50 while (l
> 0 && pathspec
[i
][l
-1] == '/')
55 for (i
= 0; i
< q
->nr
; i
++) {
56 struct diff_filepair
*p
= q
->queue
[i
];
57 if (matches_pathspec(p
->two
->path
, spec
, speccnt
))
60 diff_free_filepair(p
);