summaryrefslogtreecommitdiff
path: root/Documentation/CodingGuidelines
AgeCommit message (Collapse)Author
2013-05-10CodingGuidelines: Documentation/*.txt are the sourcesDale Worley
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>
2013-03-21CodingGuidelines: our documents are in AsciiDocJunio C Hamano
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>
2013-02-14Merge branch 'tz/perl-styles'Junio C Hamano
Add coding guidelines for writing Perl scripts for Git. * tz/perl-styles: Update CodingGuidelines for Perl
2013-02-07Merge branch 'jk/python-styles'Junio C Hamano
* jk/python-styles: CodingGuidelines: add Python coding guidelines
2013-02-06Update CodingGuidelines for PerlTed Zlatanov
Add the coding guidelines for Perl. Signed-off-by: Ted Zlatanov <tzz@lifelogs.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-02-01Documentation: the name of the system is 'Git', not 'git'Thomas Ackermann
Signed-off-by: Thomas Ackermann <th.acker@arcor.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-02-01Documentation: avoid poor-man's small caps GITThomas Ackermann
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>
2013-01-30CodingGuidelines: add Python coding guidelinesJohn Keeping
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>
2012-12-17Documentation: move support for old compilers to CodingGuidelinesAdam Spiers
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>
2012-08-15Documentation/CodingGuidelines: spell out more shell guidelinesHeiko Voigt
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>
2012-02-27CodingGuidelines: do not use 'which' in shell scriptsTim Henigan
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>
2012-02-27CodingGuidelines: Add a note about spaces after redirectionTim Henigan
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>
2011-12-06i18n: add infrastructure for translating Git with gettextÆvar Arnfjörð Bjarmason
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>
2011-02-15CodingGuidelines: downcase placeholders in usage messagesJunio C Hamano
We accumulated some inconsistencies without an explicit guidance to spell this out over time. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-01-04Fix typos in the documentationRalf Wildenhues
Signed-off-by: Ralf Wildenhues <Ralf.Wildenhues@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-12-04Merge branch 'sn/diff-doc'Junio C Hamano
* 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
2010-12-03CodingGuidelines: mention whitespace preferences for shell scriptsGiuseppe Bilotta
Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-11-05CodingGuidelines: Add a section on writing documentationŠtěpán Němec
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>
2010-10-13CodingGuidelines: reword parameter expansion sectionJunio C Hamano
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>
2010-09-27CodingGuidelines: spell Arithmetic Expansion with $(($var))Junio C Hamano
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>
2009-02-10lstat_cache(): swap func(length, string) into func(string, length)Kjetil Barvik
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>
2009-01-26Mention "local convention" rule in the CodingGuidelinesNanako Shiraishi
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>
2008-07-22Rename path_list to string_listJohannes Schindelin
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>
2008-05-25CodingGuidelines: Add a note to avoid assignments inside if()Miklos Vajna
Signed-off-by: Miklos Vajna <vmiklos@frugalware.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-03-02CodingGuidelines: spell out how we use grep in our scriptsJunio C Hamano
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>
2007-11-08Add Documentation/CodingGuidelinesJohannes Schindelin
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>