xs/PathSpec.xs

filter: Statementstmt 93.4% 43 / 46 Branchbran 81.8% 18 / 22 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 89.7% 61 / 68 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« xs/Rebase.xs ↑ Summary xs/Diff/Hunk.xs »
1 MODULE = Git::Raw PACKAGE = Git::Raw::PathSpec
2  
3 SV *
4 new(class, ...)
5 SV *class
6  
7 PROTOTYPE: $;@
8 PREINIT:
9 int i, count, rc;
10  
11 9 git_strarray paths = {NULL, 0};
12  
13 PathSpec ps;
14  
15 CODE:
16 9 ▶ if (items == 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items == 1) 1 8 9
17 1 croak_usage("No 'paths' provided");
18  
19 8 count = items - 1;
20 8 Newxz(paths.strings, count, char *);
21 17 ▶ for (i = 0; i < count; ++i) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < count; ++i) { 10 7 17
22 10 ▶ if (!SvPOK(ST(i + 1))) {
Branch: 1 branch
BranchTrueFalseTotal
if (!SvPOK(ST(i + 1))) { 1 9 10
23 1 Safefree(paths.strings);
24 1 croak_usage("Expected a string for 'path'");
25 }
26 18 paths.strings[i] = SvPVbyte_nolen(ST(i + 1));
27 }
28  
29 7 paths.count = (size_t) count;
30  
31 7 rc = git_pathspec_new(&ps, &paths);
32 7 Safefree(paths.strings);
33 7 git_check_error(rc);
34  
35 14 GIT_NEW_OBJ(
36 RETVAL, SvPVbyte_nolen(class), ps
37 );
38  
39 OUTPUT: RETVAL
40  
41 SV *
42 match(self, obj, ...)
43 PathSpec self
44 SV *obj
45  
46 PROTOTYPE: $$;$
47 PREINIT:
48 12 unsigned flags = 0;
49  
50 12 git_pathspec_match_list *list = NULL;
51  
52 CODE:
53 12 ▶ if (items == 3) {
Branch: 1 branch
BranchTrueFalseTotal
if (items == 3) { 6 6 12
54 6 HV *hopt, *opts = git_ensure_hv(ST(2), "options");
55  
56 6 ▶ if ((hopt = git_hv_hash_entry(opts, "flags"))) {
Branch: 1 branch
BranchTrueFalseTotal
if ((hopt = git_hv_hash_entry(opts, "flags"))) { 6 0 6
57 6 git_flag_opt(hopt, "ignore_case", GIT_PATHSPEC_IGNORE_CASE, &flags);
58 6 git_flag_opt(hopt, "use_case", GIT_PATHSPEC_USE_CASE, &flags);
59 6 git_flag_opt(hopt, "no_glob", GIT_PATHSPEC_NO_GLOB, &flags);
60 6 git_flag_opt(hopt, "no_match_error", GIT_PATHSPEC_NO_MATCH_ERROR, &flags);
61 6 git_flag_opt(hopt, "find_failures", GIT_PATHSPEC_FIND_FAILURES, &flags);
62 6 git_flag_opt(hopt, "failures_only", GIT_PATHSPEC_FAILURES_ONLY, &flags);
63 }
64 }
65  
66 12 ▶ if (sv_isobject(obj)) {
Branch: 1 branch
BranchTrueFalseTotal
if (sv_isobject(obj)) { 11 1 12
67 11 int rc = 0;
68  
69 11 ▶ if (sv_derived_from(obj, "Git::Raw::Repository")) {
Branch: 1 branch
BranchTrueFalseTotal
if (sv_derived_from(obj, "Git::Raw::Repository")) { 6 5 11
70 6 Repository repo = GIT_SV_TO_PTR(Repository, obj);
71 6 rc = git_pathspec_match_workdir(
72 &list,
73 repo -> repository,
74 flags, self);
75 5 ▶ } else if (sv_derived_from(obj, "Git::Raw::Index")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (sv_derived_from(obj, "Git::Raw::Index")) { 1 4 5
76 1 rc = git_pathspec_match_index(
77 &list,
78 1 GIT_SV_TO_PTR(Index, obj),
79 flags, self);
80 4 ▶ } else if (sv_derived_from(obj, "Git::Raw::Tree")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (sv_derived_from(obj, "Git::Raw::Tree")) { 4 0 4
81 4 rc = git_pathspec_match_tree(
82 &list,
83 4 GIT_SV_TO_PTR(Tree, obj),
84 flags, self);
85 0 ▶ } else if (sv_derived_from(obj, "Git::Raw::Diff")) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (sv_derived_from(obj, "Git::Raw::Diff")) { 0 0 0
86 0 rc = git_pathspec_match_diff(
87 &list,
88 0 GIT_SV_TO_PTR(Diff, obj),
89 flags, self);
90 }
91 11 git_check_error(rc);
92 }
93  
94 11 ▶ if (list == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if (list == NULL) 1 10 11
95 1 croak_usage("Expected a 'Git::Raw::Repository', 'Git::Raw::Index', "
96 "'Git::Raw::Tree' or 'Git::Raw::Diff' object");
97  
98 10 GIT_NEW_OBJ(
99 RETVAL, "Git::Raw::PathSpec::MatchList", list
100 );
101  
102 OUTPUT: RETVAL
103  
104 void
105 DESTROY(self)
106 SV *self
107  
108 PREINIT:
109 PathSpec ps;
110  
111 CODE:
112 7 ps = GIT_SV_TO_PTR(PathSpec, self);
113 7 git_pathspec_free(ps);
« xs/Rebase.xs ↑ Summary xs/Diff/Hunk.xs »