<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/git.git/Documentation/CodingGuidelines, branch jc/coding-guidelines</title>
<subtitle>github.com: git/git.git
</subtitle>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/git.git/'/>
<entry>
<title>CodingGuidelines: clarify C #include rules</title>
<updated>2015-01-15T23:42:50+00:00</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2015-01-15T23:20:09+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/git.git/commit/?id=412cb2ec1302364aba862b183210249c2ca7d44e'/>
<id>412cb2ec1302364aba862b183210249c2ca7d44e</id>
<content type='text'>
Even though "advice.h" includes "git-compat-util.h", it is not
sensible to have it as the first #include and indirectly satisify
the "You must give git-compat-util.h a clean environment to set up
feature test macros before including any of the system headers are
included", which is the real requirement.

Because:

 - A command that interacts with the object store, config subsystem,
   the index, or the working tree cannot do anything without using
   what is declared in "cache.h";

 - A built-in command must be declared in "builtin.h", so anything
   in builtin/*.c must include it;

 - These two headers both include "git-compat-util.h" as the first
   thing; and

 - Almost all our *.c files (outside compat/ and borrowed files in
   xdiff/) need some Git-ness from "cache.h" to do something
   Git-ish.

let's explicitly specify that one of these three header files must
be the first thing that is included.

Any of our *.c file should include the header file that directly
declares what it uses, instead of relying on the fact that some *.h
file it includes happens to include another *.h file that declares
the necessary function or type.  Spell it out as another guideline
item.

Helped-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Even though "advice.h" includes "git-compat-util.h", it is not
sensible to have it as the first #include and indirectly satisify
the "You must give git-compat-util.h a clean environment to set up
feature test macros before including any of the system headers are
included", which is the real requirement.

Because:

 - A command that interacts with the object store, config subsystem,
   the index, or the working tree cannot do anything without using
   what is declared in "cache.h";

 - A built-in command must be declared in "builtin.h", so anything
   in builtin/*.c must include it;

 - These two headers both include "git-compat-util.h" as the first
   thing; and

 - Almost all our *.c files (outside compat/ and borrowed files in
   xdiff/) need some Git-ness from "cache.h" to do something
   Git-ish.

let's explicitly specify that one of these three header files must
be the first thing that is included.

Any of our *.c file should include the header file that directly
declares what it uses, instead of relying on the fact that some *.h
file it includes happens to include another *.h file that declares
the necessary function or type.  Spell it out as another guideline
item.

Helped-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>CodingGuidelines: avoid "test &lt;cond&gt; -a/-o &lt;cond&gt;"</title>
<updated>2014-05-20T18:19:43+00:00</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2014-05-20T18:12:02+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/git.git/commit/?id=897f964c0dce8e7cc2cc53bb19b83cadce106773'/>
<id>897f964c0dce8e7cc2cc53bb19b83cadce106773</id>
<content type='text'>
The construct is error-prone; "test" being built-in in most modern
shells, the reason to avoid "test &lt;cond&gt; &amp;&amp; test &lt;cond&gt;" spawning
one extra process by using a single "test &lt;cond&gt; -a &lt;cond&gt;" no
longer exists.

Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The construct is error-prone; "test" being built-in in most modern
shells, the reason to avoid "test &lt;cond&gt; &amp;&amp; test &lt;cond&gt;" spawning
one extra process by using a single "test &lt;cond&gt; -a &lt;cond&gt;" no
longer exists.

Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>CodingGuidelines: on splitting a long line</title>
<updated>2014-05-02T21:08:16+00:00</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2014-05-02T20:42:39+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/git.git/commit/?id=f26443da0449c459dab8b91d963bd91dd4335657'/>
<id>f26443da0449c459dab8b91d963bd91dd4335657</id>
<content type='text'>
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>CodingGuidelines: on comparison</title>
<updated>2014-05-02T20:44:46+00:00</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2014-04-30T21:26:23+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/git.git/commit/?id=5db9ab82b94fab16e69b0228aaf1e972520bd04a'/>
<id>5db9ab82b94fab16e69b0228aaf1e972520bd04a</id>
<content type='text'>
There are arguments for writing a conditional as "a &lt; b" rather than
"b &gt; 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 &lt;gitster@pobox.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
There are arguments for writing a conditional as "a &lt; b" rather than
"b &gt; 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 &lt;gitster@pobox.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>CodingGuidelines: do not call the conditional statement "if()"</title>
<updated>2014-05-02T20:26:07+00:00</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2014-04-30T21:25:47+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/git.git/commit/?id=691d0dd0a9c901286c2a0a28c30ec4d13bcd2032'/>
<id>691d0dd0a9c901286c2a0a28c30ec4d13bcd2032</id>
<content type='text'>
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 &lt;gitster@pobox.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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 &lt;gitster@pobox.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>CodingGuidelines: give an example for shell function preamble</title>
<updated>2014-05-02T20:24:57+00:00</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2014-04-30T21:25:11+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/git.git/commit/?id=6117a3d4946e35c7d4a38c0b443891c81808a838'/>
<id>6117a3d4946e35c7d4a38c0b443891c81808a838</id>
<content type='text'>
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>CodingGuidelines: give an example for control statements</title>
<updated>2014-05-02T20:24:57+00:00</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2014-04-30T21:24:52+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/git.git/commit/?id=9dbe780174892a35d6f1e19495c13b9edb9d88fd'/>
<id>9dbe780174892a35d6f1e19495c13b9edb9d88fd</id>
<content type='text'>
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>CodingGuidelines: give an example for redirection</title>
<updated>2014-05-02T20:24:57+00:00</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2014-04-30T21:24:24+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/git.git/commit/?id=6a49909b52b48592234da6a53bfe74ea34c302c6'/>
<id>6a49909b52b48592234da6a53bfe74ea34c302c6</id>
<content type='text'>
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>CodingGuidelines: give an example for case/esac statement</title>
<updated>2014-05-02T20:24:57+00:00</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2014-04-30T21:24:08+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/git.git/commit/?id=79fc3ca1232099fd21e5bdef14c1b6fe1d2dbc1c'/>
<id>79fc3ca1232099fd21e5bdef14c1b6fe1d2dbc1c</id>
<content type='text'>
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>CodingGuidelines: once it is in, it is not worth the code churn</title>
<updated>2014-05-02T20:24:57+00:00</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2014-04-30T21:23:26+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/git.git/commit/?id=dd30800bcd236233c82da80bba0d00956a246260'/>
<id>dd30800bcd236233c82da80bba0d00956a246260</id>
<content type='text'>
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</pre>
</div>
</content>
</entry>
</feed>
