]>
git.ipfire.org Git - thirdparty/git.git/blob - diffcore-pathspec.c
2 * Copyright (C) 2005 Junio C Hamano
14 static int matches_pathspec(const char *name
, struct path_spec
*s
, int cnt
)
22 namelen
= strlen(name
);
23 for (i
= 0; i
< cnt
; i
++) {
25 if (! strncmp(s
[i
].spec
, name
, len
) &&
27 (name
[len
] == 0 || name
[len
] == '/'))
33 void diffcore_pathspec(const char **pathspec
)
35 struct diff_queue_struct
*q
= &diff_queued_diff
;
37 struct diff_queue_struct outq
;
38 struct path_spec
*spec
;
41 outq
.nr
= outq
.alloc
= 0;
43 for (i
= 0; pathspec
[i
]; i
++)
46 spec
= xmalloc(sizeof(*spec
) * speccnt
);
47 for (i
= 0; pathspec
[i
]; i
++) {
49 spec
[i
].spec
= pathspec
[i
];
50 l
= strlen(pathspec
[i
]);
51 while (l
> 0 && pathspec
[i
][l
-1] == '/')
56 for (i
= 0; i
< q
->nr
; i
++) {
57 struct diff_filepair
*p
= q
->queue
[i
];
58 if (matches_pathspec(p
->two
->path
, spec
, speccnt
))
61 diff_free_filepair(p
);