<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/parse-options.c, branch v2.4.9</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.4.9</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.4.9'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2014-09-19T18:38:38Z</updated>
<entry>
<title>Merge branch 'jc/parseopt-verify-short-name'</title>
<updated>2014-09-19T18:38:38Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2014-09-19T18:38:38Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=5dbdb3bed63ab1bb0b44a398322d736aafbeb841'/>
<id>urn:sha1:5dbdb3bed63ab1bb0b44a398322d736aafbeb841</id>
<content type='text'>
Add checks for a common programming mistake to assign the same
short option name to two separate options to help developers.

* jc/parseopt-verify-short-name:
  parse-options: detect attempt to add a duplicate short option name
</content>
</entry>
<entry>
<title>parse-options: detect attempt to add a duplicate short option name</title>
<updated>2014-09-04T18:00:28Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2014-09-03T19:42:37Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=af465af8deda8ad685f7704a2dc787845eb317ed'/>
<id>urn:sha1:af465af8deda8ad685f7704a2dc787845eb317ed</id>
<content type='text'>
It is easy to overlook an already assigned single-letter option name
and try to use it for a new one.  Help the developer to catch it
before such a mistake escapes the lab.

This retroactively forbids any short option name (which is defined
to be of type "int") outside the ASCII printable range.  We might
want to do one of two things:

 - tighten the type of short_name member to 'char', and further
   update optbug() to protect it against doing "'%c'" on a funny
   value, e.g. negative or above 127.

 - drop the check (even the "duplicate" check) for an option whose
   short_name is either negative or above 255, to allow clever folks
   to take advantage of the fact that such a short_name cannot be
   parsed from the command line and the member can be used to store
   some extra information.

Helped-by: René Scharfe &lt;l.s.r@web.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>refactor skip_prefix to return a boolean</title>
<updated>2014-06-20T17:44:43Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2014-06-18T19:44:19Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=cf4fff579e02d8585d59f6c8739534b7b0d617dd'/>
<id>urn:sha1:cf4fff579e02d8585d59f6c8739534b7b0d617dd</id>
<content type='text'>
The skip_prefix() function returns a pointer to the content
past the prefix, or NULL if the prefix was not found. While
this is nice and simple, in practice it makes it hard to use
for two reasons:

  1. When you want to conditionally skip or keep the string
     as-is, you have to introduce a temporary variable.
     For example:

       tmp = skip_prefix(buf, "foo");
       if (tmp)
	       buf = tmp;

  2. It is verbose to check the outcome in a conditional, as
     you need extra parentheses to silence compiler
     warnings. For example:

       if ((cp = skip_prefix(buf, "foo"))
	       /* do something with cp */

Both of these make it harder to use for long if-chains, and
we tend to use starts_with() instead. However, the first line
of "do something" is often to then skip forward in buf past
the prefix, either using a magic constant or with an extra
strlen(3) (which is generally computed at compile time, but
means we are repeating ourselves).

This patch refactors skip_prefix() to return a simple boolean,
and to provide the pointer value as an out-parameter. If the
prefix is not found, the out-parameter is untouched. This
lets you write:

  if (skip_prefix(arg, "foo ", &amp;arg))
	  do_foo(arg);
  else if (skip_prefix(arg, "bar ", &amp;arg))
	  do_bar(arg);

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 'mr/opt-set-ptr'</title>
<updated>2014-04-08T19:00:17Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2014-04-08T19:00:16Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=b389e04031ffe4c725161a082ff748bd33688641'/>
<id>urn:sha1:b389e04031ffe4c725161a082ff748bd33688641</id>
<content type='text'>
OPT_SET_PTR() implementation was broken on IL32P64 platforms;
it turns out that the macro is not used by any real user.

* mr/opt-set-ptr:
  parse-options: remove unused OPT_SET_PTR
  parse-options: add cast to correct pointer type to OPT_SET_PTR
  MSVC: fix t0040-parse-options crash
</content>
</entry>
<entry>
<title>parse-options: remove unused OPT_SET_PTR</title>
<updated>2014-03-31T20:01:19Z</updated>
<author>
<name>Marat Radchenko</name>
<email>marat@slonopotamus.org</email>
</author>
<published>2014-03-30T11:08:23Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=20d1c6528c76242581e89c271679d35884d916dc'/>
<id>urn:sha1:20d1c6528c76242581e89c271679d35884d916dc</id>
<content type='text'>
OPT_SET_PTR was never used since its creation at db7244bd
(parse-options new features., 2007-11-07).

Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>parse-options: make sure argh string does not have SP or _</title>
<updated>2014-03-24T17:43:35Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2014-03-23T23:04:36Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=b6c2a0d45d4165dfd326bd7a28e66d9cedb8ae84'/>
<id>urn:sha1:b6c2a0d45d4165dfd326bd7a28e66d9cedb8ae84</id>
<content type='text'>
We encourage to spell an argument hint that consists of multiple
words as a single-token separated with dashes.  In order to help
catching violations added by new callers of parse-options, make sure
argh does not contain SP or _ when the code validates the option
definitions.

Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>use strchrnul() in place of strchr() and strlen()</title>
<updated>2014-03-10T15:35:30Z</updated>
<author>
<name>Rohit Mani</name>
<email>rohit.mani@outlook.com</email>
</author>
<published>2014-03-08T06:48:31Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=2c5495f7b60d6ddcd6a411b48d2f6dbc4a24717a'/>
<id>urn:sha1:2c5495f7b60d6ddcd6a411b48d2f6dbc4a24717a</id>
<content type='text'>
Avoid scanning strings twice, once with strchr() and then with
strlen(), by using strchrnul().

Helped-by: Junio C Hamano &lt;gitster@pobox.com&gt;
Signed-off-by: Rohit Mani &lt;rohit.mani@outlook.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>replace {pre,suf}fixcmp() with {starts,ends}_with()</title>
<updated>2013-12-05T22:13:21Z</updated>
<author>
<name>Christian Couder</name>
<email>chriscool@tuxfamily.org</email>
</author>
<published>2013-11-30T20:55:40Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=59556548230e617b837343c2c07e357e688e2ca4'/>
<id>urn:sha1:59556548230e617b837343c2c07e357e688e2ca4</id>
<content type='text'>
Leaving only the function definitions and declarations so that any
new topic in flight can still make use of the old functions, replace
existing uses of the prefixcmp() and suffixcmp() with new API
functions.

The change can be recreated by mechanically applying this:

    $ git grep -l -e prefixcmp -e suffixcmp -- \*.c |
      grep -v strbuf\\.c |
      xargs perl -pi -e '
        s|!prefixcmp\(|starts_with\(|g;
        s|prefixcmp\(|!starts_with\(|g;
        s|!suffixcmp\(|ends_with\(|g;
        s|suffixcmp\(|!ends_with\(|g;
      '

on the result of preparatory changes in this series.

Signed-off-by: Christian Couder &lt;chriscool@tuxfamily.org&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>parse-options: add OPT_CMDMODE()</title>
<updated>2013-07-30T19:23:31Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2013-07-30T19:06:01Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=1158826394e162c5d45a4043ea86b04b24215555'/>
<id>urn:sha1:1158826394e162c5d45a4043ea86b04b24215555</id>
<content type='text'>
This can be used to define a set of mutually exclusive "command
mode" options, and automatically catch use of more than one from
that set as an error.

Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'ef/non-ascii-parse-options-error-diag'</title>
<updated>2013-02-15T00:06:14Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2013-02-15T00:06:14Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=6bdecc8f56a06f085b4444dc29361a5aa80d9eef'/>
<id>urn:sha1:6bdecc8f56a06f085b4444dc29361a5aa80d9eef</id>
<content type='text'>
* ef/non-ascii-parse-options-error-diag:
  parse-options: report uncorrupted multi-byte options
</content>
</entry>
</feed>
