]> git.ipfire.org Git - thirdparty/git.git/blob - contrib/coccinelle/config_fn_ctx.pending.cocci
Merge branch 'ms/send-email-validate-fix'
[thirdparty/git.git] / contrib / coccinelle / config_fn_ctx.pending.cocci
1 @ get_fn @
2 identifier fn, R;
3 @@
4 (
5 (
6 git_config_from_file
7 |
8 git_config_from_file_with_options
9 |
10 git_config_from_mem
11 |
12 git_config_from_blob_oid
13 |
14 read_early_config
15 |
16 read_very_early_config
17 |
18 config_with_options
19 |
20 git_config
21 |
22 git_protected_config
23 |
24 config_from_gitmodules
25 )
26 (fn, ...)
27 |
28 repo_config(R, fn, ...)
29 )
30
31 @ extends get_fn @
32 identifier C1, C2, D;
33 @@
34 int fn(const char *C1, const char *C2,
35 + const struct config_context *ctx,
36 void *D);
37
38 @ extends get_fn @
39 @@
40 int fn(const char *, const char *,
41 + const struct config_context *,
42 void *);
43
44 @ extends get_fn @
45 // Don't change fns that look like callback fns but aren't
46 identifier fn2 != tar_filter_config && != git_diff_heuristic_config &&
47 != git_default_submodule_config && != git_color_config &&
48 != bundle_list_update && != parse_object_filter_config;
49 identifier C1, C2, D1, D2, S;
50 attribute name UNUSED;
51 @@
52 int fn(const char *C1, const char *C2,
53 + const struct config_context *ctx,
54 void *D1) {
55 <+...
56 (
57 fn2(C1, C2
58 + , ctx
59 , D2);
60 |
61 if(fn2(C1, C2
62 + , ctx
63 , D2) < 0) { ... }
64 |
65 return fn2(C1, C2
66 + , ctx
67 , D2);
68 |
69 S = fn2(C1, C2
70 + , ctx
71 , D2);
72 )
73 ...+>
74 }
75
76 @ extends get_fn@
77 identifier C1, C2, D;
78 attribute name UNUSED;
79 @@
80 int fn(const char *C1, const char *C2,
81 + const struct config_context *ctx UNUSED,
82 void *D) {...}
83
84
85 // The previous rules don't catch all callbacks, especially if they're defined
86 // in a separate file from the git_config() call. Fix these manually.
87 @@
88 identifier C1, C2, D;
89 attribute name UNUSED;
90 @@
91 int
92 (
93 git_ident_config
94 |
95 urlmatch_collect_fn
96 |
97 write_one_config
98 |
99 forbid_remote_url
100 |
101 credential_config_callback
102 )
103 (const char *C1, const char *C2,
104 + const struct config_context *ctx UNUSED,
105 void *D) {...}
106
107 @@
108 identifier C1, C2, D, D2, S, fn2;
109 @@
110 int
111 (
112 http_options
113 |
114 git_status_config
115 |
116 git_commit_config
117 |
118 git_default_core_config
119 |
120 grep_config
121 )
122 (const char *C1, const char *C2,
123 + const struct config_context *ctx,
124 void *D) {
125 <+...
126 (
127 fn2(C1, C2
128 + , ctx
129 , D2);
130 |
131 if(fn2(C1, C2
132 + , ctx
133 , D2) < 0) { ... }
134 |
135 return fn2(C1, C2
136 + , ctx
137 , D2);
138 |
139 S = fn2(C1, C2
140 + , ctx
141 , D2);
142 )
143 ...+>
144 }