merge(third_party/git): Merge squashed git subtree at v2.23.0
Merge commit '1b593e1ea4' as 'third_party/git'
This commit is contained in:
commit
7ef0d62730
3629 changed files with 1139935 additions and 0 deletions
1
third_party/git/contrib/coccinelle/.gitignore
vendored
Normal file
1
third_party/git/contrib/coccinelle/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
*.patch*
|
||||
43
third_party/git/contrib/coccinelle/README
vendored
Normal file
43
third_party/git/contrib/coccinelle/README
vendored
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
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.
|
||||
90
third_party/git/contrib/coccinelle/array.cocci
vendored
Normal file
90
third_party/git/contrib/coccinelle/array.cocci
vendored
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
@@
|
||||
expression dst, src, n, E;
|
||||
@@
|
||||
memcpy(dst, src, n * sizeof(
|
||||
- E[...]
|
||||
+ *(E)
|
||||
))
|
||||
|
||||
@@
|
||||
type T;
|
||||
T *ptr;
|
||||
T[] arr;
|
||||
expression E, n;
|
||||
@@
|
||||
(
|
||||
memcpy(ptr, E,
|
||||
- n * sizeof(*(ptr))
|
||||
+ n * sizeof(T)
|
||||
)
|
||||
|
|
||||
memcpy(arr, E,
|
||||
- n * sizeof(*(arr))
|
||||
+ n * sizeof(T)
|
||||
)
|
||||
|
|
||||
memcpy(E, ptr,
|
||||
- n * sizeof(*(ptr))
|
||||
+ n * sizeof(T)
|
||||
)
|
||||
|
|
||||
memcpy(E, arr,
|
||||
- n * sizeof(*(arr))
|
||||
+ n * sizeof(T)
|
||||
)
|
||||
)
|
||||
|
||||
@@
|
||||
type T;
|
||||
T *dst_ptr;
|
||||
T *src_ptr;
|
||||
T[] dst_arr;
|
||||
T[] src_arr;
|
||||
expression n;
|
||||
@@
|
||||
(
|
||||
- memcpy(dst_ptr, src_ptr, (n) * sizeof(T))
|
||||
+ COPY_ARRAY(dst_ptr, src_ptr, n)
|
||||
|
|
||||
- memcpy(dst_ptr, src_arr, (n) * sizeof(T))
|
||||
+ COPY_ARRAY(dst_ptr, src_arr, n)
|
||||
|
|
||||
- memcpy(dst_arr, src_ptr, (n) * sizeof(T))
|
||||
+ COPY_ARRAY(dst_arr, src_ptr, n)
|
||||
|
|
||||
- memcpy(dst_arr, src_arr, (n) * sizeof(T))
|
||||
+ COPY_ARRAY(dst_arr, src_arr, n)
|
||||
)
|
||||
|
||||
@@
|
||||
type T;
|
||||
T *dst;
|
||||
T *src;
|
||||
expression n;
|
||||
@@
|
||||
(
|
||||
- memmove(dst, src, (n) * sizeof(*dst));
|
||||
+ MOVE_ARRAY(dst, src, n);
|
||||
|
|
||||
- memmove(dst, src, (n) * sizeof(*src));
|
||||
+ MOVE_ARRAY(dst, src, n);
|
||||
|
|
||||
- memmove(dst, src, (n) * sizeof(T));
|
||||
+ MOVE_ARRAY(dst, src, n);
|
||||
)
|
||||
|
||||
@@
|
||||
type T;
|
||||
T *ptr;
|
||||
expression n;
|
||||
@@
|
||||
- ptr = xmalloc((n) * sizeof(*ptr));
|
||||
+ ALLOC_ARRAY(ptr, n);
|
||||
|
||||
@@
|
||||
type T;
|
||||
T *ptr;
|
||||
expression n;
|
||||
@@
|
||||
- ptr = xmalloc((n) * sizeof(T));
|
||||
+ ALLOC_ARRAY(ptr, n);
|
||||
34
third_party/git/contrib/coccinelle/commit.cocci
vendored
Normal file
34
third_party/git/contrib/coccinelle/commit.cocci
vendored
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
@@
|
||||
expression c;
|
||||
@@
|
||||
- &c->maybe_tree->object.oid
|
||||
+ get_commit_tree_oid(c)
|
||||
|
||||
@@
|
||||
expression c;
|
||||
@@
|
||||
- c->maybe_tree->object.oid.hash
|
||||
+ get_commit_tree_oid(c)->hash
|
||||
|
||||
@@
|
||||
identifier f !~ "^set_commit_tree$";
|
||||
expression c;
|
||||
expression s;
|
||||
@@
|
||||
f(...) {<...
|
||||
- c->maybe_tree = s
|
||||
+ set_commit_tree(c, s)
|
||||
...>}
|
||||
|
||||
// These excluded functions must access c->maybe_tree direcly.
|
||||
// Note that if c->maybe_tree is written somewhere outside of these
|
||||
// functions, then the recommended transformation will be bogus with
|
||||
// repo_get_commit_tree() on the LHS.
|
||||
@@
|
||||
identifier f !~ "^(repo_get_commit_tree|get_commit_tree_in_graph_one|load_tree_for_commit|set_commit_tree)$";
|
||||
expression c;
|
||||
@@
|
||||
f(...) {<...
|
||||
- c->maybe_tree
|
||||
+ repo_get_commit_tree(specify_the_right_repo_here, c)
|
||||
...>}
|
||||
13
third_party/git/contrib/coccinelle/flex_alloc.cocci
vendored
Normal file
13
third_party/git/contrib/coccinelle/flex_alloc.cocci
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
@@
|
||||
expression str;
|
||||
identifier x, flexname;
|
||||
@@
|
||||
- FLEX_ALLOC_MEM(x, flexname, str, strlen(str));
|
||||
+ FLEX_ALLOC_STR(x, flexname, str);
|
||||
|
||||
@@
|
||||
expression str;
|
||||
identifier x, ptrname;
|
||||
@@
|
||||
- FLEXPTR_ALLOC_MEM(x, ptrname, str, strlen(str));
|
||||
+ FLEXPTR_ALLOC_STR(x, ptrname, str);
|
||||
18
third_party/git/contrib/coccinelle/free.cocci
vendored
Normal file
18
third_party/git/contrib/coccinelle/free.cocci
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
@@
|
||||
expression E;
|
||||
@@
|
||||
- if (E)
|
||||
free(E);
|
||||
|
||||
@@
|
||||
expression E;
|
||||
@@
|
||||
- if (!E)
|
||||
free(E);
|
||||
|
||||
@@
|
||||
expression E;
|
||||
@@
|
||||
- free(E);
|
||||
+ FREE_AND_NULL(E);
|
||||
- E = NULL;
|
||||
119
third_party/git/contrib/coccinelle/object_id.cocci
vendored
Normal file
119
third_party/git/contrib/coccinelle/object_id.cocci
vendored
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
@@
|
||||
struct object_id OID;
|
||||
@@
|
||||
- is_null_sha1(OID.hash)
|
||||
+ is_null_oid(&OID)
|
||||
|
||||
@@
|
||||
struct object_id *OIDPTR;
|
||||
@@
|
||||
- is_null_sha1(OIDPTR->hash)
|
||||
+ is_null_oid(OIDPTR)
|
||||
|
||||
@@
|
||||
struct object_id OID;
|
||||
@@
|
||||
- sha1_to_hex(OID.hash)
|
||||
+ oid_to_hex(&OID)
|
||||
|
||||
@@
|
||||
identifier f != oid_to_hex;
|
||||
struct object_id *OIDPTR;
|
||||
@@
|
||||
f(...) {<...
|
||||
- sha1_to_hex(OIDPTR->hash)
|
||||
+ oid_to_hex(OIDPTR)
|
||||
...>}
|
||||
|
||||
@@
|
||||
expression E;
|
||||
struct object_id OID;
|
||||
@@
|
||||
- sha1_to_hex_r(E, OID.hash)
|
||||
+ oid_to_hex_r(E, &OID)
|
||||
|
||||
@@
|
||||
identifier f != oid_to_hex_r;
|
||||
expression E;
|
||||
struct object_id *OIDPTR;
|
||||
@@
|
||||
f(...) {<...
|
||||
- sha1_to_hex_r(E, OIDPTR->hash)
|
||||
+ oid_to_hex_r(E, OIDPTR)
|
||||
...>}
|
||||
|
||||
@@
|
||||
struct object_id OID;
|
||||
@@
|
||||
- hashclr(OID.hash)
|
||||
+ oidclr(&OID)
|
||||
|
||||
@@
|
||||
identifier f != oidclr;
|
||||
struct object_id *OIDPTR;
|
||||
@@
|
||||
f(...) {<...
|
||||
- hashclr(OIDPTR->hash)
|
||||
+ oidclr(OIDPTR)
|
||||
...>}
|
||||
|
||||
@@
|
||||
struct object_id OID1, OID2;
|
||||
@@
|
||||
- hashcmp(OID1.hash, OID2.hash)
|
||||
+ oidcmp(&OID1, &OID2)
|
||||
|
||||
@@
|
||||
identifier f != oidcmp;
|
||||
struct object_id *OIDPTR1, OIDPTR2;
|
||||
@@
|
||||
f(...) {<...
|
||||
- hashcmp(OIDPTR1->hash, OIDPTR2->hash)
|
||||
+ oidcmp(OIDPTR1, OIDPTR2)
|
||||
...>}
|
||||
|
||||
@@
|
||||
struct object_id *OIDPTR;
|
||||
struct object_id OID;
|
||||
@@
|
||||
- hashcmp(OIDPTR->hash, OID.hash)
|
||||
+ oidcmp(OIDPTR, &OID)
|
||||
|
||||
@@
|
||||
struct object_id *OIDPTR;
|
||||
struct object_id OID;
|
||||
@@
|
||||
- hashcmp(OID.hash, OIDPTR->hash)
|
||||
+ oidcmp(&OID, OIDPTR)
|
||||
|
||||
@@
|
||||
struct object_id *OIDPTR1;
|
||||
struct object_id *OIDPTR2;
|
||||
@@
|
||||
- oidcmp(OIDPTR1, OIDPTR2) == 0
|
||||
+ oideq(OIDPTR1, OIDPTR2)
|
||||
|
||||
@@
|
||||
identifier f != hasheq;
|
||||
expression E1, E2;
|
||||
@@
|
||||
f(...) {<...
|
||||
- hashcmp(E1, E2) == 0
|
||||
+ hasheq(E1, E2)
|
||||
...>}
|
||||
|
||||
@@
|
||||
struct object_id *OIDPTR1;
|
||||
struct object_id *OIDPTR2;
|
||||
@@
|
||||
- oidcmp(OIDPTR1, OIDPTR2) != 0
|
||||
+ !oideq(OIDPTR1, OIDPTR2)
|
||||
|
||||
@@
|
||||
identifier f != hasheq;
|
||||
expression E1, E2;
|
||||
@@
|
||||
f(...) {<...
|
||||
- hashcmp(E1, E2) != 0
|
||||
+ !hasheq(E1, E2)
|
||||
...>}
|
||||
5
third_party/git/contrib/coccinelle/preincr.cocci
vendored
Normal file
5
third_party/git/contrib/coccinelle/preincr.cocci
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
@ preincrement @
|
||||
identifier i;
|
||||
@@
|
||||
- ++i > 1
|
||||
+ i++
|
||||
37
third_party/git/contrib/coccinelle/qsort.cocci
vendored
Normal file
37
third_party/git/contrib/coccinelle/qsort.cocci
vendored
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
@@
|
||||
expression base, nmemb, compar;
|
||||
@@
|
||||
- qsort(base, nmemb, sizeof(*base), compar);
|
||||
+ QSORT(base, nmemb, compar);
|
||||
|
||||
@@
|
||||
expression base, nmemb, compar;
|
||||
@@
|
||||
- qsort(base, nmemb, sizeof(base[0]), compar);
|
||||
+ QSORT(base, nmemb, compar);
|
||||
|
||||
@@
|
||||
type T;
|
||||
T *base;
|
||||
expression nmemb, compar;
|
||||
@@
|
||||
- qsort(base, nmemb, sizeof(T), compar);
|
||||
+ QSORT(base, nmemb, compar);
|
||||
|
||||
@@
|
||||
expression base, nmemb, compar;
|
||||
@@
|
||||
- if (nmemb)
|
||||
QSORT(base, nmemb, compar);
|
||||
|
||||
@@
|
||||
expression base, nmemb, compar;
|
||||
@@
|
||||
- if (nmemb > 0)
|
||||
QSORT(base, nmemb, compar);
|
||||
|
||||
@@
|
||||
expression base, nmemb, compar;
|
||||
@@
|
||||
- if (nmemb > 1)
|
||||
QSORT(base, nmemb, compar);
|
||||
62
third_party/git/contrib/coccinelle/strbuf.cocci
vendored
Normal file
62
third_party/git/contrib/coccinelle/strbuf.cocci
vendored
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
@ strbuf_addf_with_format_only @
|
||||
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);
|
||||
28
third_party/git/contrib/coccinelle/swap.cocci
vendored
Normal file
28
third_party/git/contrib/coccinelle/swap.cocci
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
@ swap_with_declaration @
|
||||
type T;
|
||||
identifier tmp;
|
||||
T a, b;
|
||||
@@
|
||||
- T tmp = a;
|
||||
+ T tmp;
|
||||
+ tmp = a;
|
||||
a = b;
|
||||
b = tmp;
|
||||
|
||||
@ swap @
|
||||
type T;
|
||||
T tmp, a, b;
|
||||
@@
|
||||
- tmp = a;
|
||||
- a = b;
|
||||
- b = tmp;
|
||||
+ SWAP(a, b);
|
||||
|
||||
@ extends swap @
|
||||
identifier unused;
|
||||
@@
|
||||
{
|
||||
...
|
||||
- T unused;
|
||||
... when != unused
|
||||
}
|
||||
144
third_party/git/contrib/coccinelle/the_repository.pending.cocci
vendored
Normal file
144
third_party/git/contrib/coccinelle/the_repository.pending.cocci
vendored
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
// This file is used for the ongoing refactoring of
|
||||
// bringing the index or repository struct in all of
|
||||
// our code base.
|
||||
|
||||
@@
|
||||
expression E;
|
||||
expression F;
|
||||
expression G;
|
||||
@@
|
||||
- read_object_file(
|
||||
+ repo_read_object_file(the_repository,
|
||||
E, F, G)
|
||||
|
||||
@@
|
||||
expression E;
|
||||
@@
|
||||
- has_sha1_file(
|
||||
+ repo_has_sha1_file(the_repository,
|
||||
E)
|
||||
|
||||
@@
|
||||
expression E;
|
||||
expression F;
|
||||
@@
|
||||
- has_sha1_file_with_flags(
|
||||
+ repo_has_sha1_file_with_flags(the_repository,
|
||||
E)
|
||||
|
||||
@@
|
||||
expression E;
|
||||
@@
|
||||
- has_object_file(
|
||||
+ repo_has_object_file(the_repository,
|
||||
E)
|
||||
|
||||
@@
|
||||
expression E;
|
||||
expression F;
|
||||
@@
|
||||
- has_object_file_with_flags(
|
||||
+ repo_has_object_file_with_flags(the_repository,
|
||||
E)
|
||||
|
||||
@@
|
||||
expression E;
|
||||
expression F;
|
||||
expression G;
|
||||
@@
|
||||
- parse_commit_internal(
|
||||
+ repo_parse_commit_internal(the_repository,
|
||||
E, F, G)
|
||||
|
||||
@@
|
||||
expression E;
|
||||
expression F;
|
||||
@@
|
||||
- parse_commit_gently(
|
||||
+ repo_parse_commit_gently(the_repository,
|
||||
E, F)
|
||||
|
||||
@@
|
||||
expression E;
|
||||
@@
|
||||
- parse_commit(
|
||||
+ repo_parse_commit(the_repository,
|
||||
E)
|
||||
|
||||
@@
|
||||
expression E;
|
||||
expression F;
|
||||
@@
|
||||
- get_merge_bases(
|
||||
+ repo_get_merge_bases(the_repository,
|
||||
E, F);
|
||||
|
||||
@@
|
||||
expression E;
|
||||
expression F;
|
||||
expression G;
|
||||
@@
|
||||
- get_merge_bases_many(
|
||||
+ repo_get_merge_bases_many(the_repository,
|
||||
E, F, G);
|
||||
|
||||
@@
|
||||
expression E;
|
||||
expression F;
|
||||
expression G;
|
||||
@@
|
||||
- get_merge_bases_many_dirty(
|
||||
+ repo_get_merge_bases_many_dirty(the_repository,
|
||||
E, F, G);
|
||||
|
||||
@@
|
||||
expression E;
|
||||
expression F;
|
||||
@@
|
||||
- in_merge_bases(
|
||||
+ repo_in_merge_bases(the_repository,
|
||||
E, F);
|
||||
|
||||
@@
|
||||
expression E;
|
||||
expression F;
|
||||
expression G;
|
||||
@@
|
||||
- in_merge_bases_many(
|
||||
+ repo_in_merge_bases_many(the_repository,
|
||||
E, F, G);
|
||||
|
||||
@@
|
||||
expression E;
|
||||
expression F;
|
||||
@@
|
||||
- get_commit_buffer(
|
||||
+ repo_get_commit_buffer(the_repository,
|
||||
E, F);
|
||||
|
||||
@@
|
||||
expression E;
|
||||
expression F;
|
||||
@@
|
||||
- unuse_commit_buffer(
|
||||
+ repo_unuse_commit_buffer(the_repository,
|
||||
E, F);
|
||||
|
||||
@@
|
||||
expression E;
|
||||
expression F;
|
||||
expression G;
|
||||
@@
|
||||
- logmsg_reencode(
|
||||
+ repo_logmsg_reencode(the_repository,
|
||||
E, F, G);
|
||||
|
||||
@@
|
||||
expression E;
|
||||
expression F;
|
||||
expression G;
|
||||
expression H;
|
||||
@@
|
||||
- format_commit_message(
|
||||
+ repo_format_commit_message(the_repository,
|
||||
E, F, G, H);
|
||||
13
third_party/git/contrib/coccinelle/xstrdup_or_null.cocci
vendored
Normal file
13
third_party/git/contrib/coccinelle/xstrdup_or_null.cocci
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
@@
|
||||
expression E;
|
||||
expression V;
|
||||
@@
|
||||
- if (E)
|
||||
- V = xstrdup(E);
|
||||
+ V = xstrdup_or_null(E);
|
||||
|
||||
@@
|
||||
expression E;
|
||||
@@
|
||||
- xstrdup(absolute_path(E))
|
||||
+ absolute_pathdup(E)
|
||||
Loading…
Add table
Add a link
Reference in a new issue