tvl-depot/third_party/git/contrib/coccinelle
Vincent Ambo f4609b896f merge(3p/git): Merge git subtree at v2.29.2
This also bumps the stable nixpkgs to 20.09 as of 2020-11-21, because
there is some breakage in the git build related to the netrc
credentials helper which someone has taken care of in nixpkgs.

The stable channel is not used for anything other than git, so this
should be fine.

Change-Id: I3575a19dab09e1e9556cf8231d717de9890484fb
2020-11-21 19:45:56 +01:00
..
.gitignore merge(third_party/git): Merge squashed git subtree at v2.23.0 2020-01-11 23:40:29 +00:00
array.cocci merge(third_party/git): Merge squashed git subtree at v2.23.0 2020-01-11 23:40:29 +00:00
commit.cocci merge(3p/git): Merge git subtree at v2.29.2 2020-11-21 19:45:56 +01:00
flex_alloc.cocci merge(third_party/git): Merge squashed git subtree at v2.23.0 2020-01-11 23:40:29 +00:00
free.cocci merge(third_party/git): Merge squashed git subtree at v2.23.0 2020-01-11 23:40:29 +00:00
hashmap.cocci merge(3p/git): Merge git subtree at v2.29.2 2020-11-21 19:45:56 +01:00
object_id.cocci merge(3p/git): Merge git subtree at v2.29.2 2020-11-21 19:45:56 +01:00
preincr.cocci merge(third_party/git): Merge squashed git subtree at v2.23.0 2020-01-11 23:40:29 +00:00
qsort.cocci merge(third_party/git): Merge squashed git subtree at v2.23.0 2020-01-11 23:40:29 +00:00
README merge(third_party/git): Merge squashed git subtree at v2.23.0 2020-01-11 23:40:29 +00:00
strbuf.cocci merge(third_party/git): Merge squashed git subtree at v2.23.0 2020-01-11 23:40:29 +00:00
swap.cocci merge(third_party/git): Merge squashed git subtree at v2.23.0 2020-01-11 23:40:29 +00:00
the_repository.pending.cocci merge(third_party/git): Merge squashed git subtree at v2.23.0 2020-01-11 23:40:29 +00:00
xstrdup_or_null.cocci merge(third_party/git): Merge squashed git subtree at v2.23.0 2020-01-11 23:40:29 +00:00

This directory provides examples of Coccinelle (http://coccinelle.lip6.fr/)
semantic patches that might be useful to developers.

There are two types of semantic patches:

 * Using the semantic transformation to check for bad patterns in the code;
   The target 'make coccicheck' is designed to check for these patterns and
   it is expected that any resulting patch indicates a regression.
   The patches resulting from 'make coccicheck' are small and infrequent,
   so once they are found, they can be sent to the mailing list as per usual.

   Example for introducing new patterns:
   67947c34ae (convert "hashcmp() != 0" to "!hasheq()", 2018-08-28)
   b84c783882 (fsck: s/++i > 1/i++/, 2018-10-24)

   Example of fixes using this approach:
   248f66ed8e (run-command: use strbuf_addstr() for adding a string to
               a strbuf, 2018-03-25)
   f919ffebed (Use MOVE_ARRAY, 2018-01-22)

   These types of semantic patches are usually part of testing, c.f.
   0860a7641b (travis-ci: fail if Coccinelle static analysis found something
               to transform, 2018-07-23)

 * Using semantic transformations in large scale refactorings throughout
   the code base.

   When applying the semantic patch into a real patch, sending it to the
   mailing list in the usual way, such a patch would be expected to have a
   lot of textual and semantic conflicts as such large scale refactorings
   change function signatures that are used widely in the code base.
   A textual conflict would arise if surrounding code near any call of such
   function changes. A semantic conflict arises when other patch series in
   flight introduce calls to such functions.

   So to aid these large scale refactorings, semantic patches can be used.
   However we do not want to store them in the same place as the checks for
   bad patterns, as then automated builds would fail.
   That is why semantic patches 'contrib/coccinelle/*.pending.cocci'
   are ignored for checks, and can be applied using 'make coccicheck-pending'.

   This allows to expose plans of pending large scale refactorings without
   impacting the bad pattern checks.