aboutsummaryrefslogtreecommitdiff
path: root/tools/coccinelle/strbuf.cocci
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2026-03-27 11:00:01 -0700
committerJunio C Hamano <gitster@pobox.com>2026-03-27 11:00:01 -0700
commitd1f07dd50087bef18246feffb963d73b23e2cdd6 (patch)
tree818b60e53f48bf6112eb0e834ef63a777f83de6b /tools/coccinelle/strbuf.cocci
parentebd8fa7e1291e4f82992db763e271ca261dd750b (diff)
parent671df48df895fdf259b48a7f90b70b7c75fc4059 (diff)
downloadgit-d1f07dd50087bef18246feffb963d73b23e2cdd6.tar.xz
Merge branch 'ps/build-tweaks'
Tweak the build infrastructure by moving tools around. * ps/build-tweaks: meson: precompile "git-compat-util.h" meson: compile compatibility sources separately git-compat-util.h: move warning infra to prepare for PCHs builds: move build scripts into "tools/" contrib: move "update-unicode.sh" script into "tools/" contrib: move "coverage-diff.sh" script into "tools/" contrib: move "coccinelle/" directory into "tools/" Introduce new "tools/" directory
Diffstat (limited to 'tools/coccinelle/strbuf.cocci')
-rw-r--r--tools/coccinelle/strbuf.cocci73
1 files changed, 73 insertions, 0 deletions
diff --git a/tools/coccinelle/strbuf.cocci b/tools/coccinelle/strbuf.cocci
new file mode 100644
index 0000000000..83bd93be5f
--- /dev/null
+++ b/tools/coccinelle/strbuf.cocci
@@ -0,0 +1,73 @@
+@@
+expression E;
+constant fmt !~ "%";
+@@
+- strbuf_addf
++ strbuf_addstr
+ (E,
+(
+ fmt
+|
+ _(fmt)
+)
+ );
+
+@@
+expression E;
+struct strbuf SB;
+format F =~ "^s$";
+@@
+- strbuf_addf(E, "%@F@", SB.buf);
++ strbuf_addbuf(E, &SB);
+
+@@
+expression E;
+struct strbuf *SBP;
+format F =~ "^s$";
+@@
+- strbuf_addf(E, "%@F@", SBP->buf);
++ strbuf_addbuf(E, SBP);
+
+@@
+expression E;
+struct strbuf SB;
+@@
+- strbuf_addstr(E, SB.buf);
++ strbuf_addbuf(E, &SB);
+
+@@
+expression E;
+struct strbuf *SBP;
+@@
+- strbuf_addstr(E, SBP->buf);
++ strbuf_addbuf(E, SBP);
+
+@@
+expression E1, E2;
+format F =~ "^s$";
+@@
+- strbuf_addf(E1, "%@F@", E2);
++ strbuf_addstr(E1, E2);
+
+@@
+expression E1, E2, E3;
+@@
+- strbuf_addstr(E1, find_unique_abbrev(E2, E3));
++ strbuf_add_unique_abbrev(E1, E2, E3);
+
+@@
+expression E1, E2;
+@@
+- strbuf_addstr(E1, real_path(E2));
++ strbuf_add_real_path(E1, E2);
+
+@@
+identifier fn, param;
+@@
+ fn(...,
+- struct strbuf param
++ struct strbuf *param
+ ,...)
+ {
+ ...
+ }