<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/parse-options.c, branch v2.16.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.16.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.16.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2017-09-25T05:35:53Z</updated>
<entry>
<title>parse-options: only insert newline in help text if needed</title>
<updated>2017-09-25T05:35:53Z</updated>
<author>
<name>Brandon Casey</name>
<email>drafnel@gmail.com</email>
</author>
<published>2017-09-25T04:08:05Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=a6304fa4c2f57b08ec0acea9f91c188f284f8374'/>
<id>urn:sha1:a6304fa4c2f57b08ec0acea9f91c188f284f8374</id>
<content type='text'>
Currently, when parse_options() produces a help message it always emits
a blank line after the usage text to separate it from the options text.
If the option spec does not define any switches, or only defines hidden
switches that will not be displayed, then the help text will end up with
two trailing blank lines instead of one.  Let's defer emitting the blank
line between the usage text and the options text until it is clear that
the options section will not be empty.

Fixes t1502.5, t1502.6.

Signed-off-by: Brandon Casey &lt;drafnel@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>parse-options: write blank line to correct output stream</title>
<updated>2017-09-25T05:35:52Z</updated>
<author>
<name>Brandon Casey</name>
<email>drafnel@gmail.com</email>
</author>
<published>2017-09-25T04:08:04Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=1a9bf1e176439d415b97fb8c5a556f69ea503877'/>
<id>urn:sha1:1a9bf1e176439d415b97fb8c5a556f69ea503877</id>
<content type='text'>
When commit 54e6dc7 added translation support to parse-options, an
fprintf was mistakenly replaced by a call to putchar().  Let's use fputc
instead.

Fixes t0040.11, t0040.12, t0040.33, and t1502.8.

Signed-off-by: Brandon Casey &lt;drafnel@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'bw/config-h'</title>
<updated>2017-06-24T21:28:41Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2017-06-24T21:28:40Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=f31d23a399d557d687266b4375a0436f920cc051'/>
<id>urn:sha1:f31d23a399d557d687266b4375a0436f920cc051</id>
<content type='text'>
Fix configuration codepath to pay proper attention to commondir
that is used in multi-worktree situation, and isolate config API
into its own header file.

* bw/config-h:
  config: don't implicitly use gitdir or commondir
  config: respect commondir
  setup: teach discover_git_directory to respect the commondir
  config: don't include config.h by default
  config: remove git_config_iter
  config: create config.h
</content>
</entry>
<entry>
<title>config: don't include config.h by default</title>
<updated>2017-06-15T19:56:22Z</updated>
<author>
<name>Brandon Williams</name>
<email>bmwill@google.com</email>
</author>
<published>2017-06-14T18:07:36Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=b2141fc1d20e659810245ec6ca1c143c60e033ec'/>
<id>urn:sha1:b2141fc1d20e659810245ec6ca1c143c60e033ec</id>
<content type='text'>
Stop including config.h by default in cache.h.  Instead only include
config.h in those files which require use of the config system.

Signed-off-by: Brandon Williams &lt;bmwill@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>C style: use standard style for "TRANSLATORS" comments</title>
<updated>2017-05-30T23:01:42Z</updated>
<author>
<name>Ævar Arnfjörð Bjarmason</name>
<email>avarab@gmail.com</email>
</author>
<published>2017-05-11T21:20:12Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=66f5f6dca95eda46bf02c8d06de8cb265995fd6e'/>
<id>urn:sha1:66f5f6dca95eda46bf02c8d06de8cb265995fd6e</id>
<content type='text'>
Change all the "TRANSLATORS: [...]" comments in the C code to use the
regular Git coding style, and amend the style guide so that the
example there uses that style.

This custom style was necessary back in 2010 when the gettext support
was initially added, and was subsequently documented in commit
cbcfd4e3ea ("i18n: mention "TRANSLATORS:" marker in
Documentation/CodingGuidelines", 2014-04-18).

GNU xgettext hasn't had the parsing limitation that necessitated this
exception for almost 3 years. Since its 0.19 release on 2014-06-02
it's been able to recognize TRANSLATOR comments in the standard Git
comment syntax[1].

Usually we'd like to keep compatibility with software that's that
young, but in this case literally the only person who needs to be
using a gettext newer than 3 years old is Jiang Xin (the only person
who runs &amp; commits "make pot" results), so I think in this case we can
make an exception.

This xgettext parsing feature was added after a thread on the Git
mailing list[2] which continued on the bug-gettext[3] list, but we
never subsequently changed our style &amp; styleguide, do so.

There are already longstanding changes in git that use the standard
comment style &amp; have their TRANSLATORS comments extracted properly
without getting the literal "*"'s mixed up in the text, as would
happen before xgettext 0.19.

Commit 7ff2683253 ("builtin-am: implement -i/--interactive",
2015-08-04) added one such comment, which in commit df0617bfa7 ("l10n:
git.pot: v2.6.0 round 1 (123 new, 41 removed)", 2015-09-05) got picked
up in the po/git.pot file with the right format, showing that Jiang
already runs a modern xgettext.

The xgettext parser does not handle the sort of non-standard comment
style that I'm amending here in sequencer.c, but that isn't standard
Git comment syntax anyway. With this change to sequencer.c &amp; "make
pot" the comment in the pot file is now correct:

     #. TRANSLATORS: %s will be "revert", "cherry-pick" or
    -#. * "rebase -i".
    +#. "rebase -i".

1. http://git.savannah.gnu.org/cgit/gettext.git/commit/?id=10af7fe6bd
2. &lt;2ce9ec406501d112e032c8208417f8100bed04c6.1397712142.git.worldhello.net@gmail.com&gt;
   (https://public-inbox.org/git/2ce9ec406501d112e032c8208417f8100bed04c6.1397712142.git.worldhello.net@gmail.com/)
3. https://lists.gnu.org/archive/html/bug-gettext/2014-04/msg00016.html

Signed-off-by: Ævar Arnfjörð Bjarmason &lt;avarab@gmail.com&gt;
Acked-by: Jiang Xin &lt;worldhello.net@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>prefix_filename: return newly allocated string</title>
<updated>2017-03-21T18:18:41Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2017-03-21T01:28:49Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=e4da43b1f063d227b5f7d2922d27458748763a2d'/>
<id>urn:sha1:e4da43b1f063d227b5f7d2922d27458748763a2d</id>
<content type='text'>
The prefix_filename() function returns a pointer to static
storage, which makes it easy to use dangerously. We already
fixed one buggy caller in hash-object recently, and the
calls in apply.c are suspicious (I didn't dig in enough to
confirm that there is a bug, but we call the function once
in apply_all_patches() and then again indirectly from
parse_chunk()).

Let's make it harder to get wrong by allocating the return
value. For simplicity, we'll do this even when the prefix is
empty (and we could just return the original file pointer).
That will cause us to allocate sometimes when we wouldn't
otherwise need to, but this function isn't called in
performance critical code-paths (and it already _might_
allocate on any given call, so a caller that cares about
performance is questionable anyway).

The downside is that the callers need to remember to free()
the result to avoid leaking. Most of them already used
xstrdup() on the result, so we know they are OK. The
remainder have been converted to use free() as appropriate.

I considered retaining a prefix_filename_unsafe() for cases
where we know the static lifetime is OK (and handling the
cleanup is awkward). This is only a handful of cases,
though, and it's not worth the mental energy in worrying
about whether the "unsafe" variant is OK to use in any
situation.

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>prefix_filename: drop length parameter</title>
<updated>2017-03-21T18:12:53Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2017-03-21T01:22:28Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=116fb64e439d3744d0f244a51d7a6d714b7703ae'/>
<id>urn:sha1:116fb64e439d3744d0f244a51d7a6d714b7703ae</id>
<content type='text'>
This function takes the prefix as a ptr/len pair, but in
every caller the length is exactly strlen(ptr). Let's
simplify the interface and just take the string. This saves
callers specifying it (and in some cases handling a NULL
prefix).

In a handful of cases we had the length already without
calling strlen, so this is technically slower. But it's not
likely to matter (after all, if the prefix is non-empty
we'll allocate and copy it into a buffer anyway).

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>parse-options: print "fatal:" before usage_msg_opt()</title>
<updated>2016-12-14T17:58:09Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2016-12-14T15:10:10Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=87433261a46db1a9bd012acd7fba868f009ba38f'/>
<id>urn:sha1:87433261a46db1a9bd012acd7fba868f009ba38f</id>
<content type='text'>
Programs may use usage_msg_opt() to print a brief message
followed by the program usage, and then exit. The message
isn't prefixed at all, though, so it doesn't match our usual
error output and is easy to overlook:

    $ git clone 1 2 3
    Too many arguments.

    usage: git clone [&lt;options&gt;] [--] &lt;repo&gt; [&lt;dir&gt;]

    -v, --verbose         be more verbose
    -q, --quiet           be more quiet
    --progress            force progress reporting
    -n, --no-checkout     don't create a checkout
    --bare                create a bare repository
    [...and so on for another 31 lines...]

It looks especially bad when the message starts with an
option, like:

    $ git replace -e
    -e needs exactly one argument

    usage: git replace [-f] &lt;object&gt; &lt;replacement&gt;
       or: git replace [-f] --edit &lt;object&gt;
    [...etc...]

Let's put our usual "fatal:" prefix in front of it.

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>parse-options.c: make OPTION_COUNTUP respect "unspecified" values</title>
<updated>2016-05-05T18:52:45Z</updated>
<author>
<name>Pranit Bauva</name>
<email>pranit.bauva@gmail.com</email>
</author>
<published>2016-05-05T09:50:00Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=e0070e8bd575c069ddc0a469c43076290210e79e'/>
<id>urn:sha1:e0070e8bd575c069ddc0a469c43076290210e79e</id>
<content type='text'>
OPT_COUNTUP() merely increments the counter upon --option, and resets it
to 0 upon --no-option, which means that there is no "unspecified" value
with which a client can initialize the counter to determine whether or
not --[no]-option was seen at all.

Make OPT_COUNTUP() treat any negative number as an "unspecified" value
to address this shortcoming. In particular, if a client initializes the
counter to -1, then if it is still -1 after parse_options(), then
neither --option nor --no-option was seen; if it is 0, then --no-option
was seen last, and if it is 1 or greater, than --option was seen last.

This change does not affect the behavior of existing clients because
they all use the initial value of 0 (or more).

Note that builtin/clean.c initializes the variable used with
OPT__FORCE (which uses OPT_COUNTUP()) to a negative value, but it is set
to either 0 or 1 by reading the configuration before the code calls
parse_options(), i.e. as far as parse_options() is concerned, the
initial value of the variable is not negative.

To test this behavior, in test-parse-options.c, "verbose" is set to
"unspecified" while quiet is set to 0 which will test the new behavior
with all sets of values.

Helped-by: Jeff King &lt;peff@peff.net&gt;
Helped-by: Eric Sunshine &lt;sunshine@sunshineco.com&gt;
Helped-by: Junio C Hamano &lt;gitster@pobox.com&gt;
Signed-off-by: Pranit Bauva &lt;pranit.bauva@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>parse-options: allow -h as a short option</title>
<updated>2015-11-20T13:02:07Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2015-11-17T10:25:38Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=5ad0d3d5266b83aa767a7efa09cb574d3c2968b3'/>
<id>urn:sha1:5ad0d3d5266b83aa767a7efa09cb574d3c2968b3</id>
<content type='text'>
Let callers provide their own handler for the short option -h even
without the flag PARSE_OPT_NO_INTERNAL_HELP, but call the internal
handler (showing usage information) if that is the only parameter.
Implement the first part by checking for -h only if parse_short_opt()
can't find it and returns -2.

Signed-off-by: Rene Scharfe &lt;l.s.r@web.de&gt;
Signed-off-by: Jeff King &lt;peff@peff.net&gt;
</content>
</entry>
</feed>
