aboutsummaryrefslogtreecommitdiff
path: root/Documentation
diff options
context:
space:
mode:
authorLucas Seiki Oshiro <lucasseikioshiro@gmail.com>2026-02-25 13:32:10 -0300
committerJunio C Hamano <gitster@pobox.com>2026-02-25 11:47:41 -0800
commitc63e64e04d43ebdc04204a052858c4801c018e1e (patch)
tree3b52a1093242c430cd65c29f739b8992658a5baa /Documentation
parent02a0d297a113fbf011625ef2b6a49ff8c6dde7e5 (diff)
downloadgit-c63e64e04d43ebdc04204a052858c4801c018e1e.tar.xz
CodingGuidelines: instruct to name arrays in singular
Arrays should be named in the singular form, ensuring that when accessing an element within an array (e.g. dog[0]) it's clear that we're referring to an element instead of a collection. Add a new rule to CodingGuidelines asking for arrays to be named in singular instead of plural. Helped-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'Documentation')
-rw-r--r--Documentation/CodingGuidelines13
1 files changed, 13 insertions, 0 deletions
diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
index df72fe0177..278083526d 100644
--- a/Documentation/CodingGuidelines
+++ b/Documentation/CodingGuidelines
@@ -656,6 +656,19 @@ For C programs:
unsigned other_field:1;
unsigned field_with_longer_name:1;
+ - Array names should be named in the singular form if the individual items are
+ subject of use. E.g.:
+
+ char *dog[] = ...;
+ walk_dog(dog[0]);
+ walk_dog(dog[1]);
+
+ Cases where the array is employed as a whole rather than as its unit parts,
+ the plural forms is preferable. E.g:
+
+ char *dogs[] = ...;
+ walk_all_dogs(dogs);
+
For Perl programs:
- Most of the C guidelines above apply.