<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/help.c, branch v2.4.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.4.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.4.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2014-09-26T21:39:49Z</updated>
<entry>
<title>Merge branch 'sb/help-unknown-command-sort-fix'</title>
<updated>2014-09-26T21:39:49Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2014-09-26T21:39:46Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=5d7f49dc79edf476a0b9266ea5f076b723eca6ec'/>
<id>urn:sha1:5d7f49dc79edf476a0b9266ea5f076b723eca6ec</id>
<content type='text'>
Code cleanup.

* sb/help-unknown-command-sort-fix:
  help: fix the size passed to qsort
</content>
</entry>
<entry>
<title>help: fix the size passed to qsort</title>
<updated>2014-09-18T17:17:53Z</updated>
<author>
<name>Stefan Beller</name>
<email>stefanbeller@gmail.com</email>
</author>
<published>2014-09-17T12:14:39Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=d333ac178547946271afc41885d3ea9914500a47'/>
<id>urn:sha1:d333ac178547946271afc41885d3ea9914500a47</id>
<content type='text'>
We actually want to have the size of one 'name' and not the size
of the pointer.

Signed-off-by: Stefan Beller &lt;stefanbeller@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'jk/strip-suffix'</title>
<updated>2014-07-16T18:26:00Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2014-07-16T18:25:59Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=6e4094731acee5207595a8416d19508107ea475d'/>
<id>urn:sha1:6e4094731acee5207595a8416d19508107ea475d</id>
<content type='text'>
* jk/strip-suffix:
  prepare_packed_git_one: refactor duplicate-pack check
  verify-pack: use strbuf_strip_suffix
  strbuf: implement strbuf_strip_suffix
  index-pack: use strip_suffix to avoid magic numbers
  use strip_suffix instead of ends_with in simple cases
  replace has_extension with ends_with
  implement ends_with via strip_suffix
  add strip_suffix function
  sha1_file: replace PATH_MAX buffer with strbuf in prepare_packed_git_one()
</content>
</entry>
<entry>
<title>use strip_suffix instead of ends_with in simple cases</title>
<updated>2014-06-30T20:43:17Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2014-06-30T16:58:51Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=26936bfd9bde1ec46901bea3e53d4fb9ae1b4a4c'/>
<id>urn:sha1:26936bfd9bde1ec46901bea3e53d4fb9ae1b4a4c</id>
<content type='text'>
When stripping a suffix like:

  if (ends_with(str, "foo"))
	buf = xmemdupz(str, strlen(str) - 3);

we can instead use strip_suffix to avoid the constant 3,
which must match the literal "foo" (we sometimes use
strlen("foo") instead, but that means we are repeating
ourselves). The example above becomes:

  if (strip_suffix(str, "foo", &amp;len))
	buf = xmemdupz(str, len);

This also saves a strlen(), since we calculate the string
length when detecting the suffix.

Note that in some cases we also switch from xstrndup to
xmemdupz, which saves a further strlen call.

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>replace has_extension with ends_with</title>
<updated>2014-06-30T20:43:16Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2014-06-30T16:58:25Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=2975c770ca609ea5afc80631c4ac9087c527b6fd'/>
<id>urn:sha1:2975c770ca609ea5afc80631c4ac9087c527b6fd</id>
<content type='text'>
These two are almost the same function, with the exception
that has_extension only matches if there is content before
the suffix. So ends_with(".exe", ".exe") is true, but
has_extension would not be.

This distinction does not matter to any of the callers,
though, and we can just replace uses of has_extension with
ends_with. We prefer the "ends_with" name because it is more
generic, and there is nothing about the function that
requires it to be used for file extensions.

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>use skip_prefix to avoid repeated calculations</title>
<updated>2014-06-20T17:45:19Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2014-06-18T19:57:17Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=de8118e153c5e527263086605e437ccca5d4f1ef'/>
<id>urn:sha1:de8118e153c5e527263086605e437ccca5d4f1ef</id>
<content type='text'>
In some cases, we use starts_with to check for a prefix, and
then use an already-calculated prefix length to advance a
pointer past the prefix. There are no magic numbers or
duplicated strings here, but we can still make the code
simpler and more obvious by using skip_prefix.

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>use skip_prefix to avoid repeating strings</title>
<updated>2014-06-20T17:44:45Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2014-06-18T19:48:29Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=95b567c7c3cf6b85d74b79424cdfbd40a7dee7c9'/>
<id>urn:sha1:95b567c7c3cf6b85d74b79424cdfbd40a7dee7c9</id>
<content type='text'>
It's a common idiom to match a prefix and then skip past it
with strlen, like:

  if (starts_with(foo, "bar"))
	  foo += strlen("bar");

This avoids magic numbers, but means we have to repeat the
string (and there is no compiler check that we didn't make a
typo in one of the strings).

We can use skip_prefix to handle this case without repeating
ourselves.

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>use skip_prefix to avoid magic numbers</title>
<updated>2014-06-20T17:44:45Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2014-06-18T19:47:50Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=ae021d87911da4328157273df24779892cb51277'/>
<id>urn:sha1:ae021d87911da4328157273df24779892cb51277</id>
<content type='text'>
It's a common idiom to match a prefix and then skip past it
with a magic number, like:

  if (starts_with(foo, "bar"))
	  foo += 3;

This is easy to get wrong, since you have to count the
prefix string yourself, and there's no compiler check if the
string changes.  We can use skip_prefix to avoid the magic
numbers here.

Note that some of these conversions could be much shorter.
For example:

  if (starts_with(arg, "--foo=")) {
	  bar = arg + 6;
	  continue;
  }

could become:

  if (skip_prefix(arg, "--foo=", &amp;bar))
	  continue;

However, I have left it as:

  if (skip_prefix(arg, "--foo=", &amp;v)) {
	  bar = v;
	  continue;
  }

to visually match nearby cases which need to actually
process the string. Like:

  if (skip_prefix(arg, "--foo=", &amp;v)) {
	  bar = atoi(v);
	  continue;
  }

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'rt/help-pretty-prints-cmd-names'</title>
<updated>2014-03-14T21:27:00Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2014-03-14T21:27:00Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=c89eb9870e474b0717d6e11f0ddb8b73cef520af'/>
<id>urn:sha1:c89eb9870e474b0717d6e11f0ddb8b73cef520af</id>
<content type='text'>
* rt/help-pretty-prints-cmd-names:
  help.c: rename function "pretty_print_string_list"
</content>
</entry>
<entry>
<title>help.c: rename function "pretty_print_string_list"</title>
<updated>2014-02-28T21:24:53Z</updated>
<author>
<name>Ralf Thielow</name>
<email>ralf.thielow@gmail.com</email>
</author>
<published>2014-02-28T19:27:29Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=d10cb3dfab92bf24e2919ae3d4a16013dba0261f'/>
<id>urn:sha1:d10cb3dfab92bf24e2919ae3d4a16013dba0261f</id>
<content type='text'>
The part "string_list" of the name of function
"pretty_print_string_list" is just an implementation
detail. The function pretty-prints command names so
rename it to "pretty_print_cmdnames".

Signed-off-by: Ralf Thielow &lt;ralf.thielow@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
