<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/alias.c, branch v2.6.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.6.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.6.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2015-08-24T15:52:23Z</updated>
<entry>
<title>config: silence warnings for command names with invalid keys</title>
<updated>2015-08-24T15:52:23Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2015-08-24T06:11:33Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=9e9de18f1ad39901a8f0c67f0af70d66d427e326'/>
<id>urn:sha1:9e9de18f1ad39901a8f0c67f0af70d66d427e326</id>
<content type='text'>
When we are running the git command "foo", we may have to
look up the config keys "pager.foo" and "alias.foo". These
config schemes are mis-designed, as the command names can be
anything, but the config syntax has some restrictions. For
example:

  $ git foo_bar
  error: invalid key: pager.foo_bar
  error: invalid key: alias.foo_bar
  git: 'foo_bar' is not a git command. See 'git --help'.

You cannot name an alias with an underscore. And if you have
an external command with one, you cannot configure its
pager.

In the long run, we may develop a different config scheme
for these features. But in the near term (and because we'll
need to support the existing scheme indefinitely), we should
at least squelch the error messages shown above.

These errors come from git_config_parse_key. Ideally we
would pass a "quiet" flag to the config machinery, but there
are many layers between the pager code and the key parsing.
Passing a flag through all of those would be an invasive
change.

Instead, let's provide a config function to report on
whether a key is syntactically valid, and have the pager and
alias code skip lookup for bogus keys. We can build this
easily around the existing git_config_parse_key, with two
minor modifications:

  1. We now handle a NULL store_key, to validate but not
     write out the normalized key.

  2. We accept a "quiet" flag to avoid writing to stderr.
     This doesn't need to be a full-blown public "flags"
     field, because we can make the existing implementation
     a static helper function, keeping the mess contained
     inside config.c.

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>alias.c: replace `git_config()` with `git_config_get_string()`</title>
<updated>2014-08-07T20:33:29Z</updated>
<author>
<name>Tanay Abhra</name>
<email>tanayabh@gmail.com</email>
</author>
<published>2014-08-07T16:21:25Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=111791559e69011a6d55f053393d154a1840b4f5'/>
<id>urn:sha1:111791559e69011a6d55f053393d154a1840b4f5</id>
<content type='text'>
Use `git_config_get_string()` instead of `git_config()` to take advantage of
the config-set API which provides a cleaner control flow.

Signed-off-by: Tanay Abhra &lt;tanayabh@gmail.com&gt;
Reviewed-by: Matthieu Moy &lt;Matthieu.Moy@imag.fr&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>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>alias: have SP around arithmetic operators</title>
<updated>2013-10-16T17:27:26Z</updated>
<author>
<name>Felipe Contreras</name>
<email>felipe.contreras@gmail.com</email>
</author>
<published>2013-09-21T19:15:44Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=cc10837929b2afe4116bb305e69b4bd4a95958de'/>
<id>urn:sha1:cc10837929b2afe4116bb305e69b4bd4a95958de</id>
<content type='text'>
Signed-off-by: Felipe Contreras &lt;felipe.contreras@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>split_cmdline: Allow caller to access error string</title>
<updated>2010-08-11T16:36:23Z</updated>
<author>
<name>Greg Brockman</name>
<email>gdb@MIT.EDU</email>
</author>
<published>2010-08-07T05:13:39Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=ad9ac6db5d58de08d0497b9184e86926377c20dd'/>
<id>urn:sha1:ad9ac6db5d58de08d0497b9184e86926377c20dd</id>
<content type='text'>
This allows the caller to add its own error message to that returned
by split_cmdline.  Thus error output following a failed split_cmdline
can be of the form

fatal: Bad alias.test string: cmdline ends with \

rather than

error: cmdline ends with \
fatal: Bad alias.test string

Signed-off-by: Greg Brockman &lt;gdb@mit.edu&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'jk/maint-1.6.0-trace-argv'</title>
<updated>2009-05-23T08:39:08Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2009-05-23T08:39:08Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=2beba6beb0074afac988594539572865fb37a00f'/>
<id>urn:sha1:2beba6beb0074afac988594539572865fb37a00f</id>
<content type='text'>
* jk/maint-1.6.0-trace-argv:
  fix GIT_TRACE segfault with shell-quoted aliases

Conflicts:
	alias.c
</content>
</entry>
<entry>
<title>fix GIT_TRACE segfault with shell-quoted aliases</title>
<updated>2009-05-09T08:39:40Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2009-05-08T09:06:15Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=27d5438d9f4eb2cefc2a989c68f9b42b529b2a12'/>
<id>urn:sha1:27d5438d9f4eb2cefc2a989c68f9b42b529b2a12</id>
<content type='text'>
The alias argv comes from the split_cmdline function, which
splits the config text for the alias into an array of
strings. It returns the number of elements in the array, but
does not actually put a NULL at the end of the array.
Later, the trace function tries to print this argv and
assumes that it has the trailing NULL.

The split_cmdline function is probably at fault, since argv
lists almost always end with a NULL signal. This patch adds
one, in addition to the returned count; this doesn't hurt
the other callers at all, since they were presumably using
the count already (and will never look at the NULL).

While we're there and using ALLOC_GROW, let's clean up the
other manual grow.

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>Fix a bunch of pointer declarations (codestyle)</title>
<updated>2009-05-01T22:17:31Z</updated>
<author>
<name>Felipe Contreras</name>
<email>felipe.contreras@gmail.com</email>
</author>
<published>2009-05-01T09:06:36Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=4b25d091ba53c758fae0096b8c0662371857b9d9'/>
<id>urn:sha1:4b25d091ba53c758fae0096b8c0662371857b9d9</id>
<content type='text'>
Essentially; s/type* /type */ as per the coding guidelines.

Signed-off-by: Felipe Contreras &lt;felipe.contreras@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Move split_cmdline() to alias.c</title>
<updated>2008-07-01T05:45:50Z</updated>
<author>
<name>Miklos Vajna</name>
<email>vmiklos@frugalware.org</email>
</author>
<published>2008-06-27T16:21:54Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=0989fe9623dc8d98033f6acdcc0c84ec28571b19'/>
<id>urn:sha1:0989fe9623dc8d98033f6acdcc0c84ec28571b19</id>
<content type='text'>
split_cmdline() is currently used for aliases only, but later it can be
useful for other builtins as well. Move it to alias.c for now,
indicating that originally it's for aliases, but we'll have it in libgit
this way.

Signed-off-by: Miklos Vajna &lt;vmiklos@frugalware.org&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
