aboutsummaryrefslogtreecommitdiff
path: root/Documentation/CodingGuidelines
Commit message (Collapse)AuthorAge
* Merge branch 'po/error-message-style'Junio C Hamano2014-07-16
|\ | | | | | | | | * po/error-message-style: doc: give some guidelines for error messages
| * doc: give some guidelines for error messagesPhilip Oakley2014-07-10
| | | | | | | | | | | | | | | | Clarify error message puntuation to reduce review workload. Signed-off-by: Philip Oakley <philipoakley@iee.org> Helped-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | CodingGuidelines: avoid "test <cond> -a/-o <cond>"Junio C Hamano2014-05-20
| | | | | | | | | | | | | | | | | | The construct is error-prone; "test" being built-in in most modern shells, the reason to avoid "test <cond> && test <cond>" spawning one extra process by using a single "test <cond> -a <cond>" no longer exists. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | CodingGuidelines: on splitting a long lineJunio C Hamano2014-05-02
| | | | | | | | Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | CodingGuidelines: on comparisonJunio C Hamano2014-05-02
| | | | | | | | | | | | | | | | | | | | There are arguments for writing a conditional as "a < b" rather than "b > a", or vice versa. Let's give guidance on which we prefer. See http://thread.gmane.org/gmane.comp.version-control.git/3903/focus=4126 for the original discussion. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | CodingGuidelines: do not call the conditional statement "if()"Junio C Hamano2014-05-02
| | | | | | | | | | | | | | The point immediately before it is about having SP after the control keyword. Spell it out as 'an "if" statement' instead. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | CodingGuidelines: give an example for shell function preambleJunio C Hamano2014-05-02
| | | | | | | | Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | CodingGuidelines: give an example for control statementsJunio C Hamano2014-05-02
| | | | | | | | Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | CodingGuidelines: give an example for redirectionJunio C Hamano2014-05-02
| | | | | | | | Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | CodingGuidelines: give an example for case/esac statementJunio C Hamano2014-05-02
| | | | | | | | Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | CodingGuidelines: once it is in, it is not worth the code churnJunio C Hamano2014-05-02
|/ | | | Signed-off-by: Junio C Hamano <gitster@pobox.com>
* i18n: mention "TRANSLATORS:" marker in Documentation/CodingGuidelinesJunio C Hamano2014-04-18
| | | | | | | | These comments have to have "TRANSLATORS: " at the very beginning and have to deviate from the usual multi-line comment formatting convention. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Merge branch 'jl/nor-or-nand-and'Junio C Hamano2014-04-08
|\ | | | | | | | | | | | | | | | | | | | | | | Eradicate mistaken use of "nor" (that is, essentially "nor" used not in "neither A nor B" ;-)) from in-code comments, command output strings, and documentations. * jl/nor-or-nand-and: code and test: fix misuses of "nor" comments: fix misuses of "nor" contrib: fix misuses of "nor" Documentation: fix misuses of "nor"
| * Documentation: fix misuses of "nor"Justin Lebar2014-03-31
| | | | | | | | | | Signed-off-by: Justin Lebar <jlebar@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * Merge branch 'jj/doc-markup-hints-in-coding-guidelines'Junio C Hamano2013-12-03
| |\ | | | | | | | | | | | | * jj/doc-markup-hints-in-coding-guidelines: State correct usage of literal examples in man pages in the coding standards
* | | CodingGuidelines: mention C whitespace rulesJeff King2014-02-28
| | | | | | | | | | | | | | | | | | | | | | | | We are fairly consistent about these, so most are covered by "follow existing style", but it doesn't hurt to be explicit. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | Merge branch 'jj/doc-markup-hints-in-coding-guidelines' into maintJunio C Hamano2013-12-17
|\ \ \ | |/ / |/| / | |/ | | * jj/doc-markup-hints-in-coding-guidelines: State correct usage of literal examples in man pages in the coding standards
| * State correct usage of literal examples in man pages in the coding standardsJason St. John2013-11-18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The man pages contain inconsistent usage of backticks vs. single quotes around options, commands, etc. that are in paragraphs. This commit states that backticks should always be used around literal examples. This commit states that "--" and friends should not be escaped (e.g. use `--pretty=oneline` instead of `\--pretty=oneline`). This commit also states correct usage for typesetting command usage examples with inline substitutions. Thanks-to: Ramkumar Ramachandra <artagnon@gmail.com> Thanks-to: Stuart Rackham <srackham@gmail.com> Thanks-to: Junio C Hamano <gitster@pobox.com> Signed-off-by: Jason St. John <jstjohn@purdue.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | CodingGuidelines: style for multi-line commentsbrian m. carlson2013-10-14
| | | | | | | | | | | | | | | | The style for multi-line comments is often mentioned and should be documented for clarity. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
* | Provide some linguistic guidance for the documentation.Marc Branchaud2013-08-01
|/ | | | | | | | | This will hopefully avoid questions over which spelling and grammar should be used. Translators are of course free to create localizations for specific English dialects. Signed-off-by: Marc Branchaud <marcnarc@xiplink.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* CodingGuidelines: Documentation/*.txt are the sourcesDale Worley2013-05-10
| | | | | | | | | People not familiar with AsciiDoc may not realize they are supposed to update *.txt files and not *.html/*.1 files when preparing patches to the project. Signed-off-by: Dale Worley <worley@ariadne.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* CodingGuidelines: our documents are in AsciiDocJunio C Hamano2013-03-21
| | | | | | | | Before talking about notations such as optional [--option] enclosed in brackets, state that the documents are in AsciiDoc and processed into other formats. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Merge branch 'tz/perl-styles'Junio C Hamano2013-02-14
|\ | | | | | | | | | | | | Add coding guidelines for writing Perl scripts for Git. * tz/perl-styles: Update CodingGuidelines for Perl
| * Update CodingGuidelines for PerlTed Zlatanov2013-02-06
| | | | | | | | | | | | | | Add the coding guidelines for Perl. Signed-off-by: Ted Zlatanov <tzz@lifelogs.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Merge branch 'jk/python-styles'Junio C Hamano2013-02-07
|\ \ | | | | | | | | | | | | * jk/python-styles: CodingGuidelines: add Python coding guidelines
| * | CodingGuidelines: add Python coding guidelinesJohn Keeping2013-01-30
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These are kept short by simply deferring to PEP-8. Most of the Python code in Git is already very close to this style (some things in contrib/ are not). Rationale for version suggestions: - Amongst the noise in [1], there isn't any disagreement about using 2.6 as a base (see also [2]), although Brandon Casey recently added support for 2.4 and 2.5 to git-p4 [3]. - Restricting ourselves to 2.6+ makes aiming for Python 3 compatibility significantly easier [4]. - Advocating Python 3 support in all scripts is currently unrealistic because: - 'p4 -G' provides output in a format that is very hard to use with Python 3 (and its documentation claims Python 3 is unsupported). - Mercurial does not support Python 3. - Bazaar does not support Python 3. - But we should try to make new scripts compatible with Python 3 because all new Python development is happening on version 3 and the Python community will eventually stop supporting Python 2 [5]. - Python 3.1 is required to support the 'surrogateescape' error handler for encoding/decodng filenames to/from Unicode strings and Python 3.0 is not longer supported. [1] http://thread.gmane.org/gmane.comp.version-control.git/210329 [2] http://article.gmane.org/gmane.comp.version-control.git/210429 [3] http://thread.gmane.org/gmane.comp.version-control.git/214579 [4] http://docs.python.org/3.3/howto/pyporting.html#try-to-support-python-2-6-and-newer-only [5] http://www.python.org/dev/peps/pep-0404/ Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Documentation: the name of the system is 'Git', not 'git'Thomas Ackermann2013-02-01
| | | | | | | | | | Signed-off-by: Thomas Ackermann <th.acker@arcor.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Documentation: avoid poor-man's small caps GITThomas Ackermann2013-02-01
|/ | | | | | | | | | | | | | In the earlier days, we used to spell the name of the system as GIT, to simulate as if it were typeset with capital G and IT in small caps. Later we stopped doing so at around 1.6.5 days. Let's stop doing so throughout the documentation. The name to refer to the whole system (and the concept it embodies) is "Git"; the command end-users type is "git". And document this in the coding guideline. Signed-off-by: Thomas Ackermann <th.acker@arcor.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Documentation: move support for old compilers to CodingGuidelinesAdam Spiers2012-12-16
| | | | | | | | The "Try to be nice to older C compilers" text is clearly a guideline to be borne in mind whilst coding rather than when submitting patches. Signed-off-by: Adam Spiers <git@adamspiers.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Documentation/CodingGuidelines: spell out more shell guidelinesHeiko Voigt2012-08-15
| | | | | | | | | | | In earlier days, "imitate the style in the neibouring code" was sufficient to keep the coherent style, but over time some parts of the codebase have drifted enough to make it ineffective. Spell some of the guidelines out. Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* CodingGuidelines: do not use 'which' in shell scriptsTim Henigan2012-02-27
| | | | | | | | | | | | During the code review of a recent patch, it was noted that shell scripts must not use 'which $cmd' to check the availability of the command $cmd. The output of the command is not machine parseable and its exit code is not reliable across platforms. It is better to use 'type' to accomplish this task. Signed-off-by: Tim Henigan <tim.henigan@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* CodingGuidelines: Add a note about spaces after redirectionTim Henigan2012-02-27
| | | | | | | | During code review of some patches, it was noted that redirection operators should have space before, but no space after them. Signed-off-by: Tim Henigan <tim.henigan@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* i18n: add infrastructure for translating Git with gettextÆvar Arnfjörð Bjarmason2011-12-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change the skeleton implementation of i18n in Git to one that can show localized strings to users for our C, Shell and Perl programs using either GNU libintl or the Solaris gettext implementation. This new internationalization support is enabled by default. If gettext isn't available, or if Git is compiled with NO_GETTEXT=YesPlease, Git falls back on its current behavior of showing interface messages in English. When using the autoconf script we'll auto-detect if the gettext libraries are installed and act appropriately. This change is somewhat large because as well as adding a C, Shell and Perl i18n interface we're adding a lot of tests for them, and for those tests to work we need a skeleton PO file to actually test translations. A minimal Icelandic translation is included for this purpose. Icelandic includes multi-byte characters which makes it easy to test various edge cases, and it's a language I happen to understand. The rest of the commit message goes into detail about various sub-parts of this commit. = Installation Gettext .mo files will be installed and looked for in the standard $(prefix)/share/locale path. GIT_TEXTDOMAINDIR can also be set to override that, but that's only intended to be used to test Git itself. = Perl Perl code that's to be localized should use the new Git::I18n module. It imports a __ function into the caller's package by default. Instead of using the high level Locale::TextDomain interface I've opted to use the low-level (equivalent to the C interface) Locale::Messages module, which Locale::TextDomain itself uses. Locale::TextDomain does a lot of redundant work we don't need, and some of it would potentially introduce bugs. It tries to set the $TEXTDOMAIN based on package of the caller, and has its own hardcoded paths where it'll search for messages. I found it easier just to completely avoid it rather than try to circumvent its behavior. In any case, this is an issue wholly internal Git::I18N. Its guts can be changed later if that's deemed necessary. See <AANLkTilYD_NyIZMyj9dHtVk-ylVBfvyxpCC7982LWnVd@mail.gmail.com> for a further elaboration on this topic. = Shell Shell code that's to be localized should use the git-sh-i18n library. It's basically just a wrapper for the system's gettext.sh. If gettext.sh isn't available we'll fall back on gettext(1) if it's available. The latter is available without the former on Solaris, which has its own non-GNU gettext implementation. We also need to emulate eval_gettext() there. If neither are present we'll use a dumb printf(1) fall-through wrapper. = About libcharset.h and langinfo.h We use libcharset to query the character set of the current locale if it's available. I.e. we'll use it instead of nl_langinfo if HAVE_LIBCHARSET_H is set. The GNU gettext manual recommends using langinfo.h's nl_langinfo(CODESET) to acquire the current character set, but on systems that have libcharset.h's locale_charset() using the latter is either saner, or the only option on those systems. GNU and Solaris have a nl_langinfo(CODESET), FreeBSD can use either, but MinGW and some others need to use libcharset.h's locale_charset() instead. =Credits This patch is based on work by Jeff Epler <jepler@unpythonic.net> who did the initial Makefile / C work, and a lot of comments from the Git mailing list, including Jonathan Nieder, Jakub Narebski, Johannes Sixt, Erik Faye-Lund, Peter Krefting, Junio C Hamano, Thomas Rast and others. [jc: squashed a small Makefile fix from Ramsay] Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* CodingGuidelines: downcase placeholders in usage messagesJunio C Hamano2011-02-15
| | | | | | | We accumulated some inconsistencies without an explicit guidance to spell this out over time. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Fix typos in the documentationRalf Wildenhues2011-01-04
| | | | | Signed-off-by: Ralf Wildenhues <Ralf.Wildenhues@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Merge branch 'sn/diff-doc'Junio C Hamano2010-12-03
|\ | | | | | | | | | | | | * sn/diff-doc: docs: clarify git diff modes of operation diff,difftool: Don't use the {0,2} notation in usage strings CodingGuidelines: Add a section on writing documentation
| * CodingGuidelines: Add a section on writing documentationŠtěpán Němec2010-11-05
| | | | | | | | | | | | | | | | Provide a few examples on argument and option notation in usage strings and command synopses. Signed-off-by: Štěpán Němec <stepnem@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | CodingGuidelines: mention whitespace preferences for shell scriptsGiuseppe Bilotta2010-12-03
|/ | | | | Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* CodingGuidelines: reword parameter expansion sectionJunio C Hamano2010-10-13
| | | | | | | | | Group entries related to parameter substitutions together and avoid using the word "regexp" to refer to the ${parameter/pattern/string} substitution (banned), as the pattern there is a shell glob and not a regular expression. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* CodingGuidelines: spell Arithmetic Expansion with $(($var))Junio C Hamano2010-09-27
| | | | | | | | | POSIX wants shells to support both "N" and "$N" and requires them to yield the same answer to $((N)) and $(($N)), but we should aim for portability in a case like this, especially when the price we pay to do so is so small, i.e. a few extra dollars. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* lstat_cache(): swap func(length, string) into func(string, length)Kjetil Barvik2009-02-09
| | | | | | | | | | Swap function argument pair (length, string) into (string, length) to conform with the commonly used order inside the GIT source code. Also, add a note about this fact into the coding guidelines. Signed-off-by: Kjetil Barvik <barvik@broadpark.no> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Mention "local convention" rule in the CodingGuidelinesNanako Shiraishi2009-01-26
| | | | | | | | The document suggests to imitate the existing code, but didn't say which existing code it should imitate. This clarifies. Signed-off-by: しらいしななこ <nanako3@lavabit.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Rename path_list to string_listJohannes Schindelin2008-07-21
| | | | | | | | | | | | | | | | | | | | | | | The name path_list was correct for the first usage of that data structure, but it really is a general-purpose string list. $ perl -i -pe 's/path-list/string-list/g' $(git grep -l path-list) $ perl -i -pe 's/path_list/string_list/g' $(git grep -l path_list) $ git mv path-list.h string-list.h $ git mv path-list.c string-list.c $ perl -i -pe 's/has_path/has_string/g' $(git grep -l has_path) $ perl -i -pe 's/path/string/g' string-list.[ch] $ git mv Documentation/technical/api-path-list.txt \ Documentation/technical/api-string-list.txt $ perl -i -pe 's/strdup_paths/strdup_strings/g' $(git grep -l strdup_paths) ... and then fix all users of string-list to access the member "string" instead of "path". Documentation/technical/api-string-list.txt needed some rewrapping, too. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* CodingGuidelines: Add a note to avoid assignments inside if()Miklos Vajna2008-05-24
| | | | | Signed-off-by: Miklos Vajna <vmiklos@frugalware.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* CodingGuidelines: spell out how we use grep in our scriptsJunio C Hamano2008-03-01
| | | | | | | | | Our scripts try to stick to fairly limited subset of POSIX BRE for portability. It is unclear from manual page from GNU grep which is GNU extension and which is portable, so let's spell it out to help new people to keep their contributions from hurting porters. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Add Documentation/CodingGuidelinesJohannes Schindelin2007-11-07
Even if our code is quite a good documentation for our coding style, some people seem to prefer a document describing it. The part about the shell scripts is clearly just copied from one of Junio's helpful mails, and some parts were added from comments by Junio, Andreas Ericsson and Robin Rosenberg. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>