<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/parse-options.h, branch v2.35.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.35.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.35.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2022-01-10T19:52:54Z</updated>
<entry>
<title>Merge branch 'js/branch-track-inherit'</title>
<updated>2022-01-10T19:52:54Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2022-01-10T19:52:54Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=0669bdf4ebc095a2b26654292e1ff38245ccf88a'/>
<id>urn:sha1:0669bdf4ebc095a2b26654292e1ff38245ccf88a</id>
<content type='text'>
"git -c branch.autosetupmerge=inherit branch new old" makes "new"
to have the same upstream as the "old" branch, instead of marking
"old" itself as its upstream.

* js/branch-track-inherit:
  config: require lowercase for branch.*.autosetupmerge
  branch: add flags and config to inherit tracking
  branch: accept multiple upstream branches for tracking
</content>
</entry>
<entry>
<title>branch: add flags and config to inherit tracking</title>
<updated>2021-12-21T06:40:21Z</updated>
<author>
<name>Josh Steadmon</name>
<email>steadmon@google.com</email>
</author>
<published>2021-12-21T03:30:23Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=d3115660b4cc4b1a32e77ddfd289afde5e4b94d8'/>
<id>urn:sha1:d3115660b4cc4b1a32e77ddfd289afde5e4b94d8</id>
<content type='text'>
It can be helpful when creating a new branch to use the existing
tracking configuration from the branch point. However, there is
currently not a method to automatically do so.

Teach git-{branch,checkout,switch} an "inherit" argument to the
"--track" option. When this is set, creating a new branch will cause the
tracking configuration to default to the configuration of the branch
point, if set.

For example, if branch "main" tracks "origin/main", and we run
`git checkout --track=inherit -b feature main`, then branch "feature"
will track "origin/main". Thus, `git status` will show us how far
ahead/behind we are from origin, and `git pull` will pull from origin.

This is particularly useful when creating branches across many
submodules, such as with `git submodule foreach ...` (or if running with
a patch such as [1], which we use at $job), as it avoids having to
manually set tracking info for each submodule.

Since we've added an argument to "--track", also add "--track=direct" as
another way to explicitly get the original "--track" behavior ("--track"
without an argument still works as well).

Finally, teach branch.autoSetupMerge a new "inherit" option. When this
is set, "--track=inherit" becomes the default behavior.

[1]: https://lore.kernel.org/git/20180927221603.148025-1-sbeller@google.com/

Signed-off-by: Josh Steadmon &lt;steadmon@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'ab/parse-options-cleanup'</title>
<updated>2021-11-09T21:19:06Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2021-11-09T21:19:06Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=84c99b20231e77fe1df7ea487e3dc24359cba028'/>
<id>urn:sha1:84c99b20231e77fe1df7ea487e3dc24359cba028</id>
<content type='text'>
Last minute fix to the update already in 'master'.

* ab/parse-options-cleanup:
  parse-options.[ch]: revert use of "enum" for parse_options()
</content>
</entry>
<entry>
<title>parse-options.[ch]: revert use of "enum" for parse_options()</title>
<updated>2021-11-09T17:45:37Z</updated>
<author>
<name>Ævar Arnfjörð Bjarmason</name>
<email>avarab@gmail.com</email>
</author>
<published>2021-11-09T11:04:43Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=06a199f38b50ccea198c29216c69bb389ca23391'/>
<id>urn:sha1:06a199f38b50ccea198c29216c69bb389ca23391</id>
<content type='text'>
Revert the parse_options() prototype change in my recent
352e761388b (parse-options.[ch]: consistently use "enum
parse_opt_result", 2021-10-08) was incorrect. The parse_options()
function returns the number of argc elements that haven't been
processed, not "enum parse_opt_result".

Reported-by: SZEDER Gábor &lt;szeder.dev@gmail.com&gt;
Signed-off-by: Ævar Arnfjörð Bjarmason &lt;avarab@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'ab/parse-options-cleanup'</title>
<updated>2021-10-25T23:06:59Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2021-10-25T23:06:59Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=65ca3245f99e3595ac483e4af5b2ff34b7985635'/>
<id>urn:sha1:65ca3245f99e3595ac483e4af5b2ff34b7985635</id>
<content type='text'>
Random changes to parse-options implementation.

* ab/parse-options-cleanup:
  parse-options: change OPT_{SHORT,UNSET} to an enum
  parse-options tests: test optname() output
  parse-options.[ch]: make opt{bug,name}() "static"
  commit-graph: stop using optname()
  parse-options.c: move optname() earlier in the file
  parse-options.h: make the "flags" in "struct option" an enum
  parse-options.c: use exhaustive "case" arms for "enum parse_opt_result"
  parse-options.[ch]: consistently use "enum parse_opt_result"
  parse-options.[ch]: consistently use "enum parse_opt_flags"
  parse-options.h: move PARSE_OPT_SHELL_EVAL between enums
</content>
</entry>
<entry>
<title>Merge branch 'ab/help-config-vars'</title>
<updated>2021-10-13T22:15:58Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2021-10-13T22:15:58Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=62f035aee3ff53aa9c5296d5acb4c4b683ba314d'/>
<id>urn:sha1:62f035aee3ff53aa9c5296d5acb4c4b683ba314d</id>
<content type='text'>
Teach "git help -c" into helping the command line completion of
configuration variables.

* ab/help-config-vars:
  help: move column config discovery to help.c library
  help / completion: make "git help" do the hard work
  help tests: test --config-for-completion option &amp; output
  help: simplify by moving to OPT_CMDMODE()
  help: correct logic error in combining --all and --guides
  help: correct logic error in combining --all and --config
  help tests: add test for --config output
  help: correct usage &amp; behavior of "git help --guides"
  help: correct the usage string in -h and documentation
</content>
</entry>
<entry>
<title>parse-options.[ch]: make opt{bug,name}() "static"</title>
<updated>2021-10-08T21:13:11Z</updated>
<author>
<name>Ævar Arnfjörð Bjarmason</name>
<email>avarab@gmail.com</email>
</author>
<published>2021-10-08T19:07:44Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=28794ec72e284ba398b562bc117e091853ef0332'/>
<id>urn:sha1:28794ec72e284ba398b562bc117e091853ef0332</id>
<content type='text'>
Change these two functions to "static", the last user of "optname()"
outside of parse-options.c itself went away in the preceding commit,
for the reasons noted in 9440b831ad5 (parse-options: replace
opterror() with optname(), 2018-11-10) we shouldn't be adding any more
users of it.

The "optbug()" function was never used outside of parse-options.c, but
was made non-static in 1f275b7c4ca (parse-options: export opterr,
optbug, 2011-08-11). I think the only external user of optname() was
the commit-graph.c caller added in 09e0327f57 (builtin/commit-graph.c:
introduce '--max-new-filters=&lt;n&gt;', 2020-09-18).

Signed-off-by: Ævar Arnfjörð Bjarmason &lt;avarab@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>parse-options.h: make the "flags" in "struct option" an enum</title>
<updated>2021-10-08T21:13:11Z</updated>
<author>
<name>Ævar Arnfjörð Bjarmason</name>
<email>avarab@gmail.com</email>
</author>
<published>2021-10-08T19:07:41Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=7bf7f0ba05b999e890f5738e08a7f5f70b71c633'/>
<id>urn:sha1:7bf7f0ba05b999e890f5738e08a7f5f70b71c633</id>
<content type='text'>
Change the "flags" members of "struct option" to refer to their
corresponding "enum" defined earlier in the file.

The benefit of changing this to an enum isn't as great as with some
"enum parse_opt_type" as we'll always check this as a bitfield, so we
can't rely on the compiler checking "case" arms for us. But let's do
it for consistency with the rest of the file.

Signed-off-by: Ævar Arnfjörð Bjarmason &lt;avarab@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>parse-options.[ch]: consistently use "enum parse_opt_result"</title>
<updated>2021-10-08T21:13:11Z</updated>
<author>
<name>Ævar Arnfjörð Bjarmason</name>
<email>avarab@gmail.com</email>
</author>
<published>2021-10-08T19:07:39Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=352e761388b5fa41bf40e7c04edf3cb07d888d94'/>
<id>urn:sha1:352e761388b5fa41bf40e7c04edf3cb07d888d94</id>
<content type='text'>
Use the "enum parse_opt_result" instead of an "int flags" as the
return value of the applicable functions in parse-options.c.

This will help catch future bugs, such as the missing "case" arms in
the two existing users of the API in "blame.c" and "shortlog.c". A
third caller in 309be813c9b (update-index: migrate to parse-options
API, 2010-12-01) was already checking for these.

As can be seen when trying to sort through the deluge of warnings
produced when compiling this with CC=g++ (mostly unrelated to this
change) we're not consistently using "enum parse_opt_result" even now,
i.e. we'll return error() and "return 0;". See f41179f16ba
(parse-options: avoid magic return codes, 2019-01-27) for a commit
which started changing some of that.

I'm not doing any more of that exhaustive migration here, and it's
probably not worthwhile past the point of being able to check "enum
parse_opt_result" in switch().

Signed-off-by: Ævar Arnfjörð Bjarmason &lt;avarab@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>parse-options.[ch]: consistently use "enum parse_opt_flags"</title>
<updated>2021-10-08T21:13:11Z</updated>
<author>
<name>Ævar Arnfjörð Bjarmason</name>
<email>avarab@gmail.com</email>
</author>
<published>2021-10-08T19:07:38Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=3f9ab7ccdea91b8312a14d39ce752b4d6685d067'/>
<id>urn:sha1:3f9ab7ccdea91b8312a14d39ce752b4d6685d067</id>
<content type='text'>
Use the "enum parse_opt_flags" instead of an "int flags" as arguments
to the various functions in parse-options.c.

Even though this is an enum bitfield there's there's a benefit to
doing this when it comes to the wider C ecosystem. E.g. the GNU
debugger (gdb) will helpfully detect and print out meaningful enum
labels in this case. Here's the output before and after when breaking
in "parse_options()" after invoking "git stash show":

Before:

    (gdb) p flags
    $1 = 9

After:

    (gdb) p flags
    $1 = (PARSE_OPT_KEEP_DASHDASH | PARSE_OPT_KEEP_UNKNOWN)

Of course as noted in[1] there's a limit to this smartness,
i.e. manually setting it with unrelated enum labels won't be
caught. There are some third-party extensions to do more exhaustive
checking[2], perhaps we'll be able to make use of them sooner than
later.

We've also got prior art using this pattern in the codebase. See
e.g. "enum bloom_filter_computed" added in 312cff52074 (bloom: split
'get_bloom_filter()' in two, 2020-09-16) and the "permitted" enum
added in ce910287e72 (add -p: fix checking of user input, 2020-08-17).

1. https://lore.kernel.org/git/87mtnvvj3c.fsf@evledraar.gmail.com/
2. https://github.com/sinelaw/elfs-clang-plugins/blob/master/enums_conversion/README.md

Signed-off-by: Ævar Arnfjörð Bjarmason &lt;avarab@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
