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
++) {
26 if (memcmp(s
[i
].spec
, name
, len
))
28 if (s
[i
].spec
[len
-1] == '/' ||
38 void diffcore_pathspec(const char **pathspec
)
40 struct diff_queue_struct
*q
= &diff_queued_diff
;
42 struct diff_queue_struct outq
;
43 struct path_spec
*spec
;
46 outq
.nr
= outq
.alloc
= 0;
48 for (i
= 0; pathspec
[i
]; i
++)
51 spec
= xmalloc(sizeof(*spec
) * speccnt
);
52 for (i
= 0; pathspec
[i
]; i
++) {
53 spec
[i
].spec
= pathspec
[i
];
54 spec
[i
].len
= strlen(pathspec
[i
]);
57 for (i
= 0; i
< q
->nr
; i
++) {
58 struct diff_filepair
*p
= q
->queue
[i
];
59 if (matches_pathspec(p
->two
->path
, spec
, speccnt
))
62 diff_free_filepair(p
);